Jump to content
  • 0

Dynamic Menu


gunvald

Question


  • Group:  Members
  • Topic Count:  13
  • Topics Per Day:  0.00
  • Content Count:  50
  • Reputation:   4
  • Joined:  03/31/12
  • Last Seen:  

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!

Link to comment
Share on other sites

12 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  60
  • Topics Per Day:  0.01
  • Content Count:  562
  • Reputation:   219
  • Joined:  11/22/11
  • Last Seen:  

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

problem in here

Edited by goddameit
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  13
  • Topics Per Day:  0.00
  • Content Count:  50
  • Reputation:   4
  • Joined:  03/31/12
  • Last Seen:  

o.o?

Edited by gunvald
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  60
  • Topics Per Day:  0.01
  • Content Count:  562
  • Reputation:   219
  • Joined:  11/22/11
  • Last Seen:  

o.o?

hm? you only record one name into one variable, that's why it only show one name.

Edited by goddameit
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  13
  • Topics Per Day:  0.00
  • Content Count:  50
  • Reputation:   4
  • Joined:  03/31/12
  • Last Seen:  

what should be the correct code?? :D

this is my first time to use array...

sorry :(

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  60
  • Topics Per Day:  0.01
  • Content Count:  562
  • Reputation:   219
  • Joined:  11/22/11
  • Last Seen:  

what should be the correct code?? :D

this is my first time to use array...

sorry :(

Array#Array_Variables

setarray

copyarray

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

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


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10015
  • Reputation:   2350
  • Joined:  10/28/11
  • Last Seen:  

you can try this...

http://pastebin.com/raw.php?i=QSUdk47e

LOL...Annie is faster than me..... >.<

Edited by Emistry
  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

@Emistry, your

input .@Name$,4,23;

that day you laugh at me, today let me laugh at you /heh

Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10015
  • Reputation:   2350
  • Joined:  10/28/11
  • Last Seen:  

@Emistry, your

input .@Name$,4,23;

that day you laugh at me, today let me laugh at you /heh

LOL.

* Damn...how come i can forget what i have asked last time...LOL

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  60
  • Topics Per Day:  0.01
  • Content Count:  562
  • Reputation:   219
  • Joined:  11/22/11
  • Last Seen:  

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


  • Group:  Members
  • Topic Count:  13
  • Topics Per Day:  0.00
  • Content Count:  50
  • Reputation:   4
  • Joined:  03/31/12
  • Last Seen:  

thanks everyone!! :)

ill try to understand your script AnnieRuRu :P

thx again!

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.00
  • Content Count:  626
  • Reputation:   188
  • Joined:  11/19/11
  • Last Seen:  

Hmm you could use my InGame CP, which allows GM's to view other accounts plus their chars :)

See Mu Script Collection in my Sig

Regards,

Chris

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