28.05.2012, 12:26
Hello, i tried to make my own leveling system, but it is kinda bugged. It doesn't work for everyplayer when more than one is online, and sometimes it takes less than 60 seconds to pass 1 minute.. ![Sad](images/smilies/sad.gif)
Here is the code:
Thanks. I am really bad with timers.. :S
![Sad](images/smilies/sad.gif)
Here is the code:
pawn Код:
Under OnPlayerConnect i have:
SetTimer("PlayingTime", 60000, true);
Than the function is:
forward PlayingTime(playerid);
public PlayingTime(playerid)
{
new Name[MAX_PLAYER_NAME];
GetPlayerName(playerid, Name, sizeof(Name));
PlayerInfo[playerid][PlayingMinutes]++;
if(PlayerInfo[playerid][PlayingMinutes] >= 60)
{
PlayerInfo[playerid][PlayingHours]++;
PlayerInfo[playerid][RespectPoints]++;
PlayerInfo[playerid][PlayingMinutes] = 0;
format(file, sizeof(file), "RRP/users/%s.ini", Name);
if(fexist(file))
{
dini_IntSet(file, "PlayingHours", PlayerInfo[playerid][PlayingHours]);
dini_IntSet(file, "RespectPoints", PlayerInfo[playerid][RespectPoints]);
dini_IntSet(file, "PlayingMinutes", PlayerInfo[playerid][PlayingMinutes]);
}
return 1;
}
format(file, sizeof(file), "RRP/users/%s.ini", Name);
if(fexist(file))
{
dini_IntSet(file, "PlayingMinutes", PlayerInfo[playerid][PlayingMinutes]);
}
return 1;
}