Player positions not loading properly
#6

It's a good practice as you need to escape necessary strings.

When a player connects:
pawn Код:
mysql_format(...);
mysql_tquery(Database, query, "OnPlayerDataLoad", "d", playerid);
Check if player is registered or not:
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
    }
}
In OnDialogResponse, you check if passwords match and then you call all cache functions to retrieve data.

This is also wrong:
pawn Код:
playerInfo[playerid][playerAdmin] = cache_get_value_int(0, "playerAdmin", playerInfo[playerid][playerAdmin]);
function returns 0 or 1 (failure or success) so just:
pawn Код:
cache_get_value_int(0, "playerAdmin", playerInfo[playerid][playerAdmin]);
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
Reply


Messages In This Thread
Player positions not loading properly - by OMonger - 25.07.2018, 18:04
Re: Player positions not loading properly - by Usmanmemon - 25.07.2018, 18:23
Re: Player positions not loading properly - by denNorske - 25.07.2018, 19:51
Re: Player positions not loading properly - by Calisthenics - 25.07.2018, 19:54
Re: Player positions not loading properly - by OMonger - 25.07.2018, 20:02
Re: Player positions not loading properly - by Calisthenics - 25.07.2018, 20:28
Re: Player positions not loading properly - by GTLS - 26.07.2018, 14:47

Forum Jump:


Users browsing this thread: 1 Guest(s)