Mysql Bug
#1

I have my own RP server,
everything is okay but sometimes when someone connect or disconnect at the same time it bugs and give the player1 vehicles to player2.
Reply
#2

It is called race condition. The query finishes when the player has already disconnected and another player has connected. You should always have a check to important data and the only solution is to kick the player.

pawn Код:
// global:
new gPlayer_RaceCondition[MAX_PLAYERS];

// OnPlayerConnect:
gPlayer_RaceCondition[playerid]++;
...
mysql_tquery(mysql_handle_here, "...", "callback_here", "ii", playerid, gPlayer_RaceCondition[playerid]);

// OnPlayerDisconnect
gPlayer_RaceCondition[playerid]++;

// in the callbacks specified in mysql_tquery and race condition was passed as argument:
forward callback_here(playerid, race_check);
public callback_here(playerid, race_check)
{
    if (race_check != gPlayer_RaceCondition[playerid])
    {
        // kick the player
    }

    // code for retrieving the data
}
Reply
#3

i already have racecheck condition.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)