Timer error in my gamemode??! :O [ REP + ]
#1

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:43 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.
Reply
#2

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(playeridparams[])
{
    if(
PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playeridCHYBA"[ Chyba ] Nemбte dostatečnб admin prбva!");
    new
        
pplayeridreason[48]
    ;
    if(
sscanf(params"us[48]"pplayeridreason)) return SendClientMessage(playeridPOUZITI"[ Pouћitн ] Pouћitн: /vyhodit [ID] [DŮVOD]");
    if(!
IsPlayerConnected(pplayerid) || pplayerid == INVALID_PLAYER_ID) return SendClientMessage(playeridCHYBA"[ Chyba ] Hrбč nenн připojen!");
    if(
PlayerInfo[pplayerid][pAdmin] > 0) return SendClientMessage(playeridCHYBA"[ Chyba ] Nemůћete vyhodit člena admin tэmu!");
    
PlayerInfo[pplayerid][pKicks] ++;
    new 
banma[144];
    
format(banmasizeof(banma), "[ Administrace ] Admin %s vyhodil hrбče %s! [ %s ]"GetName(playerid), GetName(pplayerid), reason);
    
SendClientMessageToAll(ADMINbanma);
    
format(banmasizeof(banma), "[ Administrace ] Admin %s vбs vyhodil! [ %s ]"GetName(playerid), reason);
    
SendClientMessage(pplayeridADMINbanma);
    
SetTimerEx("KickPlayer"100false"i"pplayerid);
    return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)