Saving Skin/Position - 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: Saving Skin/Position (
/showthread.php?tid=157197)
Saving Skin/Position -
TKZ227 - 05.07.2010
I'm having an issue. I'm new to using Dini/any saving stats thing period. I created a register and login out of a dialog using Dini. I added to that it saves everything. Anything in my enum pInfo such as "Faction" or "BankMoney" saves, but Skin and Position do not save. Here is the code I'm using to save and load:
OnPlayerDisconnect:
Code:
PlayerInfo[playerid][Skin] = GetPlayerSkin(playerid);
dini_IntSet(file,"Skin", PlayerInfo[playerid][Skin]);
When the player logs in:
Code:
SetPlayerSkin(playerid, PlayerInfo[playerid][Skin]);
I did the same thing with money, and money saves perfectly. Can anyone help me with this?
Re: Saving Skin/Position -
Miikkel - 05.07.2010
Remember to load the skin when the person logs into his account.
Code:
PlayerInfo[playerid][Skin] = dini_Int(file, "Skin");
Re: Saving Skin/Position -
TKZ227 - 05.07.2010
Yeah I have that, just forgot to put it in the main post.
pawn Code:
PlayerInfo[playerid][Skin] = dini_Int(file, "Skin");
Re: Saving Skin/Position -
Miikkel - 05.07.2010
Hmm, I can't realy understand why the Skin won't save, as I'm using the same method - and that works 100%.
For the Position - I use this:
In you Playerinfo enum:
Code:
Float:pPosX,
Float:pPosY,
Float:pPosZ,
Under your Login Function
Code:
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
Code:
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]);
Tell me if that works.
Re: Saving Skin/Position -
TKZ227 - 06.07.2010
I got it to work, just needed to make it occur AFTER the player spawns, because it was by default giving me the CJ skin stuff.
Re: Saving Skin/Position -
Miikkel - 06.07.2010
Quote:
Originally Posted by TKZ227
I got it to work, just needed to make it occur AFTER the player spawns, because it was by default giving me the CJ skin stuff.
|
Yea you need to place it under
OnPlayerSpawn
Re: Saving Skin/Position -
TheKingOfSamp - 06.07.2010
PHP Code:
SetPlayerSkin(playerid, PlayerInfo[playerid][pChar]);