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 08-16-2008, 01:37 PM   #1 (permalink)
Forum Novice
 
Ice19999's Avatar
 
Join Date: Apr 2005
Age: 22
Posts: 102
Send a message via Yahoo to Ice19999
Question Gump Button doing a command?

How would i go about makeing a gump button do this command?
[online addtopack Item [Amount] set hue [Number]
anyone have any ideas?
Ice19999 is offline   Reply With Quote
Old 08-16-2008, 02:07 PM   #2 (permalink)
Forum Novice
 
Soteric's Avatar
 
Join Date: Aug 2006
Location: Russia, Rostov-on-Don
Posts: 772
Send a message via ICQ to Soteric
Default

Code:
foreach ( NetState state in NetState.Instances )
{
	Item item = new Item();
	item.Amount = amount;
	item.Hue = number;
	state.Mobile.AddToBackpack( item );
}
Soteric is offline   Reply With Quote
Old 08-16-2008, 02:43 PM   #3 (permalink)
Forum Novice
 
Ice19999's Avatar
 
Join Date: Apr 2005
Age: 22
Posts: 102
Send a message via Yahoo to Ice19999
Default

Well i tried that but im guess i did it wrong bcs i got errors, this is how i used it

Code:
using System; 
using Server;
using Server.Misc;
using Server.Spells;
using Server.Regions;
using Server.Items;
using Server.Gumps; 
using Server.Network; 
using Server.Menus; 
using Server.Menus.Questions; 

namespace Server.Gumps
{
	public class RebookG : Gump
	{
		public RebookG( Mobile owner ) : base( 150, 60 )
		{
			Closable=true;
			Disposable=true;
			Dragable=true;
			Resizable=false;
			
AddPage(0);
AddBackground(92, 69, 100, 134, 9200);
AddImage(110, 75, 15119);
AddButton(109, 158, 247, 248, 1, GumpButtonType.Reply, 0);
			
		}

		foreach ( NetState state in NetState.Instances )
{
	switch ( info.ButtonID ) 
	{
			case 0: 
			{
			 break; 
			}
			case 1:
			{
					Item item = new Gold();
					item.Amount = 500;
					item.Hue = 1500;
					state.Mobile.AddToBackpack( item );
					break;
			}
			}

namespace Server.Items 
{ 
	public class Rebook : Item 
	{ 
		[Constructable] 
		public Rebook() : base( 7187 ) 
		{ 
			 
			Weight = 0; 
			Movable = true; 
			Name = "Reward Book"; 
			LootType = LootType.Blessed; 
			} 

        public Rebook( Serial serial ) : base( serial ) { } 

          public override void OnDoubleClick(Mobile from)
        {
            if (IsChildOf(from.Backpack))
            {
                from.CloseGump(typeof(RebookG));
                from.SendGump(new RebookG(this));
            }
            else
            {
                from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
            }
        } 

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

        public override void Deserialize( GenericReader reader ) 
        {
	         base.Deserialize( reader ); int version = reader.ReadInt(); 
	    } 
	} 
}

and these are the errors i got.
Code:
Errors:
 + thisisit.cs:
    CS1519: Line 30: Invalid token 'foreach' in class, struct, or interface memb
er declaration
    CS1002: Line 30: ; expected
    CS1519: Line 30: Invalid token ')' in class, struct, or interface member dec
laration
    CS1519: Line 32: Invalid token ')' in class, struct, or interface member dec
laration
    CS1519: Line 41: Invalid token '=' in class, struct, or interface member dec
laration
    CS1519: Line 42: Invalid token '=' in class, struct, or interface member dec
laration
    CS1519: Line 43: Invalid token '(' in class, struct, or interface member dec
laration
    CS1519: Line 43: Invalid token ')' in class, struct, or interface member dec
laration
thanks much for your help.
Ice19999 is offline   Reply With Quote
Old 08-16-2008, 02:50 PM   #4 (permalink)
Forum Novice
 
Join Date: Jan 2006
Posts: 329
Default

You need to add
Code:
using System.Collections.Generic;
to the top of your script and define the OnResponse method for the gump.
razzles is offline   Reply With Quote
Old 08-16-2008, 04:58 PM   #5 (permalink)
Forum Novice
 
Ice19999's Avatar
 
Join Date: Apr 2005
Age: 22
Posts: 102
Send a message via Yahoo to Ice19999
Default

what do you mean define the OnResponse method i tried to do it like this but it didnt work. How would you define it?

Code:
public override void OnResponse foreach( NetState state in NetState.Instances )

i also tried this
Code:
public override void OnResponse( NetState state in NetState.Instances )
but all i got was some
CS1026: Line 31: ; expected
and
CS1026: Line 31: ) expected
errors
Ice19999 is offline   Reply With Quote
Old 08-16-2008, 05:06 PM   #6 (permalink)
Newbie
 
Sixkillers's Avatar
 
Join Date: May 2006
Location: Czech Republic
Posts: 78
Default

You dont have to use namespace System.Collections.Generic. You have to place foreach cycle into method (i.e. OnDoubleClick) no just anywhere you want. You will have to gain some skills in C#. Your method can be:

PHP Code:
public override void OnDoubleClickMobile m )
{
  foreach ( 
NetState state in NetState.Instances )
  {
    
Item item = new Item();
    
item.Amount amount;
    
item.Hue number;
    
state.Mobile.AddToBackpackitem );
  }

Sixkillers is offline   Reply With Quote
Reply

Bookmarks


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