Jump to content

Question

Posted
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 ?

12 answers to this question

Recommended Posts

  • 0
Posted

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).

 

  • Upvote 1
  • 0
Posted

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;

 

  • 0
Posted
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).

  • 0
Posted (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 by MukkiesftKies
  • 0
Posted

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";

  • 0
Posted

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";

  • 0
Posted

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?

  • 0
Posted (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 by MukkiesftKies
  • 0
Posted
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.

  • Love 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...