Some one I need help thanks.
#4

I don't recommend using OnPlayerUpdate for saving stuff in files, it will cause a lot of lag because OnPlayerUpdate is called about 20 times per second, I recommend using a timer instead...

Here is the code if you need it:

pawn Код:
public OnPlayerConnect(playerid)
{
    //Set a timer for the player that repeats every 2 seconds to update the player's stats...
    SetPVarInt(playerid, "UpdateTimer", SetTimerEx("UpdatePlayer", 2000, true, "i", playerid));
}

public OnPlayerDisconnect(playerid)
{
    //Kill the update timer for the player...
    KillTimer(GetPVarInt(playerid, "UpdateTimer"));
}

//Called every 2 seconds for a player
stock UpdatePlayer(playerid)
{
    new file[128];
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file), "%s.ini", name);
    new uCash = GetPlayerMoney(playerid);
    dini_IntSet(file,"AdminLevel", PlayerInfo[playerid][AdminLevel]);
    dini_IntSet(file,"Cash", uCash);
    dini_IntSet(file,"Kills", PlayerInfo[playerid][pKills]);
    dini_IntSet(file,"Deaths", PlayerInfo[playerid][pDeaths]);
    dini_IntSet(file,"Locked", PlayerInfo[playerid][pLocked]);
    dini_IntSet(file,"Local", PlayerInfo[playerid][pLocal]);
    dini_IntSet(file,"Int", PlayerInfo[playerid][pInt]);
    return 1;
}
Reply


Messages In This Thread
Some one I need help thanks. - by kujox32 - 06.05.2010, 01:54
Re: Some one I need help thanks. - by westre - 06.05.2010, 02:03
Re: Some one I need help thanks. - by kujox32 - 06.05.2010, 03:09
Re: Some one I need help thanks. - by PotH3Ad - 06.05.2010, 04:45
Re: Some one I need help thanks. - by kujox32 - 06.05.2010, 05:03
Re: Some one I need help thanks. - by PotH3Ad - 07.05.2010, 00:06
Re: Some one I need help thanks. - by kujox32 - 07.05.2010, 01:19
Re: Some one I need help thanks. - by PotH3Ad - 07.05.2010, 02:38

Forum Jump:


Users browsing this thread: 2 Guest(s)