SA-MP Forums Archive
save stats help - 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: save stats help (/showthread.php?tid=381814)



save stats help - trapstar2020 - 30.09.2012

i need help saving stats under gm int when the gamemode closes and when the gamemode restart and saving player pos
pawn Код:
public SaveStats(playerid)
{
    PlayerInfo[playerid][pInt] = GetPlayerInterior(playerid);
    PlayerInfo[playerid][pVW] = GetPlayerVirtualWorld(playerid);
    GetPlayerFacingAngle(playerid,PlayerInfo[playerid][pA]);
    GetPlayerPos(playerid, PlayerInfo[playerid][pX], PlayerInfo[playerid][pY], PlayerInfo[playerid][pZ]);
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    INI_WriteFloat(File, "X", PlayerInfo[playerid][pX]);
    INI_WriteFloat(File, "Y", PlayerInfo[playerid][pY]);
    INI_WriteFloat(File, "Z", PlayerInfo[playerid][pZ]);
    INI_WriteFloat(File, "A", PlayerInfo[playerid][pA]);
    INI_WriteInt(File, "Int", PlayerInfo[playerid][pInt]);
    INI_WriteInt(File, "VW", PlayerInfo[playerid][pVW]);
    INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
    INI_Close(File);
}
i deleted most of it for person reasons can anyone help save on gmx and when gamemode closes


Re: save stats help - Kitten - 30.09.2012

Use foreach include

pawn Код:
public OnGameModeExit()
{
     foreach(Player,i) {
          SaveStats(i);
     }
     return 1;
}



Re: save stats help - trapstar2020 - 30.09.2012

hmm what about server restart?


Re: save stats help - ReneG - 30.09.2012

Make your own GMX command instead of /rcon gmx.
pawn Код:
CMD:gmx(playerid, params[])
{
    if(!IsPlayerAdmin(playerid)) return 0;

    foreach(Player, i)
    {
        SaveStats(i);
        SendClientMessage(playerid, -1, "SERVER: The server is being restarted.");
        Kick(i);
    }

    SendRconCommand("gmx");
    return 1;
}



Re: save stats help - trapstar2020 - 01.10.2012

Should I put a return value under the public for save stats ?


Re: save stats help - ReneG - 01.10.2012

Yes you should.

Compiling gives you a warning without it.


Re: save stats help - trapstar2020 - 01.10.2012

0 errors i was just wondering n it works but ill still put
pawn Код:
return 1;