Set Skin On Spawn
#1

Hey guys, for some reason, when my character gets spawned, his skin automatically gets set to 0.

On my database it shows:

pawn Код:
Name    Password    Admin   Money   ppos_x  ppos_y  ppos_z  Gender  Level   Skin
Abreezyy    censored    0   0   -1969.48    130.9289    27.68750    1   0   29
But, when i actually set the skin it goes back to 0

pawn Код:
SetPlayerSkin(playerid, UserStats[playerid][Skin]);
Skin loading:

pawn Код:
if(mysql_fetch_row(str))
    {
        sscanf(str, "p<|>e<s[24]s[50]ddfffddd>", UserStats[playerid]);
    }
    mysql_free_result();
Any thoughts on problem and how to fix? Thanks in advance.

-Anthony
Reply
#2

I responded to your question on the Andreas Market forums. Which MySQL plugin are you using? I know the issue, I just need to know the correct function to get you.
Reply
#3

Oh i forgot i posted there, strikenkids
Reply
#4

Okay, go ahead and see if this makes a difference.

pawn Код:
if(mysql_num_rows() > 0)
{
    while(mysql_fetch_row(str, "|"))
    {
        sscanf(str, "p<|>e<s[24]s[50]ddfffddd>", UserStats[playerid]);
    }
}
mysql_free_result();
EDIT: Actually, try this one if the one above doesn't work properly either.

pawn Код:
if(mysql_num_rows() > 0)
{
    mysql_fetch_row(str, "|");
    sscanf(str, "p<|>e<s[24]s[50]ddfffddd>", UserStats[playerid]);
}
mysql_free_result();
EDIT 2: Okay, so I reviewed the sscanf line over and over and realized I missed something. You had it messed up in the beginning. If the above don't work, try this:

pawn Код:
if(mysql_num_rows() > 0)
{
    mysql_fetch_row(str, "|");
    sscanf(str, "e<p<|>s[24]s[50]ddfffddd>", UserStats[playerid]);
}
mysql_free_result();
Reply
#5

Negative, skin still gets set to 0

Edit: just saw your edit

Edit2: still didnt work :/
Reply
#6

Quote:
Originally Posted by Anthonyx3'
Посмотреть сообщение
Negative, skin still gets set to 0

Edit: just saw your edit

Edit2: still didnt work :/
Could you display your enum for player stats?
Reply
#7

Sure
pawn Код:
enum pEnum
{
    Name[MAX_PLAYER_NAME],
    Password[32],
    Admin,
    Money,
    Level,
    Float:ppos_x[4],
    Float:ppos_y[4],
    Float:ppos_z[4],
    Skin,
    Gender
};
Also, id like to share these few lines from mysql log
pawn Код:
Function: mysql_fetch_row executed with result: "Abreezyy|tony|0|0|99.62181|-97.9576|1.330710|0|0|180".
 Function: mysql_free_result executed.
shows skin is being loaded o.o
Reply
#8

Quote:
Originally Posted by Anthonyx3'
Посмотреть сообщение
Sure
pawn Код:
enum pEnum
{
    Name[MAX_PLAYER_NAME],
    Password[32],
    Admin,
    Money,
    Level,
    Float:ppos_x[4],
    Float:ppos_y[4],
    Float:ppos_z[4],
    Skin,
    Gender
};
Also, id like to share these few lines from mysql log
pawn Код:
Function: mysql_fetch_row executed with result: "Abreezyy|tony|0|0|99.62181|-97.9576|1.330710|0|0|180".
 Function: mysql_free_result executed.
shows skin is being loaded o.o
Just as I had expected; your enum doesn't match the format for the sscanf line or the MySQL database. They need to be in the EXACT same order, otherwise it won't work properly...
Reply
#9

Oh...i didnt know that, lol
Reply
#10

Quote:
Originally Posted by Anthonyx3'
Посмотреть сообщение
Oh...i didnt know that, lol
I made the same exact mistake when I was learning MySQL awhile ago. Anyways, get them in the correct order and it should work properly.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)