16.07.2014, 16:17
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.
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.
+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.
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;
}
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;
}
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.


