SA-MP Forums Archive
Timer problems - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Timer problems (/showthread.php?tid=154035)



Timer problems - coole210 - 12.06.2010

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.


Re: Timer problems - (SF)Noobanatior - 12.06.2010

where is the code?


Re: Timer problems - coole210 - 12.06.2010

Код:
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;
}



Re: Timer problems - (SF)Noobanatior - 12.06.2010

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


Re: Timer problems - coole210 - 12.06.2010

>.>

The bug is it goes every minute

What i WANT is every 10 secs.


Re: Timer problems - Kar - 12.06.2010

10000 and not 60000 then


Re: Timer problems - coole210 - 12.06.2010

Omg ..

It is 10000


Re: Timer problems - coole210 - 12.06.2010

BUMP



Re: Timer problems - Kar - 13.06.2010

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


Re: Timer problems - coole210 - 13.06.2010

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