Jump to content
  • 0

query_sql doubt, look for existing character?


Question

Posted (edited)

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

6 answers to this question

Recommended Posts

Posted
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 !

Posted
	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.";
Posted

 

	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:

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

Posted

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

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