Stop a countdown!!
#1

hi,
ive created a countdown that appears on screen for all players:

pawn Код:
forward counter(playerid);
new countdown = 60;
new CDONSTimer;

public counter(playerid)
{

if(countdown > 1)
{
new string[128];
format(string,sizeof(string),"~l~! ~r~Detonating: ~y~%d ~l~!",countdown);
GameTextForAll(string,990,5);
SetTimer("counter",990,0);
countdown --;
}
else
{

countdown = 0;
}
return 1;
}
It counts backwards from 60 sec but how can i stop the text countdown on screen from continuing counting?
I did :

KillTimer(CDONSTimer);

But the countdown still continues!!

Pls help.

regards.
Reply
#2

pawn Код:
forward counter(playerid);
new countdown = 60;
new CDONSTimer;

public counter(playerid)
{

if(countdown > 1)
{
new string[128];
format(string,sizeof(string),"~l~! ~r~Detonating: ~y~%d ~l~!",countdown);
GameTextForAll(string,990,5);
CDONSTimer = SetTimer("counter",990,0);
countdown --;
}
else
{
KillTimer(CDONSTimer);
countdown = 0;
}
return 1;
}
i think it would be this...
Reply
#3

hi,
thx for ur fast answer!
There is a checkpoint in the game and i want it to stop the on screen countdown after 15 secs after u enter it.
The other actions that shall happen at the same time after stayed in the cp for 15sec are executed but not the countdown kill. So u think its allright to write the killtimer under the else command?
Im not able to test it right now, but i m gonna try it as soon as i can.
thx.
regards.
Reply
#4

so u want to kill the timer in 15 secs after the player enters the checkpoint?

pawn Код:
OnPlayerEnterCheckpoint(playerid)
{
SendClientMessage(playerid,TEXTCOLOURID,"Stay in this checkpoint for 15 seconds to disable the CountDown!");
SetTimer("KillCount",15000,false);
return 1;
}

forward KillCount();
public KillCount()
{
KillTimer(CDONSTimer);
SendClientMessage(playerid,TEXTCOLOURID,"Countdown stopped!!!");
return 1;
}
Reply
#5

hi,
no matter what i try
just cant stop this timer
I hope u can help me
Also the countdown starts only the first time, the second time it is started it just doesnt appear on the screen.
Why?
I did the KillTimer command there where i want it to be stopped but the counting goes on!!

pawn Код:
public counter(playerid)
{

if(countdown > 1)
{
new string[128];
format(string,sizeof(string),"~l~! ~r~Detonating: ~y~%d ~l~!",countdown);
GameTextForAll(string,990,5);
SetTimer("counter",990,0);
countdown --;
}
else
{

countdown = 0;
}
return 1;
}

CDONSTimer = SetTimer("counter",990,0); //i defined the timer and later i kill it with...
KillTimer(CDONSTimer); //this so whats wrong???
Reply
#6

Quote:
Originally Posted by BlackWolf120
Посмотреть сообщение
pawn Код:
public counter(playerid)
{

if(countdown > 1)
{
new string[128];
format(string,sizeof(string),"~l~! ~r~Detonating: ~y~%d ~l~!",countdown);
GameTextForAll(string,990,5);
CDONSTimer = SetTimer("counter",990,0);
countdown --;
}
else
{

countdown = 0;
}
return 1;
}

CDONSTimer = SetTimer("counter",990,0); //i defined the timer and later i kill it with...
KillTimer(CDONSTimer); //this so whats wrong???
u might wanna put CDONSTimer = SetTimer("counter",990,0); under if(countdown > 1) like I showed u in my previous reply... coz if not it will start a completely different timer.... than it should work...
Reply
#7

just lol


pawn Код:
forward counter(playerid);
new countdown = 60;
new CDONSTimer;
new EndTimer;

public counter(playerid)
{

if(countdown > 1)
{
new string[128];
format(string,sizeof(string),"~l~! ~r~Detonating: ~y~%d ~l~!",countdown);
GameTextForAll(string,990,5);
SetTimer("counter",990,0);
countdown --;
forward EndTimer(playerid);
SetTimer("EndTimer", 15000, 0);
return 1;
}
pawn Код:
public EndTimer(playerid)
{
      KillTimer(counter);
      return 1;
}
Reply
#8

error 076: syntax error in the expression, or invalid function call

there is an error:

pawn Код:
public EndTimer(playerid)
{
      KillTimer(counter);   //here
      return 1;
}
please help me.
U loled at me now u have to help me
Reply
#9

Hi,
thank u it works now, but the second time the timer is started it continues to count down from e.g 23 sec if it has been aborted (killed at the time the timer was on 23 sec). But i want it to start from 60 secs again and not from the last aborted time.

I looked at it for 10 mins and simply dont get it

pawn Код:
public counter(playerid)
{

if(countdown > 1)
{
CDONSTimer = SetTimer("counter",990,0);
new string[128];
format(string,sizeof(string),"~l~! ~r~Detonating: ~y~%d ~l~!",countdown);
GameTextForAll(string,990,5);

countdown --;
}
else
{

countdown = 0;
}
return 1;
}


forward counter(playerid);
new countdown = 60;
new CDONSTimer;

CDONSTimer = SetTimer("counter",990,0);
KillTimer(CDONSTimer);
Reply
#10

Please this is very important.
I want that the timer restarts counting from beginning (from 60 sec)
again if it started after it had been aborted once.
please help me
Reply
#11

no scripter knows how to do that
Reply
#12

ok, i solved this problem.

but ive got another question:

how to display this countdown to only one player.
Because now everybody can see the countdown.

pawn Код:
public counterzone(playerid)
{

if(countdownzone > 0)
{
CDONZone = SetTimer("counterzone",990,0);
new string[128];
format(string,sizeof(string),"~g~%d",countdownzone);
GameTextForAll(string,990,5); //here: GameTextForPlayer would be right? But how to do that with this funktion?

countdownzone --;
}
else
{

countdownzone = 0;
}
return 1;
}
regards..
Reply
#13

Instead of using SetTimer, you can use SetTimerEx. Then you can supply a parameter to the timer:
Код:
SetTimerEx("counterzone",990,0, "i", playerid);
https://sampwiki.blast.hk/wiki/SetTimerEx
Reply
#14

hi,
thank u again
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)