[HELP] CountDown For Player - Larsey123IsMe - 14.12.2010
It is bugged =/ i can compile it, but nothing happends
pawn Код:
#include <a_samp>
new count;
forward Count(playerid);
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/countdown", cmdtext, true, 10) == 0)
{
count = SetTimer("Count", 1000, false);
SendClientMessage(playerid, 0x94FF00FF, "Countdown started");
return 1;
}
return 0;
}
pawn Код:
public Count(playerid)
{
new counter = 120, string[10];
counter--;
format(string, sizeof(string),"~b~%d", counter);
GameTextForPlayer(playerid, string, 300, 3);
if(counter == 0)
{
format( string, sizeof(string), "~g~2 minutes have passed!!!");
GameTextForPlayer(playerid, string, 300, 3);
KillTimer(count);
}
return 1;
}
Re: [HELP] CountDown For Player -
JaTochNietDan - 14.12.2010
You're putting the counter variable in the local scope of the public function, which is initialized again each time the timer is called, therefore losing it's value each time, and not counting down at all. You need to define it in a global scope.
pawn Код:
#include <a_samp>
new count, counter = 120;
forward Count(playerid);
pawn Код:
public Count(playerid)
{
new string[10];
counter--;
format(string, sizeof(string),"~b~%d", counter);
GameTextForPlayer(playerid, string, 300, 3);
if(counter == 0)
{
format( string, sizeof(string), "~g~2 minutes have passed!!!");
GameTextForPlayer(playerid, string, 300, 3);
KillTimer(count);
}
return 1;
}
Also in your command you have set the timer to
not repeat, I believe you need it to repeat for your snippet of code to work as intended.
Re: [HELP] CountDown For Player - Larsey123IsMe - 14.12.2010
Thanks but it dont countdown

i need to spam /countdown to get to to countdow =/
Re: [HELP] CountDown For Player -
JaTochNietDan - 14.12.2010
Yes did you read my post? You have set the timer to
not repeat, you need to set it to repeat.
pawn Код:
count = SetTimer("Count", 1000, true); // We use "true" to specify it to repeat
Re: [HELP] CountDown For Player - Larsey123IsMe - 14.12.2010
=/ Yes i readed the post, but dident understand, my english is not good
anyway!!! THANK YOU!
Re: [HELP] CountDown For Player - Larsey123IsMe - 14.12.2010
And... Last question about countdown... how to add "Countdown already started" if the countdown is started?
Re: [HELP] CountDown For Player -
Nero_3D - 14.12.2010
Just check when the counter variable isnt zero
pawn Код:
#include <a_samp>
new count, counter;
forward Count(playerid);
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/countdown", cmdtext, true, 10) == 0)
{
if(counter != 0)
{
SendClientMessage(playerid, 0x94FF00FF, "Countdown already started!");
return 1;
}
SendClientMessage(playerid, 0x94FF00FF, "Countdown started");
count = SetTimer("Count", 1000, true);
counter = 120;
return 1;
}
return 0;
}
pawn Код:
public Count(playerid)
{
if((--counter) == 0)
{
GameTextForPlayer(playerid, "~g~2 minutes have passed!!!", 300, 3);
KillTimer(count);
} else {
new string[10];
format(string, sizeof(string), "~b~%d", counter);
GameTextForPlayer(playerid, string, 300, 3);
}
return 1;
}
Re: [HELP] CountDown For Player -
XePloiT - 14.12.2010
here is count down i've made long time ago... maybe you can use this...
pawn Код:
new count1,rCD=0;
forward CountDown(playerid,Time);
CMD:cd(playerid,params[])
{
new tt;
if(sscanf(params,"i",tt)) return SendClientMessage(playerid,COLOR_WHITE,"How To Use: /Cd [ Time ]");
if(rCD==0)
{
rCD=1;
return SetTimerEx("CountDown", 1000, false, "ii", playerid, tt);
}
rCD=0;
return SendClientMessage(playerid,COLOR_WHITE,"CountDown Running Wait 'till its done");
}
public CountDown(playerid,Time)
{
if(Time==0) //under this if you can put what ever you want to happend
{
KillTimer(count1);
return SendClientMessage(playerid,COLOR_WHITE,"The Time Has Passed");
}
new str[128];
format(str,sizeof(str),"~b~%d Seconds Has Left.",Time);
GameTextForAll(str,1000,3);
return count1=SetTimerEx("CountDown", 1000, false, "ii", playerid, Time-1);
}
EDIT: oh sorry didn't saw that someone already helped you...