MYSQL Saving
#1

Ok, hi, so I, or maybe i should say WE, have a stock here to save a player, and yes, we have remembered to put SavePlayer() in OnPlayerDisconnect, but it isn't saving, no matter what I try, here's the stock;

pawn Код:
stock SavePlayer(playerid)
{
    if(GetPVarInt(playerid, "Logged") == 1) //Yes, this is set to 1 when the player logs in.
    {
        AvoidOOSync();
        new query[1050];
        new alevel,leet,money,score,planesteals,kills,deaths,banned,muted;
        alevel = GetPVarInt(playerid, "Admin");
        leet = GetPVarInt(playerid, "Elite");
        money = GetPlayerMoney(playerid);
        score = GetPlayerScore(playerid);
        planesteals = GetPVarInt(playerid, "Planes");
        muted = GetPVarInt(playerid, "Muted");
        kills = GetPVarInt(playerid, "Kills");
        deaths = GetPVarInt(playerid, "Deaths");
        mysql_format(MySqlConnection,query,"UPDATE users SET ALevel='%i',Leet='%i',Money='%i',Score='%i',PlaneSteals='%i',Kills='%i',Deaths'%i',Banned='%i',Muted='%i' WHERE Playername='%e'", alevel,leet,money,score,planesteals,kills,deaths,banned,muted, GetName(playerid));
        mysql_query(query);
        printf("Saved Details: %s",GetName(playerid));
    }
    return 1;
}
Thanks for any help in advance,
-Aston and Nodroz.
Reply
#2

do you get any errors in the logs?
Reply
#3

We don't seem to have a mysql log in our server files. There are no errors in the script, it just doesnt save anything
Reply
#4

pawn Код:
public OnGameModeInit()
{
    mysql_debug(1); //enable debug
    //...
    mysql_debug(0); //disable debug
    return 1;
}
That's the way to enable the debug and see the errors.
Reply
#5

1. You don't need to escape player names. They can't exist anything you don't want to have in a query.
2. Don't put '' around integers, it's only needed for strings.
3. You don't need 1050 ceels big string for this.
4. Enable debug and post log here.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)