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 05-29-2008, 01:22 PM   #1 (permalink)
Newbie
 
Join Date: May 2008
Age: 18
Posts: 54
Send a message via MSN to Nemesy
Default Gump Radio Buttons...

I've done A_Li_N's Gump Tutorial and searched through to forums, but have failed to find much information on radio buttons. The information I did find was not detailed enough for me to understand. (I'm new at scripting.) More specifically,what I'm having a hard time with is with the things that happen as a result of the radio button's state when the gump is closed. Hopefully, your answers will help other people in the same situation as me. Thanx!
Nemesy is offline   Reply With Quote
Old 05-29-2008, 06:25 PM   #2 (permalink)
Forum Expert
 
Lokai's Avatar
 
Join Date: Aug 2003
Location: Bergen, NY (Rochester)
Age: 41
Posts: 1,425
Send a message via ICQ to Lokai Send a message via MSN to Lokai Send a message via Yahoo to Lokai
Default

Quote:
Originally Posted by Nemesy View Post
I've done A_Li_N's Gump Tutorial and searched through to forums, but have failed to find much information on radio buttons. The information I did find was not detailed enough for me to understand. (I'm new at scripting.) More specifically,what I'm having a hard time with is with the things that happen as a result of the radio button's state when the gump is closed. Hopefully, your answers will help other people in the same situation as me. Thanx!
Here is a simple example:

Code:
     public override void OnResponse(NetState sender, RelayInfo info)
     {
            bool radio1 = info.IsSwitched(1);
            bool radio2 = info.IsSwitched(2);
   
            if (radio1)
                DoMyRoutine(sender.Mobile);
            else if (radio2)
                DoMyOtherRoutine(sender.Mobile);
       }
Basically, when you create a radio button, you assign it a switch ID, just like a checkbox. The main difference is that only one radio button in any group of buttons will be able to be turned "on". In this example, I create 2 boolean values, radio1 and radio2, and assign each to one of 2 Switches. I hope this helps.
Lokai is offline   Reply With Quote
Old 05-29-2008, 09:27 PM   #3 (permalink)
Newbie
 
Join Date: May 2008
Age: 18
Posts: 54
Send a message via MSN to Nemesy
Default

I've just put what you said into my script (which is a race selection gump) but I get an error. (Most likely because of a mistake from my part.) I got info on how to change race here:
How to Change Race via Script?

Here are the errors:

Errors:
+ Custom/RaceGump/Racegump.cs:
CS0103: Line 40: Le nom 'mob' n'existe pas dans le contexte actuel
CS0149: Line 40: Nom de méthode attendu
CS0103: Line 42: Le nom 'mob' n'existe pas dans le contexte actuel
CS0149: Line 42: Nom de méthode attendu
CS0103: Line 44: Le nom 'mob' n'existe pas dans le contexte actuel
CS0103: Line 45: Le nom 'mob' n'existe pas dans le contexte actuel

Its in french so i'll try to translate:
CS0103: Line 40: The name 'mob' does not exist in the actual context.
CS0149: Line 40: Method name expected

Here is the script: (I wrote the line numbers from Errors in comments)

RaceGump.cs
Code:
using System;
using Server;
using Server.Gumps;
using Server.Network;

namespace Server.Gumps
{
	public class RaceGump : Gump
	{
		public RaceGump() : base( 50, 50 )
		{
			this.Closable=false;
			this.Disposable=false;
			this.Dragable=false;
			this.Resizable=false;

			AddPage(0);

			AddBackground(0, 0, 200, 200, 9270);

			AddRadio(20, 30, 208, 209, true, 1);
			AddRadio(20, 60, 208, 209, false, 2);
			AddRadio(20, 90, 208, 209, false, 3);

			AddLabel( 40, 30, 1153, "Human" );
 			AddLabel( 40, 60, 1153, "Elf" );
 			AddLabel( 40, 90, 1153, "Drow" );

			AddLabel(40, 120, 1153, "Okay");
			AddButton(20, 120, 247, 248, 20, GumpButtonType.Reply, 0);
		}

        	public override void OnResponse(NetState sender, RelayInfo info)
		{       
			bool radio1 = info.IsSwitched(1);
			bool radio2 = info.IsSwitched(2);
			bool radio3 = info.IsSwitched(3);
   
			if (radio1)
				mob.Race = Race.Races[33](sender.Mobile);	                                         //line 40
			else if (radio2)
				mob.Race = Race.Races[34](sender.Mobile);	                                         //line 42
			else if (radio3)
				mob.Race = Race.Races[35];	// Maybe this way is better than               //line 44
				mob.Race(sender.Mobile);	   // the two above? (no method error)        //line 45
		}
	}
}
Nemesy is offline   Reply With Quote
Old 05-30-2008, 06:14 AM   #4 (permalink)
Forum Expert
 
Lokai's Avatar
 
Join Date: Aug 2003
Location: Bergen, NY (Rochester)
Age: 41
Posts: 1,425
Send a message via ICQ to Lokai Send a message via MSN to Lokai Send a message via Yahoo to Lokai
Default

You were close, but you needed to create the variable 'mob' before trying to use it.

How about this?:

Code:
using System;
using Server;
using Server.Gumps;
using Server.Network;
namespace Server.Gumps
{
 public class RaceGump : Gump
 {
  public RaceGump() : base( 50, 50 )
  {
   this.Closable=false;
   this.Disposable=false;
   this.Dragable=false;
   this.Resizable=false;
   AddPage(0);
   AddBackground(0, 0, 200, 200, 9270);
   AddRadio(20, 30, 208, 209, true, 1);
   AddRadio(20, 60, 208, 209, false, 2);
   AddRadio(20, 90, 208, 209, false, 3);
   AddLabel( 40, 30, 1153, "Human" );
    AddLabel( 40, 60, 1153, "Elf" );
    AddLabel( 40, 90, 1153, "Drow" );
   AddLabel(40, 120, 1153, "Okay");
   AddButton(20, 120, 247, 248, 20, GumpButtonType.Reply, 0);
  }
         public override void OnResponse(NetState sender, RelayInfo info)
  {       
   bool radio1 = info.IsSwitched(1);
   bool radio2 = info.IsSwitched(2);
   bool radio3 = info.IsSwitched(3);
   
   if (sender.Mobile is PlayerMobile)
   {
    PlayerMobile mob = sender.Mobile as PlayerMobile;
   
    if (radio1)
     mob.Race = Race.Races[33];
    else if (radio2)
     mob.Race = Race.Races[34];
    else if (radio3)
     mob.Race = Race.Races[35];
   }
  }
 }
}
Lokai is offline   Reply With Quote
Old 05-30-2008, 09:42 AM   #5 (permalink)
Newbie
 
Join Date: May 2008
Age: 18
Posts: 54
Send a message via MSN to Nemesy
Default

After adding:
Code:
using Server.Mobiles;
to the beginning of the script, I tested it and it worked fine. (My first script has been completed, yay!)

Thanx a lot!
I added a "Many thanks to Lokai" at the beginning of the script
Nemesy 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