25.07.2018, 20:28
It's a good practice as you need to escape necessary strings.
When a player connects:
Check if player is registered or not:
In OnDialogResponse, you check if passwords match and then you call all cache functions to retrieve data.
This is also wrong:
function returns 0 or 1 (failure or success) so just:
But this is rather basic. Mysql race is a condition that can happen even in a samp server, you do not want random players get the data of previous player and their administrator status. For an example script, look at here: https://raw.githubusercontent.com/pB...stem-cache.pwn
When a player connects:
pawn Код:
mysql_format(...);
mysql_tquery(Database, query, "OnPlayerDataLoad", "d", playerid);
pawn Код:
forward OnPlayerDataLoad(playerid);
public OnPlayerDataLoad(playerid)
{
if (cache_num_rows())
{
// player is register, show "login" dialog
}
else
{
// player is not registered, show "register" dialog
}
}
This is also wrong:
pawn Код:
playerInfo[playerid][playerAdmin] = cache_get_value_int(0, "playerAdmin", playerInfo[playerid][playerAdmin]);
pawn Код:
cache_get_value_int(0, "playerAdmin", playerInfo[playerid][playerAdmin]);