Triedge 12 Posted January 1, 2014 Would it be possible to create a menu that displays certain options if certain conditions are met? Quote Share this post Link to post Share on other sites
0 AnnieRuru 957 Posted January 2, 2014 prontera,150,180,5 script jfhskdfjs 100,{ if ( BaseLevel < 5 ) { mes "only level 5 or above"; close; } mes "asdasd"; next; for ( .@i = 0; .@i < 19; .@i++ ) { if ( countitem( 501 + .@i ) ) { .@menu$ = .@menu$ + "Option "+( .@i +1 )+"!:"; .@option[.@c] = .@i; .@itemid[.@c] = 501 + .@i; .@c++; } } .@s = select( .@menu$ ) -1; mes "selected option no: "+( .@option[.@s] +1 ); mes getitemname( .@itemid[.@s] ); close;} 2 Mumbles and pan reacted to this Quote Share this post Link to post Share on other sites
0 jaBote 438 Posted January 1, 2014 Of course: select("Normal settings"+((getgmlevel >=90) ? ":GM configurations" : "") ) Quote Share this post Link to post Share on other sites
0 Triedge 12 Posted January 1, 2014 That works well for small menus.But I need that for example, note 10 conditions. and fulfilled every condition, adds an option to the menu.Example:select("Nothing" +((BaseLevel >=5) ? ":Only Have 5 Level" +((BaseLevel >=5) && counitem(501) > 0 ? ":Only Have 5 Level and have item 501": +((BaseLevel >=5) && counitem(502) > 0 ? ":Only Have 5 Level and have item 502":"") ) Let's say you have level 5 and item 502.Obviously the options 1,2 and 4 appear, but the 3 does not appear. And while I understand as "creating" the menu, as it should make it work properly? Quote Share this post Link to post Share on other sites
0 jaBote 438 Posted January 2, 2014 Blank options (which is for example the 2nd option in "opt1::opt3") are unselectable, so you can safely switch(select("opt1::opt3")) being sure nobody will ever use option 2. Be careful the script command name is countitem, not counitem and you have unbalanced brackets there. If you'd want that menu just work with level 5, you'd need to make your checks using the "is equal to" (==) operator, not the "greater or equal" (>=) one. Else you're correct on that. About your example without minding these mistakes: its also hard to read to the point I've given up trying to fully understand that (no offense). A better example (readable but not the most efficient of all possibilities) could be like this: select("I meet no requisites:" + ((BaseLevel >= 5) ? "I'm level 5 or greater!" : "") + ":" // 2nd option + ((BaseLevel >= 5 && countitem(501)) ? "I'm level 5 or greater and I have "+getitemname(501)+"!" : "") + ":" // 3rd option + ((BaseLevel >= 5 && countitem(502)) ? "I'm level 5 or greater and I have "+getitemname(502)+"!" : "") // 4th and last option ) If you badly want to make it the most efficient way you'd end up writing more and making it less readable than it currently is. Quote Share this post Link to post Share on other sites
0 Triedge 12 Posted January 2, 2014 Mm ... what would be the correct way to run something like this: select("I meet no requisites:" + ((countitem(501)) ? "Option 1!" : "") + ":" + ((countitem(502)) ? "Option 2!" : "") + ":" + ((countitem(503)) ? "Option 3!" : "") + ":" + ((countitem(504)) ? "Option 4!" : "") + ":" + ((countitem(505)) ? "Option 5!" : "") + ":" + ((countitem(506)) ? "Option 6!" : "") + ":" + ((countitem(507)) ? "Option 7!" : "") + ":" + ((countitem(508)) ? "Option 8!" : "") + ":" + ((countitem(509)) ? "Option 9!" : "") + ":" + ((countitem(510)) ? "Option 10!" : "") + ":" + ((countitem(511)) ? "Option 11!" : "") + ":" + ((countitem(512)) ? "Option 12!" : "") + ":" + ((countitem(513)) ? "Option 13!" : "") + ":" + ((countitem(514)) ? "Option 14!" : "") + ":" + ((countitem(515)) ? "Option 15!" : "") + ":" + ((countitem(516)) ? "Option 16!" : "") + ":" + ((countitem(517)) ? "Option 17!" : "") + ":" + ((countitem(518)) ? "Option 18!" : "") + ":" + ((countitem(519)) ? "Option 19!" : "") ) Quote Share this post Link to post Share on other sites
0 jaBote 438 Posted January 2, 2014 Seems correct. Please keep in mind that empty options will appear as an empty option in your menu, so that "opt1::opt3" when rendered as a menu will be: opt1opt3 And well, that's pretty much it if you don't have more questions. Quote Share this post Link to post Share on other sites
Would it be possible to create a menu that displays certain options if certain conditions are met?
Share this post
Link to post
Share on other sites