Skin saving problem
#1

Always when a player spawns, his skin is ID 0. How can i fix this?
pawn Код:
enum PlayerInfo
{
    Pass[129],
    Adminlevel,
    VIPlevel,
    Money,
    Scores,
    Kills,
    Deaths,
    Skin,......

public loadaccount_user(playerid, name[], value[])
{
    INI_String("Password", pInfo[playerid][Pass],129);
    INI_Int("AdminLevel",pInfo[playerid][Adminlevel]);
    INI_Int("VIPLevel",pInfo[playerid][VIPlevel]);
    INI_Int("Money",pInfo[playerid][Money]);
    INI_Int("Scores",pInfo[playerid][Scores]);
    INI_Int("Kills",pInfo[playerid][Kills]);
    INI_Int("Deaths",pInfo[playerid][Deaths]);
    INI_Int("Skin", pInfo[playerid][Skin]);...................

This is in the login command -->  
if ( pInfo[playerid][Skin]!= 0){
                    SetPlayerSkin(playerid, pInfo[playerid][Skin]);
                    }

dcmd_myskin(playerid, params[])
{
    new skinid, string[256];
    if( sscanf( params, "i", skinid ) ) return SendClientMessage( playerid, -1, "Използвай: /skin [ID]" );
    if(skinid > 299 || skinid< 0) return SendClientMessage(playerid,COLOR_RED,"ГРЕШКА: Налични скинове: 0 - 299 !");
    SetPlayerSkin(playerid,skinid);
    format(string, sizeof(string), "Ти промени твоя скин!");
    SendClientMessage(playerid, COLOR_YELLOW, string);
    new INI:file = INI_Open( Path( playerid ) );
    INI_WriteInt( file, "Skin",skinid);
    INI_Close( file );
    return 1;
}
Reply
#2

Do you set the skin with the command and then reconnect to the server? Can you confirm the correct value is getting written to the file when the command is executed?
Reply
#3

Yes, the value in the file is correct. Whichever skin I choose in the begging(class selection), it always spawns me with skin ID 0, no matter what is written in the file or which skin i choose.
Reply
#4

IIRC you have to use https://sampwiki.blast.hk/wiki/SetSpawnInfo
Reply
#5

Make sure you don't set the skin under OnPlayerSpawn back to 0. Besides that, make sure the AddPlayerClass lines and IDs within OnPlayerRequestClass are correct.

It won't set the skin automatically on spawn, as you only have that code within the login command.
Reply
#6

Quote:
Originally Posted by Bakr
Посмотреть сообщение
Make sure you don't set the skin under OnPlayerSpawn back to 0. Besides that, make sure the AddPlayerClass lines and IDs within OnPlayerRequestClass are correct.

It won't set the skin automatically on spawn, as you only have that code within the login command.
Everything what you said to check is correct. I have in the login command
pawn Код:
if ( pInfo[playerid][Skin]!= 0){
                    SetPlayerSkin(playerid, pInfo[playerid][Skin]);
                    }
Is it enought to set the player skin? See my first post for the whole script.
Reply
#7

Are you using the command after spawning or during class selection? If during class selection you may need to use SetSpawnInfo as Misiur pointed out. Also add some debugging messages to print out the value of pInfo[playerid][Skin] to make sure the correct value is loaded from the file into the variable.
Reply
#8

The login command is used before class selection. When I use /myskin whe correct SkinID is saved in the user's file but it loads SkinID 0 every time I connect. Furthermore, whichever skin i choose in the class selection (for my first visiting at the server with this nickname) when i spawn it is ID 0
Reply
#9

Okay. It makes sense for it not to work after logging in and then setting the skin, as it will be updated in the file, but never updated or used from the variable. For second visits, it should work, unless you have something else preventing it from doing so.

As a quick fix you could just set the player's skin after they spawn. That is me assuming you want the saved skin to always be used despite what they pick in class selection if they are logged in.
Reply
#10

I created new account, registered and chose a skin in the class selection. When i spawned it was the same(I made what you told me)
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)