countdown
#1

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

Show us what you did till now.
Reply
#3

Oops nvm
-deleted
Reply
#4

Post your code to check the issues
Reply
#5

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

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)