Skin is not saving?
#1

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

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

Is that all's i need?
Reply
#4

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

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

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

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

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

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;
}
Reply
#10

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;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)