[Help]Last Position - Spawn
#4

This is what i have (not tested but absolutly no reason why it should not work). Obviously put ur own conditions in OnPlayerSpawn like if player is regged ect.

Using djson FOUND HERE.

OnGameModeInit/OnFilterScriptInit
pawn Код:
djson_GameModeInit();
OnGameModeExit/OnFilterScriptExit
pawn Код:
djson_GameModeExit();
Then OnPlayerDisconnect
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    djAutocommit(false);//correct
    new Float:x,Float:y,Float:z,fstr[35];
    GetPlayerPos(playerid,x,y,z);//put co-ords in variables x,y,z.
    format(fstr,35,"%.json",playername(playerid));//file string (players name)
    djSetFloat(fstr,"pos/x",x);//save co-ords
    djSetFloat(fstr,"pos/y",y);
    djSetFloat(fstr,"pos/z",z);
    djCommit(fstr);
    djAutocommit(true);//This is the edit make sure this is in your code(here) and not djAutocommit(false)
    return 1;
}
then OnPlayerSpawn
pawn Код:
public OnPlayerSpawn(playerid)
{
    new fstr[35];
    format(fstr,35,"%.json",playername(playerid));
    SetPlayerPos(playerid,djFloat(fstr,"pos/x"),djFloat(fstr,"pos/y"),djFloat(fstr,"pos/z"));
    return 1;
}
Then at bottom a function to return players name
pawn Код:
stock playername(playerid)
{
    new pname[MAX_PLAYER_NAME];
    GetPlayerName(playerid,pname,sizeof(pname));
    return pname;
}
Hope it works. dont see why not if not let me know what happened u may also need to save interior and vw.

Edit: i changed the later djAutocommit() to djAutocommit(true); silly mistake by me. Make sure you change the original code i posted to the edited one above (it is slghtly different).
Reply


Messages In This Thread
[Help]Last Position - Spawn - by igal4576 - 12.08.2010, 23:56
Re: [Help]Last Position - Spawn - by iggy1 - 13.08.2010, 00:06
Re: [Help]Last Position - Spawn - by igal4576 - 13.08.2010, 00:16
Re: [Help]Last Position - Spawn - by iggy1 - 13.08.2010, 00:27
Re: [Help]Last Position - Spawn - by igal4576 - 13.08.2010, 00:30
Re: [Help]Last Position - Spawn - by iggy1 - 13.08.2010, 01:07
Re: [Help]Last Position - Spawn - by igal4576 - 13.08.2010, 01:12
Re: [Help]Last Position - Spawn - by iggy1 - 13.08.2010, 01:16
Re: [Help]Last Position - Spawn - by igal4576 - 13.08.2010, 01:45
Re: [Help]Last Position - Spawn - by iggy1 - 13.08.2010, 10:34

Forum Jump:


Users browsing this thread: 5 Guest(s)