SA-MP Forums Archive
dini help... - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: dini help... (/showthread.php?tid=236005)



dini help... - tanush - 06.03.2011

im getting problems with dini cause when player disconnect and come back, they spawn at some on top ls, please help how to save player pos when they connect!!!!!!!


Re: dini help... - tanush - 06.03.2011

someone help me already please


Re: dini help... - xir - 06.03.2011

You mean like, when a player disconnects it saves their positon(x,y,z) ? And next time they connect it loads their old position and put them where they were?


Re: dini help... - tanush - 06.03.2011

yeeeeppp


Re: dini help... - Stigg - 06.03.2011

Found this with a little SEARCH:

In you Playerinfo enum:

pawn Код:
Float:pPosX,
Float:pPosY,
Float:pPosZ,
Under your Login Function:

pawn Код:
pInfo[playerid][pPosX] = dini_Float(File, "PosX");
pInfo[playerid][pPosY] = dini_Float(File, "PosY");
pInfo[playerid][pPosZ] = dini_Float(File, "PosZ");

SetSpawnInfo(playerid, 0, pInfo[playerid][pSkin],pInfo[playerid][pPosX],pInfo[playerid][pPosY],pInfo[playerid][pPosZ],0,0,0,0,0,0,0);
SpawnPlayer(playerid);
Under your Data Save Function:

pawn Код:
GetPlayerPos(playerid, pInfo[playerid][pPosX], pInfo[playerid][pPosY], pInfo[playerid][pPosZ]);

dini_FloatSet(File, "PosX", pInfo[playerid][pPosX]);
dini_FloatSet(File, "PosY", pInfo[playerid][pPosY]);
dini_FloatSet(File, "PosZ", pInfo[playerid][pPosZ]);
Hope it helps.


Re: dini help... - tanush - 06.03.2011

pawn Код:
D:\Users\Tanush\Desktop\SA-MP\gamemodes\Server.pwn(1069) : warning 202: number of arguments does not match definition
D:\Users\Tanush\Desktop\SA-MP\gamemodes\Server.pwn(1075) : error 028: invalid subscript (not an array or too many subscripts): "pInfo"
D:\Users\Tanush\Desktop\SA-MP\gamemodes\Server.pwn(1075) : warning 215: expression has no effect
D:\Users\Tanush\Desktop\SA-MP\gamemodes\Server.pwn(1075) : error 001: expected token: ";", but found "]"
D:\Users\Tanush\Desktop\SA-MP\gamemodes\Server.pwn(1075) : error 029: invalid expression, assumed zero
D:\Users\Tanush\Desktop\SA-MP\gamemodes\Server.pwn(1075) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.
line is
pawn Код:
pInfo[playerid][pPosX] = dini_Float(File, "PosX");



Re: dini help... - xir - 06.03.2011

hmm try this, not sure if it works

Under OnPlayerSpawn
pawn Код:
SetPlayerPosition(playerid, dini_Int(file, "PositionX"));
    SetPlayerPosition(playerid, dini_Int(file, "PositionY"));
    SetPlayerPosition(playerid, dini_Int(file, "PositionZ"));
Under OnPlayerDisconnect
pawn Код:
new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    dini_FloatSet(file, "PositionX", x);
    dini_FloatSet(file, "PositionY", y);
    dini_FloatSet(file, "PositionZ", z);
And this, outside of any callbacks(recommended at the buttom of your script)

pawn Код:
new position[MAX_PLAYERS];
stock GetPlayerPosition(playerid)
{
   return position[playerid];
}


stock SetPlayerPosition(playerid, pos)
{
    position[playerid] = position[playerid] + pos;
    return position[playerid];
}
It should write the coordinates in to a player file and then load it. But im not sure, you can try it