SA-MP Forums Archive
[Help!] Saving stats - 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: [Help!] Saving stats (/showthread.php?tid=392397)



[Help!] Saving stats - Sarzoc - 14.11.2012

Well, I've scripted a levelup system (Which works) and just noticed that there's an issue..Each time I'd spend money, /levelup or whatever, it'll reset when I login. Houses save, admin level saves, but not the level and experience.


Re: [Help!] Saving stats - Black Wolf - 14.11.2012

Have you tried to save the data after /levelup and disconnect ?


Respuesta: [Help!] Saving stats - Sarzoc - 14.11.2012

How do I do that ? (I am very very very new to scripting.)


Re: [Help!] Saving stats - zT KiNgKoNg - 14.11.2012

Like this with a timer


Example ? do not use this unless you have the same saving system or formating
pawn Код:
function SaveAccountStats(playerid)
{
    if(Logged[playerid] == 1)
    {
    new
        INI:File = INI_Open(UserPath(playerid))
    ;
    INI_SetTag(File,"data");
   
    PlayerInfo[playerid][pSkin] = GetPlayerSkin(playerid);
    PlayerInfo[playerid][pCash] = GetPlayerCash(playerid);
    new
        Float:x,
        Float:y,
        Float:z
    ;
    GetPlayerPos(playerid,x,y,z);
    PlayerInfo[playerid][pPos_x] = x;
    PlayerInfo[playerid][pPos_y] = y;
    PlayerInfo[playerid][pPos_z] = z;
   
    INI_WriteInt(File,"Cash",PlayerInfo[playerid][pCash]);
    INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
    INI_WriteInt(File,"Sex",PlayerInfo[playerid][pSex]);
    INI_WriteInt(File,"Age",PlayerInfo[playerid][pAge]);
    INI_WriteFloat(File,"Pos_x",PlayerInfo[playerid][pPos_x]);
    INI_WriteFloat(File,"Pos_y",PlayerInfo[playerid][pPos_y]);
    INI_WriteFloat(File,"Pos_z",PlayerInfo[playerid][pPos_z]);
    INI_WriteInt(File,"Skin",PlayerInfo[playerid][pSkin]);
    INI_WriteInt(File,"Team",PlayerInfo[playerid][pTeam]);
    INI_WriteInt(File,"Accent",PlayerInfo[playerid][pAccent]);
    INI_WriteInt(File,"Cookies",PlayerInfo[playerid][pCookies]);
    INI_WriteInt(File,"Gold",PlayerInfo[playerid][pGold]);
    INI_WriteInt(File,"Level",PlayerInfo[playerid][Level]);
    INI_WriteInt(File,"Exp",PlayerInfo[playerid][Exp]);
   
    INI_Close(File);
    }
    return 1;
}