Restarting & Saving player files
#3

Managed to fix it with a ConnectedPlayers & IsPlayerConnected check.

pawn Code:
COMMAND:restart(playerid, params[])
{
    new File[50];
    printf("Saving %d players...", ConnectedPlayers);
    for(new i = 0; i < ConnectedPlayers; i++)
    {
        if(IsPlayerConnected(i))
        {
            format(File, sizeof(File), PFiles, pName(i));
            GetPlayerPos(i, PVar[i][pLastX], PVar[i][pLastY], PVar[i][pLastZ]);
            djSetInt        (File, "Kills",     PVar[i][pKills]);
            djSetInt        (File, "Deaths",    PVar[i][pDeaths]);
            djSetInt        (File, "Admin",     PVar[i][pAdmin]);
            djSetInt        (File, "Level",     PVar[i][pLevel]);
            djSetInt        (File, "Money",     PVar[i][pMoney]);
            djSetInt        (File, "Skin",     PVar[i][pSkin]);

            djSetFloat      (File, "LastX",     PVar[i][pLastX]);
            djSetFloat      (File, "LastY",     PVar[i][pLastY]);
            djSetFloat      (File, "LastZ",     PVar[i][pLastZ]);
            printf("%s has been saved.", pName(i));
        }
    }
    GameModeExit();
    return 1;
}
Reply


Messages In This Thread
Restarting & Saving player files - by Skylar Paul - 11.03.2011, 23:07
Re: Restarting & Saving player files - by airsoft - 11.03.2011, 23:58
Re: Restarting & Saving player files - by Skylar Paul - 12.03.2011, 00:01
Re: Restarting & Saving player files - by [L3th4l] - 12.03.2011, 00:03
Re: Restarting & Saving player files - by airsoft - 12.03.2011, 00:09

Forum Jump:


Users browsing this thread: 1 Guest(s)