11.06.2018, 02:17
Hi all,
I am working on a command that allows admins to offline ban an account. In order to do that I must verify whether or not the account actually exists in the database. Currently my disfunctional code is this:
This if-statement is in the offline ban command:
And this is the code of DoesAccountExist:
This obviously does not work because mysql_tquery returns 1 or 0 depending on whether or not the query was executed succesfully, rather than what information it retrieved from the query.
What's the most efficient way to get what I am trying to get? Which is returning a 1 or 0 depending on if a Select statement returned any rows.
I am working on a command that allows admins to offline ban an account. In order to do that I must verify whether or not the account actually exists in the database. Currently my disfunctional code is this:
This if-statement is in the offline ban command:
PHP код:
if(!DoesAccountExist(player))
{
SendClientMessage(playerid, COLOR_RED, "This account does not exist.");
}
PHP код:
DoesAccountExist(name[])
{
new query[75];
format(query, sizeof(query), "SELECT * FROM player WHERE name = '%s' LIMIT 1", EscapeString(name));
return mysql_tquery(sql_connection, query, "OnDoesAccountExist");
}
forward OnDoesAccountExist();
public OnDoesAccountExist()
{
new row_count;
cache_get_row_count(row_count);
if(!row_count) return 0;
else return 1;
}
What's the most efficient way to get what I am trying to get? Which is returning a 1 or 0 depending on if a Select statement returned any rows.