A timer problem
#1

Hello everyone, Well I have been rattling my brain for the past day trying to fix the save skin function... I have finally managed to get it to Save Skins of each individual player but if the server restarts or the user crashes it doesnt update too well... So I thought well if I make a timer for every second or so to get each players skin, money, adminlevel etc and then write it to the file... If they crash it will just put them back to what ever the timer last saved.. Problem is its just setting myself to CJ and all my money is set to 0... I log in on a new account works fine but if I re-log it sets the skin to CJ and money to 0..
Heres my timer code.

pawn Код:
public SavePlayer()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
    if(IsPlayerOnline(i))
    {
    PlayerInfo[i][AdminLevel] = dini_Int(File, "AdminLevel");
    PlayerInfo[i][VIP] = dini_Int(File, "VIP");
    PlayerInfo[i][PlayerCash] = dini_Int(File, "PlayerMoney");
    PlayerInfo[i][Skin] = dini_Int(File, "Skin");
    PlayerInfo[i][Rank] = dini_Int(File, "Rank");
    dini_IntSet(File, "PlayerMoney", PlayerInfo[i][PlayerCash] = GetPlayerMoney(i));
    dini_IntSet(File, "AdminLevel", PlayerInfo[i][AdminLevel]);
    dini_IntSet(File, "Rank", PlayerInfo[i][Rank] = GetPlayerScore(i));
    dini_IntSet(File, "VIP", PlayerInfo[i][VIP]);
    dini_IntSet(File, "Skin", PlayerInfo[i][Skin] = GetPlayerSkin(i));
    }
    else if(!IsPlayerOnline(i))
    {
    return 0;
    }
}
return 1;
}
Reply
#2

pawn Код:
public SavePlayer()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
    if(IsPlayerOnline(i))
    {
   
    dini_IntSet(File, "PlayerMoney", PlayerInfo[i][PlayerCash] = GetPlayerMoney(i));
    dini_IntSet(File, "AdminLevel", PlayerInfo[i][AdminLevel]);
    dini_IntSet(File, "Rank", PlayerInfo[i][Rank] = GetPlayerScore(i));
    dini_IntSet(File, "VIP", PlayerInfo[i][VIP]);
    dini_IntSet(File, "Skin", PlayerInfo[i][Skin] = GetPlayerSkin(i));
    }
    else    return 0;

}
return 1;
}
you where loading the data then saving it just go like this
Reply
#3

No joy, still just resetting all the information... I think that the timers still saving even though everyones offline and if no ones online its got nothing to save so the next person who comes on it has nothing saved so resets there accounts... I don't know what to do
Reply
#4

Anyone?
Reply
#5

Try this
pawn Код:
enum data
{
    AdminLevel,
    VIP,
    PlayerCash,
    Rank
}
new PlayerInfo[MAX_PLAYERS][data];

public SavePlayer()
{
    dini_IntSet(File, "PlayerMoney", PlayerInfo[playerid][PlayerCash] = GetPlayerMoney(playerid));
    dini_IntSet(File, "AdminLevel", PlayerInfo[playerid][AdminLevel]);
    dini_IntSet(File, "Rank", PlayerInfo[playerid][Rank] = GetPlayerScore(playerid));
    dini_IntSet(File, "VIP", PlayerInfo[playerid][VIP]);
    return 1;
}
Make sure you load the variables into the PlayerInfo[playerid][data] when they login.
Reply
#6

I allready have a enum with all this information which is either created at the register dialog or loaded at the login dialog.. The timer just updates there dini files whilst they are online but for some reason if you log out, come back on.. it doesnt work. Cash = 0 Skin = 0.

It works fine without the timer... but I need a timer because if the server restarts it causes a lot of problems for everyone
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)