SA-MP Forums Archive
Skin is not saving? - 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: Skin is not saving? (/showthread.php?tid=184913)



Skin is not saving? - Luis- - 22.10.2010

Okay I have a register/login system and I want my skins ot save so when a Player logs in he gets his skin that he picked on the Class Selection screen?

pawn Код:
public OnPlayerLogin(playerid)
{
    if(IsPlayerConnected(playerid))
    {
        pLogged[playerid] = 1;
        new tmpname[MAX_PLAYER_NAME], tmpstring[128], tmp[256];
        GetPlayerName(playerid, tmpname, sizeof(tmpname));
        format(tmpstring, sizeof(tmpstring), "Users/%s.ini", tmpname);
        if(dini_Isset(tmpstring, "Key")) PlayerInfo[playerid][Key] = tmp = dini_Get(tmpstring, "Key");
        if(dini_Isset(tmpstring, "Skin")) PlayerInfo[playerid][Skin] = dini_Int(tmpstring, "Skin");
        if(dini_Isset(tmpstring, "Name")) PlayerInfo[playerid][Name] = dini_Int(tmpstring, "Name");
        if(dini_Isset(tmpstring, "Sex")) PlayerInfo[playerid][Sex] = dini_Int(tmpstring, "Sex");
        if(dini_Isset(tmpstring, "Age")) PlayerInfo[playerid][Age] = dini_Int(tmpstring, "Age");
        if(dini_Isset(tmpstring, "Accent")) PlayerInfo[playerid][Accent] = dini_Int(tmpstring, "Accent");
    }
}
pawn Код:
public OnPlayerSpawn(playerid)
{
    SetPlayerSkin(playerid, PlayerInfo[playerid][Skin]);
    return 1;
}
If you need more just ask


Re: Skin is not saving? - LarzI - 22.10.2010

Make the player spawn after logging in (after the login dialog/cmd is executed) by doing
pawn Код:
SpawnPlayer(playerid);



Re: Skin is not saving? - Luis- - 22.10.2010

Is that all's i need?


Re: Skin is not saving? - LarzI - 22.10.2010

And ofcourse set his skin if he is logged in when spawning.


Re: Skin is not saving? - Luis- - 22.10.2010

Something like this?
pawn Код:
public OnPlayerSpawn(playerid)
{
    if(IsPlayerConnected(playerid))
    {
        pLogged[playerid] = 1;
        SetPlayerSkin(playerid, PlayerInfo[playerid][Skin]);
    }
    return 1;
}



Re: Skin is not saving? - JamesC - 22.10.2010

Please confirm that the skin is actually saving into the ini file. What LarzI is suggesting is that you're not setting the players skin correctly but this wouldn't help if the skin itself is not saving.


Re: Skin is not saving? - Luis- - 22.10.2010

Quote:
Originally Posted by JamesC
Посмотреть сообщение
Please confirm that the skin is actually saving into the ini file. What LarzI is suggesting is that you're not setting the players skin correctly but this wouldn't help if the skin itself is not saving.
Yeah, The skin itself is not saving..


Re: Skin is not saving? - Calgon - 22.10.2010

You've only provided the code you use to load the skin, which I cannot see any errors with. Could you provide the code you use to save the skin? From your original post, I gathered that you're trying to save the skin, load it on next login, but the skin they chose from last skin selection - correct? I'm only clarifying this because you were unclear in your first post.


Re: Skin is not saving? - Luis- - 22.10.2010

Sure, Here's he update code;
pawn Код:
public OnPlayerFUpdate(playerid)
{
    new tmpstring[64];
    new tmpname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, tmpname, sizeof(tmpname));
    format(tmpstring, sizeof(tmpstring), "Users/%s.ini", tmpname);
    dini_Remove(tmpstring);
    dini_Create(tmpstring);
    dini_Set(tmpstring, "Password", PlayerInfo[playerid][Key]);
    dini_IntSet(tmpstring, "Skin", PlayerInfo[playerid][Skin]);
    dini_IntSet(tmpstring, "Name", PlayerInfo[playerid][Name]);
    dini_IntSet(tmpstring, "Age", PlayerInfo[playerid][Age]);
    dini_IntSet(tmpstring, "Sex", PlayerInfo[playerid][Sex]);
    dini_IntSet(tmpstring, "Accent", PlayerInfo[playerid][Accent]);
    return 1;
}
Here's the Disconnect code;
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    OnPlayerFUpdate(playerid);
    GetPlayerSkin(playerid);
    return 1;
}



Re: Skin is not saving? - Calgon - 22.10.2010

GetPlayerSkin(playerid) returns the skin ID of the player. You have assigned the value to nothing, and you're trying to save variable 'PlayerInfo[playerid][Skin]' which has no value.

pawn Код:
public OnPlayerFUpdate(playerid)
{
    new tmpstring[64];
    new tmpname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, tmpname, sizeof(tmpname));
    format(tmpstring, sizeof(tmpstring), "Users/%s.ini", tmpname);
    dini_Remove(tmpstring);
    dini_Create(tmpstring);
    dini_Set(tmpstring, "Password", PlayerInfo[playerid][Key]);
    dini_IntSet(tmpstring, "Skin", GetPlayerSkin(playerid));
    dini_IntSet(tmpstring, "Name", PlayerInfo[playerid][Name]);
    dini_IntSet(tmpstring, "Age", PlayerInfo[playerid][Age]);
    dini_IntSet(tmpstring, "Sex", PlayerInfo[playerid][Sex]);
    dini_IntSet(tmpstring, "Accent", PlayerInfo[playerid][Accent]);
    return 1;
}