SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 09/07/2015, 06:18 AM   #1
VenomMancer
Gangsta
 
VenomMancer's Avatar
 
Join Date: May 2013
Location: Indonesia (Manado)
Posts: 637
Reputation: 31
Question [ASK] Autosave player stats ?

What is best one/work perfectly ?

I put
pawn Code:
// Under player loged in
pInfo[playerid][SaveTimer] = SetTimerEx("SavePlayerX",5000*60,true,"d",playerid);

function SavePlayerX(playerid)
{
        if(GPVI(playerid,"Spawned") == 1)
        {
            new query[550];
            mysql_format(mysql, query, sizeof(query), "UPDATE `players` SET `Money`='%d', `TotalScore`='%d', `PT`='%d' WHERE `ID`='%d'",GetPlayerMoneyX(playerid),GetPlayerScore(playerid), pInfo[playerid][PTScore], pInfo[playerid][ID]);
            mysql_pquery(mysql, query, "", "");
            //printf("%s",query);
        }
        return 1;
}

Or with globaltimer ?
Like this:

pawn Code:
public OnGameModeInit()
{
    SetTimer("ServerBackup",5000*60,true);
    return 1;
}

public ServerBackup()
{
    printf("**DEBUG : Server backup!");
    foreach(Player,i)
    {
        if(pInfo[i][Login] == 1)
        {
            SavePlayer(i);
        }
    }

    /*for(new s = 1; s < groupscount; s++)
    {
        SaveG(s);
    }*/


    //SCMTA(ColInfo,"**INFO : Semua data base di server telah di save (ServerBackup) !");
    return 1;
}

#Sorryformybadenglish
VenomMancer is offline   Reply With Quote
Old 09/07/2015, 07:26 AM   #2
rockhopper
Gangsta
 
rockhopper's Avatar
 
Join Date: Apr 2014
Location: In A Black Hole Under You !
Posts: 603
Reputation: 33
Default Re: [ASK] Autosave player stats ?

I think the timer will work , I do not know much about MYSQL but what I did on my previous scripts which had Y_INI was I made a Function called AutoSave(playerid) in which I placed all my saving vars and placed it in OnPlayerUpdate . I do not know if you can do that with MYSQL as it puts data into a table etc , but with INI it works and is very useful as it saves every time .
__________________
I love it <3 <3 <3
rockhopper is offline   Reply With Quote
Old 10/07/2015, 12:59 PM   #3
VenomMancer
Gangsta
 
VenomMancer's Avatar
 
Join Date: May 2013
Location: Indonesia (Manado)
Posts: 637
Reputation: 31
Default Re: [ASK] Autosave player stats ?

This my save function

pawn Code:
function SavePlayerX(playerid)
{
        if(GPVI(playerid,"Spawned") == 1)
        {
            new query[2010];
            mysql_format(mysql, query, sizeof(query), "UPDATE `players` SET \
            `Money`=%d,\
            `Cash`=%d,\
            `TotalScore`=%d,\
            `DuelScore`=%d,\
            `MostScore`=%d,\
            `Kills`=%d,\
            `Rob`=%d,\
            `Race`=%d,\
            `Mb`=%d,\
            `Lms`=%d,\
            `PT`=%d,\
            `Deaths`=%d,\
            `Fish`=%d,\
            `Groupid`=%d,\
            `GroupLevel`=%d WHERE `ID`=%d"
,
            GetPlayerMoneyX(playerid),
            pInfo[playerid][VgCash],
            GetPlayerScore(playerid),
            pInfo[playerid][DuelScore],
            pInfo[playerid][MostScore],
            pInfo[playerid][Kills],
            pInfo[playerid][RobScore],
            pInfo[playerid][RaceScore],
            pInfo[playerid][MbScore],
            pInfo[playerid][LmsScore],
            pInfo[playerid][PTScore],
            pInfo[playerid][Deaths],
            pInfo[playerid][pFish],
            pInfo[playerid][gID],
            pInfo[playerid][gLevel],
            pInfo[playerid][ID]);
            mysql_pquery(mysql, query, "", "");
        }
        return 1;
}

I make every 5 minutes player's stats will save
VenomMancer is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[FilterScript] Player Labels (/pl - good for spectating and 3D player stats!) Gammix Filterscripts 31 12/09/2018 11:53 PM
[Tool/Web/Other] [PHP/MySQL] Powerup Stats - Player stats signature generator kelvin22 Tools and Files 43 20/06/2013 11:15 PM
Autosave stats Face9000 Help Archive 4 31/12/2010 06:20 PM
Autosave stats time 06leachr Help Archive 2 16/12/2010 09:59 PM
Autosave bogdan.trial Help Archive 7 10/06/2010 01:57 PM


All times are GMT. The time now is 08:08 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.