samedi 23 juillet 2016

Save last pos not working upon serv restart

Let's block ads! (Why?)



Save last pos not working upon serv restart

Little Clucker

 

Join Date: Mar 2008

Posts: 7

Reputation: 0

DefaultSave last pos not working upon serv restart

Hey,

So I created a system that saves the user's last position when they disconnect, which on a daily basis works fine. However when I use /gmx , or use the server control panel, to stop and start the server, all user's spawn in Blueberry, I was wondering if anyone could tell what could cause this?

Code:

public OnPlayerDisconnect(playerid, reason)
{
    KillTimer(stimer[playerid]);
    SaveAccount(playerid);
        if(reason == 0)
        {
                SendConnectionMessage(playerid, 2);
        }
        else if(reason == 1)
        {
            SendConnectionMessage(playerid, 3);
        }
        else
        {
            SendConnectionMessage(playerid, 0);
        }
    return 1;
}

Code:

public OnGameModeExit()
{
        for(new i=0; i<MAX_PLAYERS; i++){
        SaveAccount(i);
    TextDrawDestroy(Zones[i]);}
        return 1;
}

Code:

public SaveAccount(playerid)
{
        new Float: x, Float: y, Float:z, Float: a;
        GetPlayerPos(playerid, x,y,z);
        GetPlayerFacingAngle(playerid, a);
        
        PlayerInfo[playerid][pXPos] = x;
        PlayerInfo[playerid][pYPos] = y;
        PlayerInfo[playerid][pZPos] = z;
        PlayerInfo[playerid][pAPos] = a;

        new h, m, s;
    TotalGameTime(playerid, h, m, s);
        new INI:File = INI_Open(UserPath(playerid));
        INI_SetTag(File, "data");
        INI_WriteInt(File, "Cash", GetPlayerMoney(playerid));
        INI_WriteInt(File, "Admin", PlayerInfo[playerid][pAdmin]);
        INI_WriteInt(File, "UCAdmin", PlayerInfo[playerid][pUCAdmin]);
        INI_WriteInt(File, "DriversLicense", PlayerInfo[playerid][pDriverLicense]);
        INI_WriteInt(File, "Hours", h);
        INI_WriteInt(File, "Minutes", m);
        INI_WriteInt(File, "Seconds", s);
        INI_WriteInt(File, "pInJail", PlayerInfo[playerid][pInJail]);
        INI_WriteInt(File, "pInJailTime", PlayerInfo[playerid][pInJailTime]);
        INI_WriteFloat(File, "PosX", PlayerInfo[playerid][pXPos]);
        INI_WriteFloat(File, "PosY", PlayerInfo[playerid][pYPos]);
        INI_WriteFloat(File, "PosZ", PlayerInfo[playerid][pZPos]);
        INI_WriteFloat(File, "PosA", PlayerInfo[playerid][pAPos]);
        INI_WriteInt(File, "Banned", PlayerInfo[playerid][pBanned]);
        INI_WriteString(File, "BannedBy", PlayerInfo[playerid][pBannedBy]);
        INI_WriteString(File, "Reason", PlayerInfo[playerid][pReason]);
        INI_Close(File);
        return 1;
}
public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Password",PlayerInfo[playerid][pPass]);
    INI_Int("Cash",PlayerInfo[playerid][pCash]);
    INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
        INI_Int("UCAdmin",PlayerInfo[playerid][pUCAdmin]);
        INI_Int("DriverLicense",PlayerInfo[playerid][pDriverLicense]);
        INI_Int("Hours",PlayerInfo[playerid][hours]);
        INI_Int("Minutes",PlayerInfo[playerid][minutes]);
        INI_Int("Seconds",PlayerInfo[playerid][seconds]);
        INI_Int("InJail",PlayerInfo[playerid][pInJail]);
        INI_Int("InJailTime",PlayerInfo[playerid][pInJailTime]);
        INI_Float("XPos",PlayerInfo[playerid][pXPos]);
        INI_Float("YPos",PlayerInfo[playerid][pYPos]);
        INI_Float("ZPos",PlayerInfo[playerid][pZPos]);
        INI_Float("APos",PlayerInfo[playerid][pAPos]);
        INI_Int("Banned", PlayerInfo[playerid][pBanned]);
        INI_String("BannedBy", PlayerInfo[playerid][pBannedBy],30);
        INI_String("ReasonBanned", PlayerInfo[playerid][pReason], 128);
    return 1;
}

Code:

public OnPlayerSpawn(playerid)
SetPlayerPos(playerid, PlayerInfo[playerid][pXPos], PlayerInfo[playerid][pYPos], PlayerInfo[playerid][pZPos]);
    SetPlayerFacingAngle(playerid, PlayerInfo[playerid][pAPos]);
    SetSpawnInfo(playerid, NO_TEAM, GetPlayerSkin(playerid),PlayerInfo[playerid][pXPos], PlayerInfo[playerid][pYPos], PlayerInfo[playerid][pZPos],PlayerInfo[playerid][pAPos], 0, 0, 0, 0, 0, 0);
Any help would be appreciated.

Aucun commentaire:

Enregistrer un commentaire