Jump to content
  • 0

save setarray after end;


MukkiesftKies

Question


  • Group:  Members
  • Topic Count:  39
  • Topics Per Day:  0.01
  • Content Count:  123
  • Reputation:   7
  • Joined:  03/13/12
  • Last Seen:  

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

  • 0

  • Group:  Members
  • Topic Count:  27
  • Topics Per Day:  0.01
  • Content Count:  505
  • Reputation:   126
  • Joined:  04/04/16
  • Last Seen:  

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
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  143
  • Reputation:   30
  • Joined:  12/23/11
  • Last Seen:  

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;

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  39
  • Topics Per Day:  0.01
  • Content Count:  123
  • Reputation:   7
  • Joined:  03/13/12
  • Last Seen:  

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

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  143
  • Reputation:   30
  • Joined:  12/23/11
  • Last Seen:  

if( countitem (.@items[.@i]) < 1 ) goto L_NotEnough;

 

  • Love 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  39
  • Topics Per Day:  0.01
  • Content Count:  123
  • Reputation:   7
  • Joined:  03/13/12
  • Last Seen:  

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
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  39
  • Topics Per Day:  0.01
  • Content Count:  123
  • Reputation:   7
  • Joined:  03/13/12
  • Last Seen:  

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

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  39
  • Topics Per Day:  0.01
  • Content Count:  123
  • Reputation:   7
  • Joined:  03/13/12
  • Last Seen:  

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

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  39
  • Topics Per Day:  0.01
  • Content Count:  123
  • Reputation:   7
  • Joined:  03/13/12
  • Last Seen:  

someone help /help

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  53
  • Topics Per Day:  0.01
  • Content Count:  411
  • Reputation:   259
  • Joined:  04/25/12
  • Last Seen:  

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?

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  39
  • Topics Per Day:  0.01
  • Content Count:  123
  • Reputation:   7
  • Joined:  03/13/12
  • Last Seen:  

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
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  53
  • Topics Per Day:  0.01
  • Content Count:  411
  • Reputation:   259
  • Joined:  04/25/12
  • Last Seen:  

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
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  39
  • Topics Per Day:  0.01
  • Content Count:  123
  • Reputation:   7
  • Joined:  03/13/12
  • Last Seen:  

@Technoken @Zell
thank you so much. it work now. 
 

Edited by MukkiesftKies
Link to comment
Share on other sites

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.

×
×
  • Create New...