Jump to content
  • 0

Dynamic Menu


Question

Posted

I want it to display the two names of my char in my account but it displays only one :(

Here is the code:

prontera,158,174,4 script Account Checker 88,{
mes "Please input a valid character name";
input .@playername$;
query_sql "SELECT `account_id` FROM `char` WHERE `name` = '"+escape_sql(.@playername$)+"'",.@accountid;
if (!.@accountid) {
next; 
mes "The name is invalid!";
close;
}
else
next;
query_sql "SELECT `name` FROM `char` WHERE `account_id`="+.@accountid,
.@whoischar$;
// Take Locations
setarray .@name$[0],.@whoischar$;
// Generate Menu
for (set .@a, 0; .@a < getarraysize(.@name$); set .@a, .@a + 1) {
   set .@menu_num$[getarraysize(.@menu_num$)], .@name$[.@a];
   set .@menu_index[getarraysize(.@menu_index)], .@a;
} 
// Generate the Menu String
set .@menu$, .@menu_num$[0];
for (set .@a, 1; .@a <= getarraysize(.@menu_num$); set .@a, .@a + 1) {
 set .@menu$, .@menu$ + ":" + .@menu_num$[.@a];
}
// Query Selection
set .@a, select(.@menu$) - 1;
goto L_Char;
L_Char:
mes "...";
close;
end;
}

thx!!

any help would be greatly appreciated!

12 answers to this question

Recommended Posts

Posted

I don't think that's the correct answer

*query_sql "your MySQL query", <array variable> {,<array variable>, ...};

*query_logsql "your MySQL query", <array variable> {,<array variable>, ...};

Puts up to 128 rows of values into the arrays and returns the number of rows.

Example:

set @nb, query_sql("select name,fame from `char` ORDER BY fame DESC LIMIT 5", @name$, @fame);

mes "Hall Of Fame: TOP5";

mes "1."+@name$[0]+"("+@fame[0]+")"; // Will return a person with the biggest fame value.

mes "2."+@name$[1]+"("+@fame[1]+")";

mes "3."+@name$[2]+"("+@fame[2]+")";

mes "4."+@name$[3]+"("+@fame[3]+")";

mes "5."+@name$[4]+"("+@fame[4]+")";

so, set .@nb, query_sql ".....", .@name$;

and then

do a for-loop with -> .@name$[.@i]

I'm not sure you can understand some of my advance scripting techniques

prontera,155,182,5    script    jfdksjfs    100,{
   mes "please input a player name";
   next;
   if ( input( .@input$ , 4,23 ) ) {
       mes "invalid string length";
       close;
   }
   if ( !( .@nb = query_sql( "select name from `char` where account_id = ( select account_id from `char` where name = '"+ escape_sql(.@input$) +"' )", .@name$ ) ) ) {
       mes "invalid player name";
       close;
   }
   for ( .@i = 0; .@i < .@nb; .@i++ )
       .@menu$ = .@menu$ + .@name$[.@i] +":";
   .@select = select( .@menu$ ) -1;
   mes "you have selected "+ .@name$[ .@select ];
   close;
}

  • Upvote 2
Posted (edited)

@Annie

:D I only answer why 'it displays only one'

setarray .@name$[0],.@whoischar$;

and tell him why he was wrong.

of course he can use copyarray, loop+set or your way to finish it

Edited by goddameit

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