Jump to content
  • 0
crazyarashi

Switch/Menu Using an array

Question

Hi Good Day Rathena, Im Still in the midst of studying C++ and want to ask a question about making a menu/switch select using an array.
Maybe an example will do im a bit confused reading old posts about it :))
 

  • Upvote 1
Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

you can try like ..

setarray [email protected]_item$, 
	"Menu 1",
	"Menu 2",
	"Menu 3";
[email protected]_item_size = getarraysize([email protected]_item$);
for ([email protected] = 0; [email protected] < [email protected]_item_size; [email protected]++) {
	[email protected]$ = [email protected]$ + ([email protected] > 0 ? ":" : "") + [email protected]_item$[[email protected]];
}
[email protected] = select( [email protected]$ ) - 1;
mes "You selected menu : "+ [email protected]_item$[[email protected]];

or

setarray [email protected]_item$, 
	"Menu 1",
	"Menu 2",
	"Menu 3";
[email protected]$ = implode([email protected]_item$, ":");
[email protected] = select( [email protected]$ ) - 1;
mes "You selected menu : "+ [email protected]_item$[[email protected]];

 

  • Upvote 2
Link to comment
Share on other sites

  • 0

little example

setarray A_menu[0],"menu 02","menu 03","menu 04";
set .@menu,"menu 01";//Build First Item on Menu, cant put in <for>, it will looping
for(set .@i,0; .@i < getarraysize(A_menu[0]);.@i++) {// add array item to menu
  set .@menu,.@menu+":"+A_menu[.@i];
}
select(.@menu);//menu list show out

 

  • Upvote 2
Link to comment
Share on other sites

  • 0
13 minutes ago, Emistry said:

you can try like ..

setarray [email protected]_item$, 
	"Menu 1",
	"Menu 2",
	"Menu 3";
[email protected]_item_size = getarraysize([email protected]_item$);
for ([email protected] = 0; [email protected] < [email protected]_item_size; [email protected]++) {
	[email protected]$ = [email protected]$ + ([email protected] > 0 ? ":" : "") + [email protected]_item$[[email protected]];
}
[email protected] = select( [email protected]$ ) - 1;
mes "You selected menu : "+ [email protected]_item$[[email protected]];

or

setarray [email protected]_item$, 
	"Menu 1",
	"Menu 2",
	"Menu 3";
[email protected]$ = implode([email protected]_item$, ":");
[email protected] = select( [email protected]$ ) - 1;
mes "You selected menu : "+ [email protected]_item$[[email protected]];

 

May I ask what is the use of implode. I haven't studied that yet nor i haven't seen it yet :o

Link to comment
Share on other sites

  • 0
5 minutes ago, Tokei said:

You can check out the script commands over here: https://github.com/rathena/rathena/blob/master/doc/script_commands.txt

Search for *implode.

Wokie didn't know it's in there :o

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

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.