Skin keeps resetting to 0, as does other stuff.
#1

It doesn't save skins properly when I call it in GMX, it immediately after getting it, sets it to 0. I've no idea why.

I call it under OnPlayerDisconnect and CMD:gmx

pawn Код:
stock SavePlayerData(playerid)
{
    new playerip[16], query[128];

        if(LoggedIn[playerid] == 1)
        {
            PlayerSQLID[playerid] = MySQL_GetValue(PlayerSQLID[playerid], "id", "accounts");
            MySQL_SetInteger(PlayerSQLID[playerid], "TotalTime", TotalTime[playerid], "accounts");
            MySQL_SetInteger(PlayerSQLID[playerid], "BankMoney", BankMoney[playerid], "accounts");
            MySQL_SetInteger(PlayerSQLID[playerid], "Skin", GetPlayerSkin(playerid), "accounts");
            printf("Player Skin %d",GetPlayerSkin(playerid));
            MySQL_SetInteger(PlayerSQLID[playerid], "Money", GetPlayerMoney(playerid), "accounts");
            MySQL_SetInteger(PlayerSQLID[playerid], "Cocaine", Cocaine[playerid], "accounts");
            MySQL_SetInteger(PlayerSQLID[playerid], "Weed", Weed[playerid], "accounts");
            MySQL_SetInteger(PlayerSQLID[playerid], "SGrip", SGrip[playerid], "accounts");
            MySQL_SetInteger(PlayerSQLID[playerid], "MGrip", MGrip[playerid], "accounts");
            MySQL_SetInteger(PlayerSQLID[playerid], "LGrip", LGrip[playerid], "accounts");
            MySQL_SetInteger(PlayerSQLID[playerid], "SFrame", SFrame[playerid], "accounts");
            MySQL_SetInteger(PlayerSQLID[playerid], "MFrame", MFrame[playerid], "accounts");
            MySQL_SetInteger(PlayerSQLID[playerid], "LFrame", LFrame[playerid], "accounts");
            MySQL_SetInteger(PlayerSQLID[playerid], "SBarrel", SBarrel[playerid], "accounts");
            MySQL_SetInteger(PlayerSQLID[playerid], "MBarrel", MBarrel[playerid], "accounts");
            MySQL_SetInteger(PlayerSQLID[playerid], "LBarrel", LBarrel[playerid], "accounts");

            GetPlayerIp(playerid, playerip, sizeof(playerip));
            format(query, sizeof(query), "UPDATE `accounts` SET `PlayerIP` = '%s' WHERE `id` = '%d' LIMIT 1", playerip,PlayerSQLID[playerid]);
            mysql_query(query);
        }
    return 1;
}
/gmx

pawn Код:
CMD:gmx(playerid, params[])
{
    if(LoggedIn[playerid] == 0) return SendClientMessage(playerid, COLOUR_GREY, "You must be logged in to use this command.");

    new reason[128], time;
    if(AdminLevel[playerid] < 3) return SendClientMessage(playerid, COLOUR_GREY, "You are not authorized to use this command.");
    if(sscanf(params, "ds[128]", time, reason)) return SendClientMessage(playerid, COLOUR_GREY, "Usage: /gmx [time till restart] [reason]");
    if(time < 1 ||time > 60) return SendClientMessage(playerid, COLOUR_GREY, "Time must be between 1 minute and 1 hour.");
    format(reason, sizeof(reason), "Admin %s has scheduled a Server Restart in %d minute(s) [Reason: %s]", GetNameEx(playerid), time, reason);
    SendClientMessageToAll(0x95FFB4FF, reason);

    foreach(Player, i)
    {
        SavePlayerData(i);
    }

    GMXTIME = time;// Starts a timer when it reaches 0 it restarts. (Minutes)
    return 1;
}
Reply
#2

You should load the skin as a variable.

pawn Код:
new PlayerSkin[MAX_PLAYERS];
Put this code in your login script:

pawn Код:
PlayerSkin[playerid] = MySQL_GetValue(PlayerSQLID[playerid], "Skin", "accounts");
And then under OnPlayerSpawn:

pawn Код:
SetPlayerSkin(playerid, PlayerSkin[playerid]);
Reply
#3

Thanks.

Actually I've already done that.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)