Timer Question
#1

Why won't this work?

pawn Код:
public Timer(playerid, time)
{
    for(new x=time,x<=1,x--)
    {
        SetPlayerPos(playerid, 0, 0, 0);
    }
    return 1;
}
I set the time to a amount in another command and I want it to subtract from that amount as the milliseconds go on, but it isnt working...
Reply
#2

your time gets set to a value like 1000 (ms) or bigger? if so, you need to check for x being bigger than 0, not smaller, since its a decreasing loop:
pawn Код:
for(new x=time,x>0,x--)
Reply
#3

But I need x to get to zero and until it does I want the x to decrease, because I am setting the timer to 60000
Reply
#4

call the timer every second and then use:

pawn Код:
time--;
then,
pawn Код:
if(time == 0)
{
      //...
}
Reply
#5

So make it every 1000 milliseconds and make it repeat?
Reply
#6

may i ask how you are calling the timer? if you call it like
Timer(playerid,60000);
then the x=time will get x set to 60000, then in the loop, x changes to 59999 until it reaches 0. this will take some time (60000 x 1000 ms = 60000 seconds. thats 1000 minutes?)
now i woudl like to know how/when the next call happens. setting the timer to 1ms wont work btw. iam afraid youll need a different way to do whatever you want to do. setting a player position to blueberry acres, below ground, doesnt sound like a good idea btw.
now i have read the post again where you state that you call the timer with 1000 as parameter. this means, the timer snippet will set the players position 1000 times to 0,0,0? thats horrible. please let us know what you want to achieve with this. iam sure there are more clever methods to do whatever wou want.
using the GetTickCount() f.ex, saved me using a lot of timers (which take more CPU time than just calling 1 function to retrieve an always increasing server-runtime value (in ms) ).
if the player is supposed to do ANY action (pressing a key, typing a command, whatever), then the timer can be left out.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)