12.12.2013, 18:49
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:
And here is the MySQL callback
Can I and how to send the result back to the function and return the result ?
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; }
Код:
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"); } }