![]() |
GUI textlist problem.
I'm a bit new to GS2, but i managed to make a GUI that pops up, gives the player a list of options, which the player clicks, then clicks the button that applies the selection and closes the window.
Inside the script telling the apply button to check what was selected, i basically use the following setup: if(){} else if () {} else if () {} else if () {} etc. however, it seems that no matter what i select, it always chooses whatever the last if(){} on the list was. for examle If the setup is the following: if(){}//line 1 if(){}//line 2 if(){}//line 3 if(){}//line 4 then whatever i select will be whatever is on line 4. HOWEVER, if the setup is like this: if(){}//line 1 else if(){}//line 2 else if(){}//line 3 else if(){}//line 4 then no matter what option is chosen, the NPC will always use whatever is on line 1. has the "else" feature changed in GS2 or something? EDIT: Maybe "GUI textlist problem" was the wrong name to call the thread, but any help would still be greatly appreciated. |
Post the code that you're having the problem with?
|
No, the "else feature" works the same as it always has, which is exactly as it should work.
PHP Code:
^The above would set your chat to "FooBar!" |
on another glance, it might actually be that it may not be checking/setting strings the same way?
heres the area i'm having trouble with: PHP Code:
|
For comparision, you need to be using == and not =.
Also (not related to your problem), setstring is GS1 and deprecated. You should be using something like this instead: PHP Code:
|
Also, if profession1 and the rest are not variables, you need to use quotes because they are strings.
It might also be simpler to just forget the if statements and just do something like: PHP Code:
|
edit: okay it got that working. i just needed a few more things in quotes.
thanks for the help guys. but before i'm done with this thread, whats the advantage of using PHP Code:
edit: nvm lol |
Quote:
PHP Code:
Just for reference, when you check or assign literal strings, you need to use quotes. For example, the first 'if' statement should have been: PHP Code:
|
yep, thanks for the help guys :D
|
| All times are GMT +2. The time now is 11:05 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.