Countdown backwards help - 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: Countdown backwards help (
/showthread.php?tid=113975)
Countdown backwards help -
wilcock33 - 16.12.2009
hi all,
i have a prob with my new years timer!
i want it to count down from 60, but the one i made (BY ACCIDENT
) counts from 0 to 60
can anyone help me change it?
here it is:
Код:
#define FILTERSCRIPT
#include <a_samp>
new counter;
new countTimer;
forward timer();
#if defined FILTERSCRIPT
public OnFilterScriptInit()
{
counter = 0;
return 1;
}
public OnFilterScriptExit()
{
counter = 0;
return 1;
}
#else
main()
{
print("\n------------------------------------------");
print(" NewYearCountdown Script");
print("------------------------------------------\n");
}
#endif
public OnPlayerConnect(playerid)
{
SendClientMessage(playerid, 0xFF00FF,"Welcome to the New Year's Party!");
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/count", true) || !strcmp(cmdtext, "/countdown", true))
{
if(counter != 0)
return SendClientMessage(playerid, 0xFFFF00FF, "The new-year countdown is already running...print what till next year!");
countTimer = SetTimer("timer", 1000, true);
return true;
}
return 0;
}
public timer()
{
new string[3];
counter++;
if(counter > 0 && counter < 60)
{
format(string, sizeof(string), "%d", counter);
GameTextForAll(string, 500, 3);
}
else
{
GameTextForAll("HAPPY NEW YEAR 2010!!!", 5000, 4);
counter = 0;
KillTimer(countTimer);
}
return true;
}
thanks everyone, merry christmmas!!!
Re: Countdown backwards help -
bigcomfycouch - 17.12.2009
Код:
#define FILTERSCRIPT
#include <a_samp>
new counter;
new countTimer;
forward timer();
#if defined FILTERSCRIPT
public OnFilterScriptInit()
{
counter = 0;
return 1;
}
public OnFilterScriptExit()
{
counter = 0;
return 1;
}
#else
main()
{
print("\n------------------------------------------");
print(" NewYearCountdown Script");
print("------------------------------------------\n");
}
#endif
public OnPlayerConnect(playerid)
{
SendClientMessage(playerid, 0xFF00FF,"Welcome to the New Year's Party!");
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/count", true) || !strcmp(cmdtext, "/countdown", true))
{
if(counter != 0)
return SendClientMessage(playerid, 0xFFFF00FF, "The new-year countdown is already running...print what till next year!");
counter = 60;
countTimer = SetTimer("timer", 1000, true);
return true;
}
return 0;
}
public timer()
{
if(counter > 0)
{
new string[3];
format(string, sizeof(string), "%d", counter);
GameTextForAll(string, 500, 3);
}
else
{
GameTextForAll("HAPPY NEW YEAR 2010!!!", 5000, 4);
counter = 0;
KillTimer(countTimer);
}
counter--;
return true;
}