SA-MP Forums Archive
Mysql Bug - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Mysql Bug (/showthread.php?tid=612462)



Mysql Bug - muhsah007 - 18.07.2016

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.


Re: Mysql Bug - Konstantinos - 18.07.2016

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
}



Re: Mysql Bug - muhsah007 - 18.07.2016

i already have racecheck condition.