SA-MP Forums Archive
Stop a 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Stop a countdown!! (/showthread.php?tid=194501)



Stop a countdown!! - BlackWolf120 - 29.11.2010

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.


Re: Stop a countdown!! - [MNC]Azz - 29.11.2010

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


Re: Stop a countdown!! - BlackWolf120 - 29.11.2010

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.


Re: Stop a countdown!! - [MNC]Azz - 29.11.2010

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;
}



Re: Stop a countdown!! - BlackWolf120 - 30.11.2010

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???



Re: Stop a countdown!! - [MNC]Azz - 30.11.2010

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


Re: Stop a countdown!! - Mean - 02.12.2010

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;
}



Re: Stop a countdown!! - BlackWolf120 - 02.12.2010

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


Re: Stop a countdown!! - BlackWolf120 - 03.12.2010

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);



Re: Stop a countdown!! - BlackWolf120 - 03.12.2010

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


Re: Stop a countdown!! - BlackWolf120 - 04.12.2010

no scripter knows how to do that


Re: Stop a countdown!! - BlackWolf120 - 04.12.2010

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


Re: Stop a countdown!! - PowerPC603 - 04.12.2010

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


Re: Stop a countdown!! - BlackWolf120 - 05.12.2010

hi,
thank u again