MukkiesftKies Posted July 21, 2018 Group: Members Topic Count: 39 Topics Per Day: 0.01 Content Count: 123 Reputation: 7 Joined: 03/13/12 Last Seen: January 2, 2019 Share Posted July 21, 2018 setarray .@items[0],501,502; switch(select("Adjust Effect:Close")) { case 1: for( set .@i,0; .@i < getarraysize(.@items[.@i]); set .@i,.@i + 1 ) set .@menu$,.@menu$+getitemname(.@items[.@i])+":"; .@i = select( .@menu$ ) - 1; end; } L_Check: if( countitem (.@items[.@i]) ) goto L_NotEnough; delitem .@items[.@i],1; mes" Ok, Your effect"; Countitem can not find item, what problem with my script ? Quote Link to comment Share on other sites More sharing options...
0 Jarek Posted July 21, 2018 Group: Members Topic Count: 0 Topics Per Day: 0 Content Count: 143 Reputation: 30 Joined: 12/23/11 Last Seen: March 9 Share Posted July 21, 2018 Double check this: if( countitem (.@items[.@i]) ) goto L_NotEnough; If I have this item then I go to L_NotEnough? Probably should be: if( !countitem (.@items[.@i]) ) goto L_NotEnough; Quote Link to comment Share on other sites More sharing options...
0 MukkiesftKies Posted July 22, 2018 Group: Members Topic Count: 39 Topics Per Day: 0.01 Content Count: 123 Reputation: 7 Joined: 03/13/12 Last Seen: January 2, 2019 Author Share Posted July 22, 2018 12 hours ago, Jarek said: Double check this: if( countitem (.@items[.@i]) ) goto L_NotEnough; If I have this item then I go to L_NotEnough? Probably should be: if( !countitem (.@items[.@i]) ) goto L_NotEnough; yaa i already try. can count. but when i choose Yellow Potion. my map show this [Error]: buildin_delitem: failed to delete 1 items (AID=2000000 item_id=501). Quote Link to comment Share on other sites More sharing options...
0 Jarek Posted July 22, 2018 Group: Members Topic Count: 0 Topics Per Day: 0 Content Count: 143 Reputation: 30 Joined: 12/23/11 Last Seen: March 9 Share Posted July 22, 2018 if( countitem (.@items[.@i]) < 1 ) goto L_NotEnough; 1 Quote Link to comment Share on other sites More sharing options...
0 MukkiesftKies Posted July 22, 2018 Group: Members Topic Count: 39 Topics Per Day: 0.01 Content Count: 123 Reputation: 7 Joined: 03/13/12 Last Seen: January 2, 2019 Author Share Posted July 22, 2018 (edited) 21 minutes ago, Jarek said: if( countitem (.@items[.@i]) < 1 ) goto L_NotEnough; it work. but when i set to yellow potion, countitem still read red potion. Edited July 22, 2018 by MukkiesftKies Quote Link to comment Share on other sites More sharing options...
0 MukkiesftKies Posted July 22, 2018 Group: Members Topic Count: 39 Topics Per Day: 0.01 Content Count: 123 Reputation: 7 Joined: 03/13/12 Last Seen: January 2, 2019 Author Share Posted July 22, 2018 setarray .@items[0],501,502; switch(select("Use Super Power:Set Super Power:Close")) { case 1: if (isequipped( )) goto L_Check; case 2: for( set .@i,0; .@i < getarraysize(.@items[.@i]); set .@i,.@i + 1 ) set .@menu$,.@menu$+getitemname(.@items[.@i])+":"; .@i = select( .@menu$ ) - 1; end; << if i remove this countitem can detect what item i choose but straight to L_Check, without select USE SUPER POWER. } L_Check: if( !countitem (.@items[.@i]) ) goto L_NotEnough; delitem .@items[.@i],1; mes "You got Meteor Storm Skill"; Quote Link to comment Share on other sites More sharing options...
0 MukkiesftKies Posted July 22, 2018 Group: Members Topic Count: 39 Topics Per Day: 0.01 Content Count: 123 Reputation: 7 Joined: 03/13/12 Last Seen: January 2, 2019 Author Share Posted July 22, 2018 setarray .@items[0],501,502; switch(select("Use Super Power:Set Super Power:Close")) { case 1: if (isequipped( )) goto L_Check; case 2: for( set .@i,0; .@i < getarraysize(.@items[.@i]); set .@i,.@i + 1 ) set .@menu$,.@menu$+getitemname(.@items[.@i])+":"; .@i = select( .@menu$ ) - 1; end; << if i remove this countitem can detect what item i choose but straight to L_Check, without select USE SUPER POWER. } L_Check: if( !countitem (.@items[.@i]) ) goto L_NotEnough; delitem .@items[.@i],1; mes "You got Meteor Storm Skill"; Quote Link to comment Share on other sites More sharing options...
0 MukkiesftKies Posted July 24, 2018 Group: Members Topic Count: 39 Topics Per Day: 0.01 Content Count: 123 Reputation: 7 Joined: 03/13/12 Last Seen: January 2, 2019 Author Share Posted July 24, 2018 someone help Quote Link to comment Share on other sites More sharing options...
0 Zell Posted July 24, 2018 Group: Members Topic Count: 53 Topics Per Day: 0.01 Content Count: 412 Reputation: 266 Joined: 04/25/12 Last Seen: Tuesday at 02:08 PM Share Posted July 24, 2018 To help you first, I need to understand. I can not understand your logic (since you're not passing the whole script). Does the player choose to use an item and then take the meteor stomer? choose "set super power", will do what? Quote Link to comment Share on other sites More sharing options...
0 Technoken Posted July 25, 2018 Group: Members Topic Count: 27 Topics Per Day: 0.01 Content Count: 505 Reputation: 127 Joined: 04/04/16 Last Seen: Sunday at 02:20 PM Share Posted July 25, 2018 since you are using a scope variable(.@) for the array, it will end when the script ends. You can try to use a temporary character variable (@) instead to pass the array. Just make sure that the variable name is a unique one. Quote ".@" - A scope variable. They are unique to the instance and scope. Each instance has its own scope that ends when the script ends. Calling a function with callsub/callfunc starts a new scope, returning from the function ends it. When a scope ends, its variables are converted to values ('return .@var;' returns a value, not a reference). 1 Quote Link to comment Share on other sites More sharing options...
0 MukkiesftKies Posted July 25, 2018 Group: Members Topic Count: 39 Topics Per Day: 0.01 Content Count: 123 Reputation: 7 Joined: 03/13/12 Last Seen: January 2, 2019 Author Share Posted July 25, 2018 (edited) 19 hours ago, Zell said: To help you first, I need to understand. I can not understand your logic (since you're not passing the whole script). Does the player choose to use an item and then take the meteor stomer? choose "set super power", will do what? i just want to make array pass from end; when the script ends. for example :- setarray .@menuStrs$[0], "Warp","Fly","Shit"; set @menu$,""; for (set @i,0; @i < getarraysize(.@menuStrs$); set @i,@i+1) { if (@i) set @menu$,@menu$+":"; set @menu$,@menu$+.@menuStrs$[@i]; } set @selection,select(@menu$)-1; i take this from https://rathena.org/board/topic/87190-how-to-use-array-as-a-menu/. but when i try to put end; to the end script. array can not be read. because i change menu to id number. like my first post. @Technoken Quote since you are using a scope variable(.@) for the array, it will end when the script ends. You can try to use a temporary character variable (@) instead to pass the array. Just make sure that the variable name is a unique one. can you show me some example ? hehe Edited July 25, 2018 by MukkiesftKies Quote Link to comment Share on other sites More sharing options...
0 Zell Posted July 25, 2018 Group: Members Topic Count: 53 Topics Per Day: 0.01 Content Count: 412 Reputation: 266 Joined: 04/25/12 Last Seen: Tuesday at 02:08 PM Share Posted July 25, 2018 2 hours ago, MukkiesftKies said: i just want to make array pass from end; when the script ends. for example :- setarray .@menuStrs$[0], "Warp","Fly","Shit"; set @menu$,""; for (set @i,0; @i < getarraysize(.@menuStrs$); set @i,@i+1) { if (@i) set @menu$,@menu$+":"; set @menu$,@menu$+.@menuStrs$[@i]; } set @selection,select(@menu$)-1; i take this from https://rathena.org/board/topic/87190-how-to-use-array-as-a-menu/. but when i try to put end; to the end script. array can not be read. because i change menu to id number. like my first post. @Technoken can you show me some example ? hehe Ok, got it. Like Technoken sayed, just change .@items to @items. This will work, but still is a ugly approach. If you need a player to handle a setarray with a @ ou permanent variable you are making something wrong in your logic. If exists some situation which you need to make something like this, to create a new table is the go. 1 Quote Link to comment Share on other sites More sharing options...
0 MukkiesftKies Posted July 26, 2018 Group: Members Topic Count: 39 Topics Per Day: 0.01 Content Count: 123 Reputation: 7 Joined: 03/13/12 Last Seen: January 2, 2019 Author Share Posted July 26, 2018 (edited) @Technoken @Zell thank you so much. it work now. Edited July 26, 2018 by MukkiesftKies Quote Link to comment Share on other sites More sharing options...
Question
MukkiesftKies
setarray .@items[0],501,502; switch(select("Adjust Effect:Close")) { case 1: for( set .@i,0; .@i < getarraysize(.@items[.@i]); set .@i,.@i + 1 ) set .@menu$,.@menu$+getitemname(.@items[.@i])+":"; .@i = select( .@menu$ ) - 1; end; } L_Check: if( countitem (.@items[.@i]) ) goto L_NotEnough; delitem .@items[.@i],1; mes" Ok, Your effect";
Countitem can not find item, what problem with my script ?
Link to comment
Share on other sites
12 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.