Page 1 of 1

Checkboxes on Gumps

Posted: Sun Sep 03, 2006 10:56 am
by Chilliden
im having a problem with Checkboxes in a gump, i iused the example stated in the gumpsdoc. But it does not work.

Code: Select all

var choice:=SendDialogGump( who, gflayout, gfdata ); 
var his_choice;
foreach key in ( choice.keys ) 
his_choice := his_choice + key;
endforeach 

if (choice[100])
	SendSysMessage(who, "Red");
	CreateItemInBackpack(who, 3172,1);
elseif
	(choice[200])
		SendSysMessage(who, "Green");
		CreateItemInBackpack(who, 3186,1);

endif
if(choice[100] && choice[200])
                SendSysMessage(who,"You combined red and green");
endif
the script works but, i want it to work separate, if i press red and green, it will create the items and stat the sysmessage, I want it so if i press red and green only the sysmessage will be shown

thnx in advance[/code]

Posted: Mon Sep 04, 2006 12:07 am
by Marilla
As long as I've been working with POL, gumps are still my nemesis :P However, I see a clear problem here from what you've described.


The way you have your IFs defined, if someone selects both, they will get the 'red' item created, AND get the message saying they checked both. They shouldn't get the green item created, though.


My guess is what you really want is a radio button, not a check box... you want them to choose only ONE or the other, right? (in evidence for my gump ignorance, I ask this question: Do UO gumps HAVE radio buttons? :P )



Assuming that's what you want, but you still want to use the check boxes, you need to re-order your code a bit.

Code: Select all

if (choice[100] && choice[200])
   SendSysMessage(who, "You chose both!");
elseif (choice[100])
   Blah...
elseif (choice[200])
   blah...
endif

Posted: Mon Sep 04, 2006 3:56 am
by Chilliden
I'll try that solution.

My idea was too have a gump with 3 checkboxes on it, and they could choose them seperate or together. So i.e u got 3 checkboxes called red green and blue, i want to do something if they choose Red and when they choose Red and Blue i wanna do something too. Hope that explains my question :?