return mysql callback (GStylezzz) - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: return mysql callback (GStylezzz) (
/showthread.php?tid=480788)
return mysql callback (GStylezzz) -
TheDeath - 12.12.2013
Hello. I made a function IsUsernameTaken and I want when its called to return false or true depending on is there row with column username with the player's username
so here is my function:
Код:
stock IsUsernameTaken(playerid){
new query[256],function_result, user[MAX_PLAYER_NAME];
mysql_real_escape_string(Username(playerid), user, handle);
format(query, sizeof(query), "SELECT * FROM `accounts` WHERE `user` = '%s' LIMIT 0,1", user);
print(query);
mysql_query(query, MYSQL_IS_USERNAME_TAKEN, playerid, handle);
return function_result;
}
And here is the MySQL callback
Код:
case MYSQL_IS_USERNAME_TAKEN:
{
new query_result;
mysql_store_result(handle);
query_result = mysql_num_rows(handle);
mysql_free_result(handle);
if(query_result == 1){
print("true");
}
else {
print("false");
}
}
Can I and how to send the result back to the function and return the result ?
Re: return mysql callback (GStylezzz) -
Vince - 12.12.2013
Impossible. There's some include that allow you to do inline queries, but I don't know how that works.