SA-MP Forums Archive
MYSQL Saving - 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 Saving (/showthread.php?tid=303278)



MYSQL Saving - AstonDA-G - 12.12.2011

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.


AW: MYSQL Saving - C0dy09 - 12.12.2011

do you get any errors in the logs?


Re: MYSQL Saving - AstonDA-G - 12.12.2011

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


Re: MYSQL Saving - TheArcher - 12.12.2011

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.


Re: MYSQL Saving - Sergei - 12.12.2011

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.