Does this foreach loop save everyones data?
#1

Hi, i am having a problem of when i do my /restart cmd, it will just reset everyones data.(So far it resets skins, position(x,y,z) and facing angle).

I thought that the following loop would save everyones data before the actual gmx is called. Should it?

pawn Код:
CMD:restart(playerid)
{
    if(PlayerInfo[playerid][pAdmin] < 1) return SCM(playerid,COLOR_WHITE,"You are not authorized to do that!");
    if(PlayerInfo[playerid][pAdmin] <4) return SCM(playerid,COLOR_WHITE,"You need to be a higher level administrator!");
    if(PlayerInfo[playerid][pAdmin] >=1337 || IsPlayerAdmin(playerid))
    foreach(Player, i)
    {
        SCM(i,COLOR_RED, "Server will restart!");
        PlayerInfo[i][pGod] = 0;
        new skinid, Float: X, Float: Y, Float: Z, Float: hp, Float: armour, Float:angle;
        GetPlayerPos(i,X,Y,Z);
        GetPlayerFacingAngle(i, angle);
        GetPlayerHealth(i, hp);
        GetPlayerArmour(i, armour);
        skinid = GetPlayerSkin(i);
        if(IsPlayerConnected(i))
        {

            PlayerInfo[i][pLastX] = X;
            PlayerInfo[i][pLastY] = Y;
            PlayerInfo[i][pLastZ] = Z;
            PlayerInfo[i][pFacingAngle] = angle;
            PlayerInfo[i][pHealth] = hp;
            PlayerInfo[i][pArmour] = armour;
            PlayerInfo[i][pSkin] = skinid ;
            SaveAccountInfo(i);
        }
    }
    SetTimer(#Restart, 1 * 1000, 0);
    return 1;
}
Restart function (#Restart)
pawn Код:
forward Restart();
public Restart()
{
    SendRconCommand(#gmx);
}
pInfo enum(PlayerInfo)
pawn Код:
enum pInfo
{
    pName[24],
    pPass,
    pCash,
    pSkin,
    pLevel,
    pVipLevel,
    pInt,
    pVW,
    pAdmin,
    aName[24],
    bool:HasSetAdminName,
    OnDuty,
    pSecKey,
    pKills,
    pDeaths,
    pGod,
    Float:pFacingAngle,
    Float:pHealth,
    Float:pArmour,
    Float:pLastX,
    Float:pLastY,
    Float:pLastZ,
    pFaction,
    pFRank,
    BizID
}
new PlayerInfo[MAX_PLAYERS][pInfo];
Thanks to anyone who can help
Reply
#2

Eh.. oops lol, forgot to change it. When i did change it, it still didn't work

pawn Код:
SendRconCommand(#gmx); with SendRconCommand("gmx");
&
pawn Код:
SetTimer(#Restart, 1 * 1000, 0); with SetTimer("Restart", 1 * 1000, 0);
Am i calling Restart() and the GMX command correctly?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)