Skin saving problem -
alanhutch - 04.01.2015
Hi all.
I wonder why this code is not working.
On OnPlayerDisconnect it saves the skin:
pawn Код:
//OnPlayerDisconnect
new skin;
skin = GetPlayerSkin(playerid);
PlayerInfo[playerid][pModel] = skin;
//OnPlayerSave
SQL_UpdateInt(index, "Model",PlayerInfo[playerid][pModel]);
And in OnPlayerSpawn it loads the skin:
pawn Код:
SetPlayerSkin(playerid, PlayerInfo[playerid][pModel]);
When I spawn the skin is ID 0 (CJ)... What's wrong? Thanks.
(IN the .DB file is all correct)
Re: Skin saving problem -
Divergent - 04.01.2015
Код:
new skin;
skin = GetPlayerSkin(playerid);
PlayerInfo[playerid][pModel] = skin;
You can just do PlayerInfo[playerid][pModel] = GetPlayerSkin(playerid);
Is the information saving correctly to the database? If it is, it's a loading problem. If it's not, it's a saving problem.
Re: Skin saving problem -
alanhutch - 04.01.2015
No, it sets the skin ID 0, (CJ) so it's a Saving problem.
Re: Skin saving problem -
alanhutch - 05.01.2015
UP!!
Re: Skin saving problem -
Virtual1ty - 05.01.2015
Well, you contradict yourself - you first say it saves correctly to the database and then you say it doesn't, which one is it?
If it's a LOADING problem as you first described then show us that code.
Re: Skin saving problem -
alanhutch - 05.01.2015
Quote:
Originally Posted by Virtual1ty
Well, you contradict yourself - you first say it saves correctly to the database and then you say it doesn't, which one is it?
If it's a LOADING problem as you first described then show us that code.
|
With "In the .db file is all correct" I say that all tables and things are set up correctly.
Re: Skin saving problem -
Smileys - 05.01.2015
so show us your loading AND saving functions.
Re: Skin saving problem -
Write - 05.01.2015
OnPlayerDisconnect calls faster than GetPlayerSkin, you'll never be able to get the players skin if they disconnect.
What you want to do is, make a global variable.
new gmx = 0;
Go to OnPlayerUpdate and do this.
pawn Код:
public OnPlayerUpdate(playerid)
{
if(gmx == 0)
{
SQL_UpdateInt(index, "Model",GetPlayerSkin(playerid));
}
return 1;
}
Now the player skin saves every 30 ms.
Re: Skin saving problem -
Virtual1ty - 05.01.2015
Well, IMHO you should never actually call "GetPlayerSkin" but rather save all the information to variables. You can e.g. hook "SetPlayerSkin" and set the skin variable whenever you use it.
Then, under "OnPlayerDisconnect" simply save the variable value.
Re: Skin saving problem -
alanhutch - 06.01.2015
Quote:
Originally Posted by Turn
OnPlayerDisconnect calls faster than GetPlayerSkin, you'll never be able to get the players skin if they disconnect.
What you want to do is, make a global variable.
new gmx = 0;
Go to OnPlayerUpdate and do this.
pawn Код:
public OnPlayerUpdate(playerid) { if(gmx == 0) { SQL_UpdateInt(index, "Model",GetPlayerSkin(playerid)); } return 1; }
Now the player skin saves every 30 ms.
|
Worked, thanks. REP+