10.10.2015, 16:55
if i logout my position not my last position before logout. how to save last position before logout ?
public OnPlayerConnect(playerid){
SetTimerEx("SavePlayerPos",1000,true,"d",playerid);
return 1;}
forward SavePlayerPos(playerid);
public SavePlayerPos(playerid){
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid,x,y,z);
return 1;}
public OnPlayerDisconnect(playerid,reason){
//here you put the stuff where you store x,y and z into a file so you can load it the next time when the player connects
return 1;}
new IsPlayerLoggedIn[MAX_PLAYERS char];
public OnPlayerDisconnect(playerid, reason)
{
if(IsPlayerLoggedIn{playerid} == 1)
{
new Float:X, Float:Y, Float:Z, Float:A;
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, A);
PlayerData[playerid][Position_X] = X;
PlayerData[playerid][Position_Y] = Y;
PlayerData[playerid][Position_Z] = Z;
PlayerData[playerid][Position_A] = A; // Facing Angle
IsPlayerLoggedIn{playerid} = 0;
}
return 1;
}
@ itsCody shouldnt it be IsPlayerLoggedIn[playerid] instead of IsPlayerLoggedIn{playerid} ?
|
with char, it's {}.
Read this: https://sampforum.blast.hk/showthread.php?tid=216730 Look for char arrays. |