save stats help
#1

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
Reply
#2

Use foreach include

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

hmm what about server restart?
Reply
#4

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;
}
Reply
#5

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

Yes you should.

Compiling gives you a warning without it.
Reply
#7

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


Forum Jump:


Users browsing this thread: 2 Guest(s)