Jump to content
  • 0

position title


TiMz

Question


  • Group:  Members
  • Topic Count:  51
  • Topics Per Day:  0.01
  • Content Count:  192
  • Reputation:   9
  • Joined:  05/08/13
  • Last Seen:  

Using SQL entries I instead of numbers appearing in-game I would like the value 0 appear as apple, 1 appear as grapes, 2 appear as watermelon etc etc.

mes "[ " +.@position[.@a]+" ]");     <<< This will appear as a number in-game from the guild position table. How to attach a word to the corresponding number.
mes " ";
close;
}
Edited by Isaiah
Link to comment
Share on other sites

8 answers to this question

Recommended Posts


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


.@guild_id = 100;

setarray .@name_list$,

"Apple",

"Orange",

"Watermelon",

"Banana",

"Strawberry";

.@name_list_size = getarraysize( .@name_list$ );

query_sql( "SELECT `name`,`position` FROM `guild_member` WHERE `guild_id` = "+.@guild_id+" ORDER BY `position` LIMIT "+.@name_list_size,.@name$,.@position );

.@name_size = getarraysize( .@name$ );

mes "["+getguildname( .@guild_id )+"]";

for( .@i = 0; .@i < .@name_size; .@i++ )

mes .@name$[.@i]+" | "+.@name_list$[ .@position[.@i] ];

close;

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


  • Group:  Members
  • Topic Count:  38
  • Topics Per Day:  0.01
  • Content Count:  949
  • Reputation:   174
  • Joined:  06/12/12
  • Last Seen:  

Why not use an if-else/switch statement instead of attaching them as a permanent variable?

 

if(.@position[.@] == 0) mes "Apple";
else if...

 

But anyways, to answer your question though, use $ as the prefix. You can find the variables stored in mapreg table

 

set $fruit$[0],"Apple";

 

Kindly correct if i have stated something wrong or misunderstood your question..

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  51
  • Topics Per Day:  0.01
  • Content Count:  192
  • Reputation:   9
  • Joined:  05/08/13
  • Last Seen:  

query_sql( "SELECT `name`,`guild_id`,`position` FROM `guild_member` where guild_id = 100 LIMIT 5",.@Name$,.@gid,.@position );
mes "[ Fruit Clan ]";
mes " ";
for( set .@a,0; .@a < getarraysize(.@name$); set .@a,.@a + 1)
if(.@position[.@] == 0) mes "Apple";
else if(.@position[.@] == 1) mes "Orange";
mes " "+.@name$[.@a]+ " | " +.@position[.@a]+" | ";
mes " ";
close;
}

@sandbox It doesn't appear to work.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  38
  • Topics Per Day:  0.01
  • Content Count:  949
  • Reputation:   174
  • Joined:  06/12/12
  • Last Seen:  

sorry for the typo

 

change 

.@position[.@]

 

to

.@position[.@a]
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  51
  • Topics Per Day:  0.01
  • Content Count:  192
  • Reputation:   9
  • Joined:  05/08/13
  • Last Seen:  

@sandbox

 

It still doesn't show the member's position as "apple"

 

It now looks something like

 

[Fruit Clan]

 

apple

Name | 0 |   // 0 meaning guildmaster.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  51
  • Topics Per Day:  0.01
  • Content Count:  192
  • Reputation:   9
  • Joined:  05/08/13
  • Last Seen:  

@Emistry

 

Thanks for the quick response. I didn't get any errors on the console although the npc is only showing the guild name of ID 100. And nothing else.

Edited by Isaiah
Link to comment
Share on other sites


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

@Emistry

 

Thanks for the quick response. I didn't get any errors on the console although the npc is only showing the guild name of ID 100. And nothing else.

.@name_list_size = getarraysize( .@name_list$ );

refer above script...updated

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  51
  • Topics Per Day:  0.01
  • Content Count:  192
  • Reputation:   9
  • Joined:  05/08/13
  • Last Seen:  

@Emistry Worked like a charm! Great support thank you!

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