Timer problems
#1

Alright i made a timer for every player
so far, i have /work done
it goes like this:
/work (workid)
work id is random number (to stop macroers)
alright when a player re-connects (or if hes last one to type /work), the timer goes on for a minute then says "Work in progress"

Instead of every 10 seconds..

help? I've killed the timer @ connect, disconnect, /work, failed to work, finished working ETC.
Reply
#2

where is the code?
Reply
#3

Код:
if(strcmp(cmd,"/work",true) == 0)
	{
		if(Job[playerid] != ow) return 0; // 12 engineer 11 mineworker
		if(O[playerid] == 0) return scm(playerid,cr,"[ ! ] You are not at the Office!");
		if(Work[playerid] == 1) return SendClientMessage(playerid,cr,"[ ! ] Already working !");
		if(AlreadyRand[playerid] == 0)
		{
			Rand[playerid] = random(1400);
			AlreadyRand[playerid] = 1;
		}
		tmp = strtok(cmdtext,idx);
		if(!strlen(tmp))
		{
		  scm(playerid,cw,"[ ! ] USAGE: /work (workid)");
		  format(string,sizeof(string),"[ ! ] [HINT] Your work ID is %d",Rand[playerid]);
		  scm(playerid,COLOR_WHITE,string);
		  return 1;
		}
		moneys = strval(tmp);
		if(moneys != Rand[playerid])
		{
		  scm(playerid,cr,"[ ! ] Wrong work ID!");
		  return 1;
		}
		AlreadyRand[playerid] = 1;
		Work[playerid] = 1;
		omsg[playerid] = 0;
		SendClientMessage(playerid,COLOR_YELLOW,"[ ! ] ..:Work in progress:..");
		WorkingTimer[playerid] = SetTimerEx("Working",10000,1,"dd",playerid);
		return 1;
	}
Timer:

Код:
public Working(playerid)
{
	new moneys,string[128];
	switch(omsg[playerid])
	{
		case 0,1,2,3:
		{
			omsg[playerid]++;
			SendClientMessage(playerid,COLOR_YELLOW,"[ ! ] ..:Work in progress:..");
			if(O[playerid] == 0)
			{
			  Work[playerid] = 0;
			  omsg[playerid] = 0;
			  Rand[playerid] = random(1500);
				format(string,sizeof(string),"[ ! ] New work ID: %d",Rand[playerid]);
				scm(playerid,COLOR_GREEN,string);
			  KillTimer(WorkingTimer[playerid]);
				scm(playerid,cr,"[ ! ] You left the Office, job canceled !");
				return 1;
			}
		}
		case 4:
		{
			if(O[playerid] == 0)
			{
  				Work[playerid] = 0;
  				omsg[playerid] = 0;
  				Rand[playerid] = random(1500);
				format(string,sizeof(string),"[ ! ] New work ID: %d",Rand[playerid]);
				scm(playerid,COLOR_GREEN,string);
			  KillTimer(WorkingTimer[playerid]);
				scm(playerid,cr,"[ ! ] You left the Office, job canceled !");
				return 1;
			}
			moneys = Olvl[playerid];
			if(Olvl[playerid] == 0)
			{
				if(Work[playerid] == 0)
					return 1;
				Folder[playerid] = Folder[playerid] + 1;
				format(string,sizeof(string),"[ ! ] Work finished ! You get 1 folder !");
				SendClientMessage(playerid,COLOR_YELLOW,string);
				scm(playerid,cw,"[ ! ] [HINT] If you get 100 folders you can /archive them and get (/olvl) rcash each & get 1 extra folder every time you work");
				Work[playerid] = 0;
				omsg[playerid] = 0;
				Rand[playerid] = random(1500);
				format(string,sizeof(string),"[ ! ] New work ID: %d",Rand[playerid]);
				scm(playerid,COLOR_GREEN,string);
			  KillTimer(WorkingTimer[playerid]);
				return 1;
			}
			else
			{
				if(Work[playerid] == 0)
					return 1;
				Folder[playerid] = Folder[playerid] + moneys;
				format(string,sizeof(string),"[ ! ] Work finished ! You get %d folders !",moneys);
				SendClientMessage(playerid,COLOR_YELLOW,string);
        scm(playerid,cw,"[ ! ] [HINT] If you get 100 folders you can /archive them and get (/olvl) rcash each & get 1 extra folder every time you work");
				Work[playerid] = 0;
				omsg[playerid] = 0;
				Rand[playerid] = random(1500);
				format(string,sizeof(string),"[ ! ] New work ID: %d",Rand[playerid]);
				scm(playerid,COLOR_GREEN,string);
				KillTimer(WorkingTimer[playerid]);
				return 1;
			}
		}
	}
	return 1;
}
Reply
#4

pawn Код:
WorkingTimer[playerid] = SetTimerEx("Working",60000,1,"dd",playerid);
60000 ~= 1 min
Reply
#5

>.>

The bug is it goes every minute

What i WANT is every 10 secs.
Reply
#6

10000 and not 60000 then
Reply
#7

Omg ..

It is 10000
Reply
#8

BUMP
Reply
#9

Код:
WorkingTimer[playerid] = SetTimerEx("Working",1000,10,"dd",playerid);
try that
Reply
#10

That means it will say the message every second, and repeats 10 times.

And that wouldn't work, that's not how repeating works..

Код:
repeating	Boolean if the timer should occur repeatedly or only once
Reply


Forum Jump:


Users browsing this thread: