Jump to content
  • 0

query_sql doubt, look for existing character?


Echoes

Question


  • Group:  Members
  • Topic Count:  34
  • Topics Per Day:  0.01
  • Content Count:  155
  • Reputation:   5
  • Joined:  03/30/13
  • Last Seen:  

Hello, 

 

I have a doubt about how to use the command 'query_sql' to check if the entered name of the supposed character exists, but I don't know how to even make that query :C

 

Please help.

 

I have this at the moment:

	if(query_sql("SELECT `name` FROM `char` WHERE `name` = '"+escape_sql(.@Winner_Name$)+"'",.@Acc_ID)){		mes .npc$;
		mes "Awesome, now put the ^aa0000Item ID^000000 of the item you want to be the prize for the player.";

But when I don't put any correct name on the input, it still let me continue with the script :C

 

Please help! What is the correct query_sql to ask for player name D:!

Edited by Echoes
Link to comment
Share on other sites

6 answers to this question

Recommended Posts


  • Group:  Developer
  • Topic Count:  48
  • Topics Per Day:  0.01
  • Content Count:  1443
  • Reputation:   337
  • Joined:  10/17/12
  • Last Seen:  

try using getcharid(0,"<character name>") for the character

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  34
  • Topics Per Day:  0.01
  • Content Count:  155
  • Reputation:   5
  • Joined:  03/30/13
  • Last Seen:  

if(getcharid(0,.@Winner_Name$) != 0){

I used that but the script is finding me (testing) even if I don't put my full character name, just writting the first letter of it, and I'm getting the reward D:

Does getcharid search for online characters?

 

Thanks for the reply !

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  177
  • Reputation:   21
  • Joined:  01/31/12
  • Last Seen:  

	if(query_sql("SELECT `name` FROM `char` WHERE `name` = '"+escape_sql(.@Winner_Name$)+"'",.@Acc_ID)){		mes .npc$;
		mes "Awesome, now put the ^aa0000Item ID^000000 of the item you want to be the prize for the player.";
 

Try:

query_sql("SELECT `name` FROM `char` WHERE `name` = '"+escape_sql(.@Winner_Name$)+"'",.@Acc_ID);
if(!.@Acc_ID) {
mes "No character found with that name.";
close;
}	
mes .npc$;
		mes "Awesome, now put the ^aa0000Item ID^000000 of the item you want to be the prize for the player.";
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  34
  • Topics Per Day:  0.01
  • Content Count:  155
  • Reputation:   5
  • Joined:  03/30/13
  • Last Seen:  

 

	if(query_sql("SELECT `name` FROM `char` WHERE `name` = '"+escape_sql(.@Winner_Name$)+"'",.@Acc_ID)){		mes .npc$;
		mes "Awesome, now put the ^aa0000Item ID^000000 of the item you want to be the prize for the player.";
 

Try:

query_sql("SELECT `name` FROM `char` WHERE `name` = '"+escape_sql(.@Winner_Name$)+"'",.@Acc_ID);
if(!.@Acc_ID) {
mes "No character found with that name.";
close;
}	
mes .npc$;
		mes "Awesome, now put the ^aa0000Item ID^000000 of the item you want to be the prize for the player.";

Thank you for your reply.

 

I will try it right now C:

Link to comment
Share on other sites


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

query_sql("SELECT `account_id` FROM `char` WHERE `name` = '"+escape_sql(.@Winner_Name$)+"'",.@Acc_ID);

@Luciar

converting String into Integer will alway end up "0" , which is false statement.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  177
  • Reputation:   21
  • Joined:  01/31/12
  • Last Seen:  

You're right, wasn't thinking (That's what I get for posting at 4:00 AM xD)

@Echoes make sure you update the script I provided with Emistry's corrected query_sql line

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