SA-MP Forums Archive
mysql is not 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 is not saving (/showthread.php?tid=538086)



mysql is not saving - JeaSon - 19.09.2014

hello all! so basically my problem is my system is not updating

pawn Код:
//Under OnGameMode
    SetTimer("SavePlayerData",180000,1);
//.....
public SavePlayerData(playerid)
{
    if(IsPlayerConnected(playerid))
    {
        for (new i = 0; i < MAX_PLAYERS; i++)
        {
            new query[600];
            mysql_format(mysql, query, sizeof(query), "UPDATE `players` SET `Admin`=%d,`Money`=%d,`Cookies`=%d,`Kills`=%d,`Deaths`=%d,`Score`=%d,`Banned`=%d,`Bannedfor`=%s,`Bannedby`=%e,`BannedDate`=%d WHERE `ID`=%d",\
            pInfo[i][Admin], pInfo[i][Money], pInfo[i][Cookies], pInfo[i][Kills], pInfo[i][Deaths],pInfo[i][Score],pInfo[i][Banned], pInfo[i][Bannedfor], pInfo[i][Bannedby], pInfo[i][BannedDate] ,pInfo[i][ID]);
            //We update the table(`players`) by getting player's admin level, vip level, money, and positions and save them in the database
            mysql_tquery(mysql, query, "", "");
        }
        new str[128];
        SendClientMessageToAll(0x009D00DB,"Your player data have been saved into(Database)");
        format(str, sizeof(str),"* Admin AutoSave (ID:007) saved all regged player stats (Total %d)",GetOnLinePlayers());
        IRC_GroupSay(groupID, IRC_CHANNEL, str);
    }
    return 1;
}



Re: mysql is not saving - Marricio - 19.09.2014

pawn Код:
//Under OnGameMode
    SetTimer("SavePlayerData",180000,1);
//.....
public SavePlayerData()
{
    for (new i = 0; i < MAX_PLAYERS; i++)
    {
        if( IsPlayerConnected( i ) )
        {
            new query[600];
            mysql_format(mysql, query, sizeof(query), "UPDATE `players` SET `Admin`=%d,`Money`=%d,`Cookies`=%d,`Kills`=%d,`Deaths`=%d,`Score`=%d,`Banned`=%d,`Bannedfor`=%s,`Bannedby`=%e,`BannedDate`=%d WHERE `ID`=%d",\
            pInfo[i][Admin], pInfo[i][Money], pInfo[i][Cookies], pInfo[i][Kills], pInfo[i][Deaths],pInfo[i][Score],pInfo[i][Banned], pInfo[i][Bannedfor], pInfo[i][Bannedby], pInfo[i][BannedDate] ,pInfo[i][ID]);
            //We update the table(`players`) by getting player's admin level, vip level, money, and positions and save them in the database
            mysql_tquery(mysql, query, "", "");
        }
        new str[128];
        SendClientMessageToAll(0x009D00DB,"Your player data have been saved into(Database)");
        format(str, sizeof(str),"* Admin AutoSave (ID:007) saved all regged player stats (Total                 %d)",GetOnLinePlayers());
        IRC_GroupSay(groupID, IRC_CHANNEL, str);
    }
    return 1;
}
Also, I highly recommend you to use foreach if you're making it a global timer each 3 minutes.