Go Back   RunUO - Ultima Online Emulation > RunUO > Script Support

Script Support Get support for modifying RunUO Scripts, or writing your own!

Reply
 
Thread Tools Display Modes
Old 03-19-2008, 07:26 PM   #1 (permalink)
Forum Novice
 
typhoonbot's Avatar
 
Join Date: Dec 2006
Posts: 480
Default IF statements ?

Hey guys, I'm just trying to make an item. it has a custom name. example: "a piece of pie" now, the graphic I used was NOT a stackable graphic, so in the items property section I have "stackable = true ;" and that works fine, and the item stacks, however after more than one, it says " 2 a piece of pie". I need it to say "2 pieces of pie" obviously.

What I was thinking I would do is have an IF statement something like the following...

Code:
If (m.Amount > 1)
{
      name = "pieces of pie" ;
}
however as im sure u can imagine, that didnt work

first of all: where in the script do I put the if statement, and what did I do wrong with it ?

im running 2.0 RC1, and here is how the script looks:


Code:
using System;
using Server.Network;
using Server.Items;
using Server.Targeting;

namespace Server.Items
{
	public class pieceofpie : Item
  {


      [Constructable]
		public pieceofpie()
			: base(12696)
		{
          Name = "A Piece Of Pie";
          Stackable = true;
		}
		
		public pieceofpie( Serial serial ) : base( serial )
		{
		}

		public override void Serialize( GenericWriter writer )
		{
			base.Serialize( writer );
			writer.Write( (int) 0 ); // version
		}

		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );

			int version = reader.ReadInt();
		}
	}
}
TA and regards...
__________________
legendsofkaine.page.tl
typhoonbot is offline   Reply With Quote
Old 03-19-2008, 07:36 PM   #2 (permalink)
Newbie
 
Henry_R's Avatar
 
Join Date: Nov 2007
Location: indiana
Age: 45
Posts: 52
Default

hi...

try this:

Code:
 using System;
using Server.Network;
using Server.Items;
using Server.Targeting;

namespace Server.Items
{
    public class pieceofpie : Item
  {


      [Constructable]
        public pieceofpie(int amount)
            : base(12696)
        {
          Name = "A Piece Of Pie";
          Stackable = true;
          Amount = amount;
          
          
        }
        
        public pieceofpie( Serial serial ) : base( serial )
        {
        }

        public override void Serialize( GenericWriter writer )
        {
            base.Serialize( writer );
            writer.Write( (int) 0 ); // version
        }

        public override void Deserialize( GenericReader reader )
        {
            base.Deserialize( reader );

            int version = reader.ReadInt();
        }
    }
}
you may run into a problem if your graphic doesnt have a *stackable* counterpart....and im not sure how to do that.....


hope this helps


henry_r

edit to add:

after looking at your post closer...and looking at a few items in-game... take *empty bottle* for example; 1 bottle is *empty bottle*, 50 bottles stacked are *50 empty bottle*.
it might be easier to rename *A piece of pie* to simply *piece of pie*. it wont be correct grammatical form, but your players will know what it is.

edit 2

if you use CheeseSlice (base 0x97C) it looks like a slice of pie and has a stackable graphic counterpart

ill shut up now
__________________
Scripts: Compiling C# scripts...done (0 errors, 0 warnings) WOOHOO

Last edited by Henry_R; 03-19-2008 at 08:18 PM.
Henry_R is offline   Reply With Quote
Reply

Bookmarks

Tags
ifstatement, issues


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC5