LP and SP
#9

Hmm take a look at this.
Код:
enum pInfo
{
    Float:pPosX,
    Float:pPosY,
    Float:pPosZ,
    Float:pPosA,
    pInterior,
    pVw
}
new PlayerInfo[MAX_PLAYERS][pInfo];
Код:
forward loadaccount_user(playerid, name[], value[]); 
public loadaccount_user(playerid, name[], value[])
{
	INI_Float("PositionX", PlayerInfo[playerid][pPosX]);
    INI_Float("PositionY", PlayerInfo[playerid][pPosY]);
    INI_Float("PositionZ", PlayerInfo[playerid][pPosZ]);
    INI_Float("Angle", PlayerInfo[playerid][pPosA]);
    INI_Int("Interior", PlayerInfo[playerid][pInterior]);
    INI_Int("VirtualWorld", PlayerInfo[playerid][pVw]);
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
	GetPlayerPos(playerid, PlayerInfo[playerid][pPosX],  PlayerInfo[playerid][pPosY], PlayerInfo[playerid][pPosZ]);
    GetPlayerFacingAngle(playerid, PlayerInfo[playerid][pPosA]);
	if(fexist(Path(playerid)))
	{
	    new INI:file = INI_Open(Path(playerid)); 
	    INI_SetTag(file,"Player's Data");
   	    INI_WriteFloat(file,"PositionX", PlayerInfo[playerid][pPosX]);
	    INI_WriteFloat(file,"PositionY", PlayerInfo[playerid][pPosY]);
	    INI_WriteFloat(file,"PositionZ", PlayerInfo[playerid][pPosZ]);
	    INI_WriteFloat(file,"Angle", PlayerInfo[playerid][pPosA]);
	    INI_WriteInt(file,"Interior", GetPlayerInterior(playerid));
	    INI_WriteInt(file,"VirtualWorld", GetPlayerVirtualWorld(playerid));
            return 1;
}

public OnPlayerSpawn(playerid)
{
	if (PlayerInfo[playerid][pPosX] != 0 && PlayerInfo[playerid][pPosY] != 0 && PlayerInfo[playerid][pPosZ] != 0)
    {
        SetPlayerPos(playerid, PlayerInfo[playerid][pPosX], PlayerInfo[playerid][pPosY], PlayerInfo[playerid][pPosZ]);
        SetPlayerFacingAngle(playerid, PlayerInfo[playerid][pPosA]);
        SetPlayerInterior(playerid, PlayerInfo[playerid][pInterior]);
        SetPlayerVirtualWorld(playerid, PlayerInfo[playerid][pVw]);
		return 1;
    }
    else
    {
        //Set normal pos here if they dont have acc
	}
    return 1;
}
Just make sure you make it that it will write the play pos on register.
Код:
INI_WriteFloat(file,"PositionX", 0);
		    INI_WriteFloat(file,"PositionY", 0);
		    INI_WriteFloat(file,"PositionZ", 0);
		    INI_WriteFloat(file,"Angle", 0);
		    INI_WriteInt(file,"Interior", 0);
		    INI_WriteInt(file,"VirtualWorld", 0);
Command example
Код:
CMD:gotpos(playerid, params[])
{
    if (PlayerInfo[playerid][pPosX] != 0 && PlayerInfo[playerid][pPosY] != 0 && PlayerInfo[playerid][pPosZ] != 0)
    {
        SetPlayerPos(playerid, PlayerInfo[playerid][pPosX], PlayerInfo[playerid][pPosY], PlayerInfo[playerid][pPosZ]);
        SetPlayerFacingAngle(playerid, PlayerInfo[playerid][pPosA]);
        SetPlayerInterior(playerid, PlayerInfo[playerid][pInterior]);
        SetPlayerVirtualWorld(playerid, PlayerInfo[playerid][pVw]);
    }
}

CMD:savepos(playerid, params[])
{
    	new INI:file = INI_Open(Path(playerid));
	    INI_SetTag(file,"Player's Data");
   		INI_WriteFloat(file,"PositionX", PlayerInfo[playerid][pPosX]);
	    INI_WriteFloat(file,"PositionY", PlayerInfo[playerid][pPosY]);
	    INI_WriteFloat(file,"PositionZ", PlayerInfo[playerid][pPosZ]);
	    INI_WriteFloat(file,"Angle", PlayerInfo[playerid][pPosA]);
	    INI_WriteInt(file,"Interior", GetPlayerInterior(playerid));
	    INI_WriteInt(file,"VirtualWorld", GetPlayerVirtualWorld(playerid));
	    return 1;
}
Reply


Messages In This Thread
LP and SP - by CBCandyBoy - 30.03.2013, 14:02
Re: LP and SP - by Lady-Happy - 30.03.2013, 14:04
Re: LP and SP - by CBCandyBoy - 30.03.2013, 14:06
Re: LP and SP - by RajatPawar - 30.03.2013, 14:10
Re: LP and SP - by CBCandyBoy - 30.03.2013, 14:14
Re: LP and SP - by Jochemd - 30.03.2013, 14:16
Re: LP and SP - by CBCandyBoy - 30.03.2013, 14:20
Re: LP and SP - by CBCandyBoy - 30.03.2013, 14:26
Re: LP and SP - by Pawnie - 30.03.2013, 15:01

Forum Jump:


Users browsing this thread: 1 Guest(s)