Timer error in my gamemode??! :O [ REP + ] -
_GHT_MarK445 - 11.09.2016
Hey guys, i am experiencing this error:
In my gamemode, the timers are for some reason a little bit messed up. For example, i have a clock, code:
Код:
forward ChangeTime();
public ChangeTime()
{
new
string[6];
niCe[1] ++;
if(niCe[1] > 59) niCe[1] = 0, niCe[0] ++;
if(niCe[0] > 23) niCe[0] = 0, niCe[1] = 0;
format(string, sizeof(string), "%02d:%02d", niCe[0], niCe[1]);
TextDrawSetString(Clocks, string);
for(new i = 0; i < MAX_PLAYERS; i ++)
{
if(IsPlayerConnected(i)) SetPlayerTime(i, niCe[0], niCe[1]);
}
return 1;
}
the thing is, that the time goes like by two, it does not wait 1 second, but waits two seconds and than the time move automaticly by two
Practical example:
It is
05:42 - 1 second passes, the time is still
05:42
It is
05:42 - 2 second passes, the time is
05:44, and the 3 in 05:4
3 appears just for like one milisecond, hope you guys know what i am talking about.
Next error is, that in this command:
Код:
CMD:vyhodit(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, CHYBA, "[ Chyba ] Nemбte dostatečnб admin prбva!");
new
pplayerid, reason[48], banmt[300],banma[300];
if(sscanf(params, "us[48]", pplayerid, reason)) return SendClientMessage(playerid, POUZITI, "[ Pouћitн ] Pouћitн: /vyhodit [ID] [DŮVOD]");
if(!IsPlayerConnected(pplayerid)) return SendClientMessage(playerid, CHYBA, "[ Chyba ] Hrбč nenн připojen!");
if(PlayerInfo[pplayerid][pAdmin] > 0) return SendClientMessage(playerid, CHYBA, "[ Chyba ] Nemůћete vyhodit člena admin tэmu!");
PlayerInfo[pplayerid][pKicks] ++;
format(banma,sizeof(banma),"[ Administrace ] Admin %s vyhodil hrбče %s! [ %s ]",GetName(playerid),GetName(pplayerid),reason);
format(banmt,sizeof(banmt),"[ Administrace ] Admin %s vбs vyhodil! [ % ]",GetName(playerid), reason);
SendClientMessageToAll(ADMIN,banma);
SendClientMessage(pplayerid,ADMIN,banmt);
SetTimerEx("KickPlayer",100,false,"i",pplayerid);
return 1;
}
Player does not get the message, so this is also proving, that the timers are kind of messed up for some reason.
I am using includes:
Код:
#include <a_samp>
#include <zcmd>
#include <YSI\y_ini>
#include <sscanf2>
Thank you in advance for any solutionable answer, i will also reward you with a reputation point for it.
Re: Timer error in my gamemode??! :O [ REP + ] -
Threshold - 11.09.2016
For the first issue, it sounds like you may have multiple instances of that function running. Can you show us where you initiate the timer? As for the second, there was a slight issue with one of your format lines. I'm not sure which line you're referring to, but try this and see if it still occurs:
PHP код:
CMD:vyhodit(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, CHYBA, "[ Chyba ] Nemбte dostatečnб admin prбva!");
new
pplayerid, reason[48]
;
if(sscanf(params, "us[48]", pplayerid, reason)) return SendClientMessage(playerid, POUZITI, "[ Pouћitн ] Pouћitн: /vyhodit [ID] [DŮVOD]");
if(!IsPlayerConnected(pplayerid) || pplayerid == INVALID_PLAYER_ID) return SendClientMessage(playerid, CHYBA, "[ Chyba ] Hrбč nenн připojen!");
if(PlayerInfo[pplayerid][pAdmin] > 0) return SendClientMessage(playerid, CHYBA, "[ Chyba ] Nemůћete vyhodit člena admin tэmu!");
PlayerInfo[pplayerid][pKicks] ++;
new banma[144];
format(banma, sizeof(banma), "[ Administrace ] Admin %s vyhodil hrбče %s! [ %s ]", GetName(playerid), GetName(pplayerid), reason);
SendClientMessageToAll(ADMIN, banma);
format(banma, sizeof(banma), "[ Administrace ] Admin %s vбs vyhodil! [ %s ]", GetName(playerid), reason);
SendClientMessage(pplayerid, ADMIN, banma);
SetTimerEx("KickPlayer", 100, false, "i", pplayerid);
return 1;
}