Skin saving problem
#1

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)
Reply
#2

Код:
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.
Reply
#3

No, it sets the skin ID 0, (CJ) so it's a Saving problem.
Reply
#4

UP!!
Reply
#5

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.
Reply
#6

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.
Reply
#7

so show us your loading AND saving functions.
Reply
#8

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.
Reply
#9

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.
Reply
#10

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+
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)