06.01.2012, 10:52
i'm making a server. i want to know how to script save position on playerdisconnect and load it onplayerspawn
just like other RP.
just like other RP.
public OnPlayerDisconnect(playerid, reason)
{
new pName[24], PlayerFile[50];
new Float:PX, Float:PY, Float:PZ;
GetPlayerName(playerid, pName, sizeof(pName));
format(PlayerFile, sizeof(PlayerFile), "Positions/%s.ini", pName);
GetPlayerPos(playerid, PX, PY, PZ);
PlayerInfo[playerid][PlayerX] = PX;
PlayerInfo[playerid][PlayerY] = PY;
PlayerInfo[playerid][PlayerZ] = PZ;
dini_FloatSet(PlayerFile, "PlayerX", PlayerInfo[playerid][PlayerX]);
dini_FloatSet(PlayerFile, "PlayerY", PlayerInfo[playerid][PlayerY]);
dini_FloatSet(PlayerFile, "PlayerZ", PlayerInfo[playerid][PlayerZ]);
dini_IntSet(PlayerFile, "Spawn", 2);
return 1;
}
public OnPlayerSpawn(playerid)
{
new pName[24], PlayerFile[50];
GetPlayerName(playerid, pName, sizeof(pName));
format(PlayerFile, sizeof(PlayerFile), "Positions/%s.ini", pName);
PlayerInfo[playerid][PlayerX] = dini_Float(PlayerFile, "PlayerX");
PlayerInfo[playerid][PlayerY] = dini_Float(PlayerFile, "PlayerY");
PlayerInfo[playerid][PlayerZ] = dini_Float(PlayerFile, "PlayerZ");
return SetPlayerPos(playerid, dini_Float(PlayerFile, "PlayerX"), dini_Float(PlayerFile, "PlayerY"), dini_Float(PlayerFile, "PlayerZ"));
}