15.10.2017, 12:10
I have this:
and I wanna do something like this:
But I am really don't know how to do that because I am only able to access the row count in the callback and not after sending the query in the first method
PHP код:
forward CheckIfAccountExists(accountName[128]);
public CheckIfAccountExists(accountName[128])
{
new query[128];
mysql_format(db, query, sizeof(query), "SELECT * FROM logindata WHERE uName = '%e';", accountName);
mysql_pquery(db, query, "OnLoginDataLoaded");
}
forward OnLoginDataLoaded();
public OnLoginDataLoaded()
{
new rows = cache_num_rows();
if(rows == 1)
return 1;
return 0;
}
PHP код:
COMMAND:checkplayerexists(playerid, params[])
{
new playerName[128]; //The player in question
if(sscanf(params, "s", playerName)) SendClientMessage(playerid, COLOR_WHITE, "Usage: /checkplayerexists <name>");
else
{
if(CheckIfAccountExists(playerName))
{
new msg[128], name[128];
format(msg, sizeof(msg), "Player %s exists in the database", playerName);
SendClientMessage(playerid, COLOR_GREEN, msg);
GetPlayerName(playerid, name, sizeof(name));
format(msg, sizeof(msg), "Admin %s has just checked if the player %s exists in the database and he does.", name, playerName);
print(msg);
}
else
{
new msg[128], name[128];
format(msg, sizeof(msg), "Player %s doesn't exist in the database", playerName);
SendClientMessage(playerid, COLOR_RED, msg);
GetPlayerName(playerid, name, sizeof(name));
format(msg, sizeof(msg), "Admin %s has just checked if the player %s exists in the database and he doesn't.", name, playerName);
print(msg);
}
}
return 1;
}