Timer or Tickcount ?
#1

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 ?
Reply
#2

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]++;
}
Reply
#3

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.
Reply
#4

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.
Reply
#5

O.. okay thanks alot

Will it work for every player that wants it?
Reply
#6

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)