How to save the Spawn (Location) ?
#2

pawn Код:
new Float:Pos[3];

public OnPlayerConnect(playerid)
{
    new name[MAX_PLAYER_NAME],file[80];GetPlayerName(playerid, name, sizeof(name));
    format(file,sizeof(file),"%s.txt",name);
    INI_ParseFile(file, "LoadPos", false, true, playerid, true, false);
    if(fexist(file)) SetPlayerPos(playerid,Pos[0],Pos[1],Pos[2]);
}

public OnPlayerDisconnect(playerid, reason)
{
    GetPlayerPos(playerid,Pos[0],Pos[1],Pos[2]);
//start saving with (Y_INI)
    new name[MAX_PLAYER_NAME], file[30+MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    format(file,sizeof(file),"%s.txt",name);
    if(fexist(file))
    {
        new INI:Acc = INI_Open(file);
        INI_WriteFloat(Acc,"PosX",Pos[0]);
        INI_WriteFloat(Acc,"PosY",Pos[1]);
        INI_WriteFloat(Acc,"PosZ",Pos[2]);
        INI_Close(Acc);
    }
    return 1;
}

forward LoadPos(playerid, name[], value[]);
public LoadPos(playerid, name[], value[])
{
    if(!strcmp(name, "PosX")) Pos[0] = value;
    if(!strcmp(name, "PosY")) Pos[1] = value;
    if(!strcmp(name, "PosZ")) Pos[2] = value;
}
Reply


Messages In This Thread
How to save the Spawn (Location) ? - by MAFIAWARS - 01.09.2013, 09:57
Re: How to save the Spawn (Location) ? - by park4bmx - 01.09.2013, 10:10
Re: How to save the Spawn (Location) ? - by MAFIAWARS - 01.09.2013, 13:30
Re: How to save the Spawn (Location) ? - by Rapgangsta - 01.09.2013, 13:49
Re: How to save the Spawn (Location) ? - by MAFIAWARS - 01.09.2013, 14:08
Re: How to save the Spawn (Location) ? - by park4bmx - 01.09.2013, 15:29
Re: How to save the Spawn (Location) ? - by Yashas - 01.09.2013, 15:35
Re: How to save the Spawn (Location) ? - by MAFIAWARS - 01.09.2013, 16:33

Forum Jump:


Users browsing this thread: 2 Guest(s)