SA-MP Forums Archive
Timer or Tickcount ? - 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)
+--- Thread: Timer or Tickcount ? (/showthread.php?tid=435577)



Timer or Tickcount ? - Zex Tan - 07.05.2013

Hello, I'm creating a weed command, but I'm not sure should I use SetTimer or GetTickcount.

Example, Player A has weed, then it should have a timer to wait for it to grow. Weed is able to be taken when it is ready, and anyone could TAKE IT. How am I going to let anyone to pick weed ?


Re: Timer or Tickcount ? - Yashas - 07.05.2013

A timer that will increment the content of the weed.

Like this
Код:
forward UpdateWeeds(playerid);
SetTimerEx("UpdateWeeds",1000,1,"i",playerid);

public UpdateWeeds(playerid)
{
    PlayerWeeds[playerid][weed1][content]++;
    PlayerWeeds[playerid][weed2][content]++;
}



Re: Timer or Tickcount ? - Pottus - 07.05.2013

Don't use a timer that is not needed GetTickCount() is better you don't need to increment the progress it can be determined by how much time has passed which will actually end up being more efficient.


Re: Timer or Tickcount ? - Yashas - 07.05.2013

K I get what you you are trying.

A GetTickCount() - TimePlanted divided by the INCREMENT_VALUE so that you get whats there in it
Nice!!

So the usage will be

Код:
new i = (GetTickCount() - OnTickWhenItWasPlanted) / 1000; //By 1000 to get it in seconds or you can define INCREMENT as 2000 for 2 seconds or and remove that division
i /= INCREMENT; //for example, if you wanted it to increase 2 every second.



Re: Timer or Tickcount ? - Zex Tan - 07.05.2013

O.. okay thanks alot

Will it work for every player that wants it?


Re: Timer or Tickcount ? - Yashas - 07.05.2013

yes, you must have a new variable for each plant for each player to hold the tick when the plant was planted.And dont forget to GetTickCount() when player plants.It will work for all the players.