01.09.2013, 10:10
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;
}