lundi 18 juillet 2016

Mysql Bug

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.

Code:

// 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
}

Let's block ads! (Why?)



Mysql Bug

Aucun commentaire:

Enregistrer un commentaire