SA-MP Forums Archive
countdown - 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: countdown (/showthread.php?tid=377326)



countdown - thefatshizms - 13.09.2012

How can i make a countdown and display how long left on a textdraw? i kinda failed (countdwon was from 12 but only went to 11)


Re: countdown - Glint - 13.09.2012

Show us what you did till now.


Re: countdown - Djole1337 - 13.09.2012

Oops nvm
-deleted


Re: countdown - xMCx - 13.09.2012

Post your code to check the issues


Re: countdown - thefatshizms - 16.09.2012

pawn Код:
new countn[MAX_PLAYERS];//It will count down,or normally,as you choose..
forward TimerName(playerid);//This is the function that will define the timer
new timer[MAX_PLAYERS];//This is the name of the timer,but there's one particulary for every player,as if we want to destroy it,it won't destroy for everyone

COMMAND:starttimer(playerid,params[])
{
   countn[playerid]=10;//It will count for 10 seconds
  timer[playerid]=SetTimerEx("TimerName",1000,true,"i",playerid);/We set the timer for 10 seconds,as you can see
 return 1;
}

//We now define the timer,like this:

public TimerName(playerid)
{
   countn[playerid]--;//The timer decreases from 10 to 0
   if(countn[playerid]>=-1)
  {
     KillTimer(timer[playerid]);
     //code[What your timer actually does]
   }
 return 1;
}
Not my code found on ****** but got like 5 errors anyone can tell the correct way of doing this?


Re: countdown - Vince - 16.09.2012

If you'd follow the code path, you'd spot the obvious error very easily:
pawn Код:
countn[playerid]--;//The timer decreases from 10 to 0
if(countn[playerid]>=-1)
{
    KillTimer(timer[playerid]);
    //code[What your timer actually does]
}
- countn is decreased from 12 to 11.
- Reached if statement: if (11 >= -1) returns true
- KillTimer

You want point two to return false. So change the operator around from >= to <=.


Re: countdown - thefatshizms - 16.09.2012

/facepalm that was a stupid mistake thanks anyway : thumbs up: