Saving Skins
#1

Hey, today I've started to save skins in my own script, and I've ran into a bit of a problem. See the code below.

pawn Код:
enum PlayerData
{
    Password[255],
    Registered,
    Authenticated,
    Float: LastX,
    Float: LastY,
    Float: LastZ,
    Float: LastA,
    Float: LastHealth,
    Float: LastArmour,
    LastSkin, // Here we have the enum for a players skin, marked as 'LastSkin'
    LastVW,
    LastInterior,
    ModeratorLevel,
    AdminLevel,
};
pawn Код:
public LoadPlayerData(playerid, password[])
{
    new string[128], Year, Month, Day, Minute, Hour, Second, Name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, Name, sizeof(Name));
    format(string, sizeof(string), "Accounts/%s.ini", Name);

    getdate(Year, Month, Day);
    gettime(Hour, Minute, Second);

    if(fexist(string))
    {
        if(strcmp(dini_Get(string, "Password"), password, false) == 0)
        {
            Player[playerid][Authenticated] = 1;
            Player[playerid][Password] = dini_Get(string, "Password");
            Player[playerid][Registered] = dini_Int(string, "Registered");
            Player[playerid][LastX] = dini_Float(string, "LastX");
            Player[playerid][LastY] = dini_Float(string, "LastY");
            Player[playerid][LastZ] = dini_Float(string, "LastZ");
            Player[playerid][LastA] = dini_Float(string, "LastA");
            Player[playerid][LastHealth] = dini_Float(string, "LastHealth");
            Player[playerid][LastArmour] = dini_Float(string, "LastArmour");
            //Player[playerid][LastSkin] = dini_Int(string, "LastSkin");
            Player[playerid][LastVW] = dini_Int(string, "LastVW");
            Player[playerid][LastInterior] = dini_Int(string, "LastInterior");
            Player[playerid][AdminLevel] = dini_Int(string, "AdminLevel");
            Player[playerid][ModeratorLevel] = dini_Int(string, "ModeratorLevel");
           
            SetSpawnInfo(playerid, 0, Player[playerid][LastSkin], Player[playerid][LastX], Player[playerid][LastY], Player[playerid][LastZ], Player[playerid][LastA], 0, 0, 0, 0, 0, 0);
            SpawnPlayer(playerid);
           
            SetPlayerPos(playerid, Player[playerid][LastX], Player[playerid][LastY], Player[playerid][LastZ]);
            SetPlayerFacingAngle(playerid, Player[playerid][LastA]);
            SetPlayerHealth(playerid, Player[playerid][LastHealth]);
            SetPlayerArmour(playerid, Player[playerid][LastArmour]);
            SetPlayerSkin(playerid, dini_Int(string, "LastSkin")); // Here we have the function that is supposed to set a players skin, according to the dini file.
            return 1;
        }
    }
    else
    {
        SendClientMessage(playerid, WHITE, "You must register first.");
    }
    return 1;
}
However, it is not saving the skin. It's a problem with the next code which shows my method of saving the skins, which is called when the player disconnects. Also, even when I manually change the skin in their userfile, it still comes out as some 1541654121 number (or close to that) and not the number I set in there which is 59.

pawn Код:
public SavePlayerData(playerid)
{
    if(Player[playerid][Authenticated] == 1)
    {
        GetPlayerPos(playerid, Player[playerid][LastX], Player[playerid][LastY], Player[playerid][LastZ]);
        GetPlayerHealth(playerid, Player[playerid][LastHealth]);
        GetPlayerArmour(playerid, Player[playerid][LastArmour]);
        Player[playerid][LastVW] = GetPlayerVirtualWorld(playerid);
        Player[playerid][LastInterior] = GetPlayerInterior(playerid);

        new string[128];
       
        format(string, sizeof(string), "Accounts/%s.ini", GetNameWithUnderscore(playerid));

        if(!fexist(string))
        {
            dini_Create(string);
        }

        dini_Set(string, "Password", Player[playerid][Password]);
        dini_FloatSet(string, "LastX", Player[playerid][LastX]);
        dini_FloatSet(string, "LastY", Player[playerid][LastY]);
        dini_FloatSet(string, "LastZ", Player[playerid][LastZ]);
        dini_FloatSet(string, "LastHealth", Player[playerid][LastHealth]);
        dini_FloatSet(string, "LastArmour", Player[playerid][LastArmour]);
        dini_IntSet(string, "LastSkin", GetPlayerSkin(playerid));
        dini_IntSet(string, "LastVW", Player[playerid][LastVW]);
        dini_IntSet(string, "LastInterior", Player[playerid][LastInterior]);
        dini_IntSet(string, "AdminLevel", Player[playerid][AdminLevel]);
        dini_IntSet(string, "ModeratorLevel", Player[playerid][ModeratorLevel]);
    }
    return 1;
}
+REP for anyone who can help me solve this issue.

TLDR; To be more clear, I want it to save your skin on logout into the dini file, and load it correctly when the player logs in. Currently, instead of saying 59, it's saying 1265469541 or some weird number.
Reply
#2

EDIT: misread.

Try editing it while you're not on the server and see if it loads when you join. Check to see if it wrote correctly before you log off.
Reply
#3

Quote:
Originally Posted by austin070
Посмотреть сообщение
EDIT: misread.

Try editing it while you're not on the server and see if it loads when you join. Check to see if it wrote correctly before you log off.
It only saves when you log off. When you disconnect, it calls public SavePlayerData(playerid) and it's supposed to get the player's skin, and write it to the file.
Reply
#4

pawn Код:
public LoadPlayerData(playerid, password[])
{
    new string[128], Year, Month, Day, Minute, Hour, Second, Name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, Name, sizeof(Name));
    format(string, sizeof(string), "Accounts/%s.ini", Name);

    getdate(Year, Month, Day);
    gettime(Hour, Minute, Second);

    if(fexist(string))
    {
        if(strcmp(dini_Get(string, "Password"), password, false) == 0)
        {
            Player[playerid][Authenticated] = 1;
            Player[playerid][Password] = dini_Get(string, "Password");
            Player[playerid][Registered] = dini_Int(string, "Registered");
            Player[playerid][LastX] = dini_Float(string, "LastX");
            Player[playerid][LastY] = dini_Float(string, "LastY");
            Player[playerid][LastZ] = dini_Float(string, "LastZ");
            Player[playerid][LastA] = dini_Float(string, "LastA");
            Player[playerid][LastHealth] = dini_Float(string, "LastHealth");
            Player[playerid][LastArmour] = dini_Float(string, "LastArmour");
            Player[playerid][LastSkin] = dini_Int(string, "LastSkin");
            Player[playerid][LastVW] = dini_Int(string, "LastVW");
            Player[playerid][LastInterior] = dini_Int(string, "LastInterior");
            Player[playerid][AdminLevel] = dini_Int(string, "AdminLevel");
            Player[playerid][ModeratorLevel] = dini_Int(string, "ModeratorLevel");
           
            SetSpawnInfo(playerid, 0, Player[playerid][LastSkin], Player[playerid][LastX], Player[playerid][LastY], Player[playerid][LastZ], Player[playerid][LastA], 0, 0, 0, 0, 0, 0);
            SpawnPlayer(playerid);
           
            SetPlayerPos(playerid, Player[playerid][LastX], Player[playerid][LastY], Player[playerid][LastZ]);
            SetPlayerFacingAngle(playerid, Player[playerid][LastA]);
            SetPlayerHealth(playerid, Player[playerid][LastHealth]);
            SetPlayerArmour(playerid, Player[playerid][LastArmour]);
            SetPlayerSkin(playerid, dini_Int(string, "LastSkin")); // Here we have the function that is supposed to set a players skin, according to the dini file.
            return 1;
        }
    }
    else
    {
        SendClientMessage(playerid, WHITE, "You must register first.");
    }
    return 1;
}
Reply
#5

Quote:
Originally Posted by Clad
Посмотреть сообщение
pawn Код:
public LoadPlayerData(playerid, password[])
{
    new string[128], Year, Month, Day, Minute, Hour, Second, Name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, Name, sizeof(Name));
    format(string, sizeof(string), "Accounts/%s.ini", Name);

    getdate(Year, Month, Day);
    gettime(Hour, Minute, Second);

    if(fexist(string))
    {
        if(strcmp(dini_Get(string, "Password"), password, false) == 0)
        {
            Player[playerid][Authenticated] = 1;
            Player[playerid][Password] = dini_Get(string, "Password");
            Player[playerid][Registered] = dini_Int(string, "Registered");
            Player[playerid][LastX] = dini_Float(string, "LastX");
            Player[playerid][LastY] = dini_Float(string, "LastY");
            Player[playerid][LastZ] = dini_Float(string, "LastZ");
            Player[playerid][LastA] = dini_Float(string, "LastA");
            Player[playerid][LastHealth] = dini_Float(string, "LastHealth");
            Player[playerid][LastArmour] = dini_Float(string, "LastArmour");
            Player[playerid][LastSkin] = dini_Int(string, "LastSkin");
            Player[playerid][LastVW] = dini_Int(string, "LastVW");
            Player[playerid][LastInterior] = dini_Int(string, "LastInterior");
            Player[playerid][AdminLevel] = dini_Int(string, "AdminLevel");
            Player[playerid][ModeratorLevel] = dini_Int(string, "ModeratorLevel");
           
            SetSpawnInfo(playerid, 0, Player[playerid][LastSkin], Player[playerid][LastX], Player[playerid][LastY], Player[playerid][LastZ], Player[playerid][LastA], 0, 0, 0, 0, 0, 0);
            SpawnPlayer(playerid);
           
            SetPlayerPos(playerid, Player[playerid][LastX], Player[playerid][LastY], Player[playerid][LastZ]);
            SetPlayerFacingAngle(playerid, Player[playerid][LastA]);
            SetPlayerHealth(playerid, Player[playerid][LastHealth]);
            SetPlayerArmour(playerid, Player[playerid][LastArmour]);
            SetPlayerSkin(playerid, dini_Int(string, "LastSkin")); // Here we have the function that is supposed to set a players skin, according to the dini file.
            return 1;
        }
    }
    else
    {
        SendClientMessage(playerid, WHITE, "You must register first.");
    }
    return 1;
}
Nope
Reply
#6

Still need help with this.
Reply
#7

Instead of extracting your skin again from dini try to use your enum array.

Also no comma after the last enum item!
...
item1,
item2,
item3
};
Reply
#8

Quote:
Originally Posted by Hanger
Посмотреть сообщение
Instead of extracting your skin again from dini try to use your enum array.

Also no comma after the last enum item!
...
item1,
item2,
item3
};
Example, please?

REPPED
Reply
#9

pawn Код:
Player[playerid][LastSkin]= dini_Int(string, "Last Skin");
Reply
#10

I've tried it, yet the skin still has trouble saving, here is my callback called when the player disconnects

pawn Код:
public SavePlayerData(playerid)
{
    if(Player[playerid][Authenticated] == 1)
    {
        GetPlayerPos(playerid, Player[playerid][LastX], Player[playerid][LastY], Player[playerid][LastZ]);
        GetPlayerFacingAngle(playerid, Player[playerid][LastA]);
        GetPlayerHealth(playerid, Player[playerid][LastHealth]);
        GetPlayerArmour(playerid, Player[playerid][LastArmour]);
        Player[playerid][LastVW] = GetPlayerVirtualWorld(playerid);
        Player[playerid][LastInterior] = GetPlayerInterior(playerid);

        new string[128];
       
        format(string, sizeof(string), "Accounts/%s.ini", GetNameWithUnderscore(playerid));

        if(!fexist(string))
        {
            dini_Create(string);
        }

        dini_Set(string, "Password", Player[playerid][Password]);
        dini_FloatSet(string, "LastX", Player[playerid][LastX]);
        dini_FloatSet(string, "LastY", Player[playerid][LastY]);
        dini_FloatSet(string, "LastZ", Player[playerid][LastZ]);
        dini_FloatSet(string, "LastHealth", Player[playerid][LastHealth]);
        dini_FloatSet(string, "LastArmour", Player[playerid][LastArmour]);
        dini_IntSet(string, "LastSkin", GetPlayerSkin(playerid));
        dini_IntSet(string, "LastVW", Player[playerid][LastVW]);
        dini_IntSet(string, "LastInterior", Player[playerid][LastInterior]);
        dini_IntSet(string, "AdminLevel", Player[playerid][AdminLevel]);
        dini_IntSet(string, "ModeratorLevel", Player[playerid][ModeratorLevel]);
    }
    return 1;
}
Still saving as a weird number 1458124
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)