PHP код:
//---[Dialog ID's]
#define Respawn 14//--[Dialog ID]
//--[Config]
#define PATH "/Users/%s.ini"
//--[Forward]
forward LoadUserAccounts(playerid, name[], value[]);
forward SaveUserAccounts(playerid);
//---[Player]
enum pInfo
{
//--[Pos]
Float:X,
Float:Y,
Float:Z,
Float:Angle,
Interior,
VirtualWorld,
};
new PlayerInfo[MAX_PLAYERS][pInfo];
stock UserPath(playerid)
{
new string[128],playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,sizeof(playername));
format(string,sizeof(string),PATH,playername);
return string;
}
public LoadUserAccounts(playerid,name[],value[])
{
INI_Float("X",PlayerInfo[playerid][X]);
INI_Float("Y",PlayerInfo[playerid][Y]);
INI_Float("Z",PlayerInfo[playerid][Z]);
INI_Float("Angle",PlayerInfo[playerid][Angle]);
INI_Int("Interior",PlayerInfo[playerid][Interior]);
INI_Int("VirtualWorld",PlayerInfo[playerid][VirtualWorld]);
return 1;
}
public SaveUserAccounts(playerid)
{
new Float:ppX,Float:ppY,Float:ppZ,Float:ppA;
new ppInt = GetPlayerInterior(playerid);
new ppVW = GetPlayerVirtualWorld(playerid);
GetPlayerPos(playerid,ppX,ppY,ppZ);
GetPlayerFacingAngle(playerid,ppA);
PlayerInfo[playerid][X] = ppX;
PlayerInfo[playerid][Y] = ppY;
PlayerInfo[playerid][Z] = ppZ;
PlayerInfo[playerid][Angle] = ppA;
PlayerInfo[playerid][Interior] = ppInt;
PlayerInfo[playerid][VirtualWorld] = ppVW;
if(fexist(UserPath(playerid)))
{
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"Player-Data");
INI_WriteFloat(File,"X",PlayerInfo[playerid][X]);
INI_WriteFloat(File,"Y",PlayerInfo[playerid][Y]);
INI_WriteFloat(File,"Z",PlayerInfo[playerid][Z]);
INI_WriteFloat(File,"Angle",PlayerInfo[playerid][Angle]);
INI_WriteInt(File,"Interior",PlayerInfo[playerid][Interior]);
INI_WriteInt(File,"VirtualWorld",PlayerInfo[playerid][VirtualWorld]);
INI_Close(File);
}
return 1;
}
public OnGameModeInit()
{
SetTimer("SaveUserAccounts", 12000, true);
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == Respawn)
{
if(response)
{
if(fexist(UserPath(playerid)))
{
INI_ParseFile(UserPath(playerid),"LoadUserAccounts", .bExtra = true, .extra = playerid);
SetPlayerPos(playerid,PlayerInfo[playerid][X],PlayerInfo[playerid][Y],PlayerInfo[playerid][Z]);
SetPlayerFacingAngle(playerid,PlayerInfo[playerid][Angle]);
SetPlayerInterior(playerid,PlayerInfo[playerid][Interior]);
SetPlayerVirtualWorld(playerid,PlayerInfo[playerid][VirtualWorld]);
}
else
{
}
}
else
{
}
return 1;
}
return 0;
}
public OnPlayerSpawn(playerid)
{
if(fexist(UserPath(playerid)))
{
ShowPlayerDialog(playerid, Respawn, DIALOG_STYLE_MSGBOX, "Respawn Dialog", "Are You Sure You Want To Respawn Where You Disconnect Or Saved From?", "Yes", "No");
}
return 1;
}