|
||
|
|||||||
| Script Support Get support for modifying RunUO Scripts, or writing your own! |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 (permalink) |
|
Newbie
|
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!
|
|
|
|
|
|
#2 (permalink) | |
|
Forum Expert
|
Quote:
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);
}
|
|
|
|
|
|
|
#3 (permalink) |
|
Newbie
|
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
}
}
}
|
|
|
|
|
|
#4 (permalink) |
|
Forum Expert
|
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];
}
}
}
}
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|