Countdown in area help (textdraw) -
Virtual1ty - 30.04.2010
Ai, so i need some help with my countdown system, I want the countdown to be shown for "all" the players in a certain range I defined.
The problem is, the textdraw doesn't even show. I really dunno where's the problem.
Heres the code:
Top:
pawn Код:
forward Countdown(Float:range, Float:x, Float:y, Float:z);
new CountDown[MAX_PLAYERS];
new CountDownTimer[MAX_PLAYERS];
new bool:auts;
OnGameModeInit:
pawn Код:
//Textdraw by RenisiL
Textdraw0 = TextDrawCreate(264.000000,367.000000,"~w~- ~r~C~r~~h~o~r~u~r~~h~n~r~t~r~~h~D~r~o~r~~h~w~r~n ~w~-");
TextDrawAlignment(Textdraw0, 0);
TextDrawBackgroundColor(Textdraw0, 0x000000ff);
TextDrawFont(Textdraw0, 1);
TextDrawLetterSize(Textdraw0, 0.399999, 1.300000);
TextDrawColor(Textdraw0, 0xffffffff);
TextDrawSetOutline(Textdraw0, 1);
TextDrawSetProportional(Textdraw0, 1);
TextDrawSetShadow(Textdraw0, 1);
for(new i = 0; i < MAX_PLAYERS; i++)
{
Textdraw1[i] = TextDrawCreate(304.000000, 384.000000, "_");
TextDrawAlignment(Textdraw1[i], 0);
TextDrawBackgroundColor(Textdraw1[i], 0x000000ff);
TextDrawFont(Textdraw1[i], 3);
TextDrawLetterSize(Textdraw1[i], 0.699999, 1.400000);
TextDrawColor(Textdraw1[i], 0xffffffff);
TextDrawSetOutline(Textdraw1[i], 1);
TextDrawSetProportional(Textdraw1[i], 1);
TextDrawSetShadow(Textdraw1[i], 1);
}
Middl:
pawn Код:
COMMAND:count(playerid, params[])
{
new string[128],
sendername[MAX_PLAYER_NAME],
Float:x, Float:y, Float:z,
time;
if(sscanf(params, "d", time)) return SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /count [time in seconds]");
if(time < 2 || time > 30) return SendClientMessage(playerid, COLOR_GRAD2, " Time not greater than 30 seconds, nor below 1 second!");
if(auts == false)
{
auts = true;
CountDown[playerid] = time;
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "* %s started a countdown.", sendername);
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
GetPlayerPos(playerid, x,y,z);
CountDownTimer[playerid] = SetTimerEx("Countdown", 1000, true, "iffff", playerid,20.0,x,y,z);
}
else
{
SendClientMessage(playerid, 0xFF9900AA, "Another countdown is currently in progress, please wait!");
}
return 1;
}
At the end:
pawn Код:
////////////////////////////////////////////////////////////////////////////////
function Countdown(Float:range, Float:x, Float:y, Float:z)
{
new string[64];
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerInRangeOfPoint(i, range, x,y,z))
{
if(CountDown[i] > 0 && CountDown[i] < 31)
{
TogglePlayerControllable(i, 0);
format(string, sizeof(string), "%d", CountDown[i]);
TextDrawSetString(Textdraw1[i], string);
TextDrawShowForPlayer(i, Textdraw1[i]);
TextDrawShowForPlayer(i, Textdraw0);
CountDown[i]--;
}
else if(CountDown[i] >= -1) { KillTimer(CountDownTimer[i]); EndCountdown(i); }
else
{
auts = false;
KillTimer(CountDownTimer[i]);
TogglePlayerControllable(i, 1);
PlayerPlaySound(i, 1057, x, y, z);
TextDrawSetString(Textdraw1[i], "~g~Go!!");
SetTimerEx("EndCountdown", 500, false, "i", i);
}
}
}
}
function EndCountdown(playerid)
{
TextDrawHideForPlayer(playerid, Textdraw1[playerid]);
TextDrawHideForPlayer(playerid, Textdraw0);
}
////////////////////////////////////////////////////////////////////////////////
Re: Countdown in area help (textdraw) -
Nero_3D - 30.04.2010
maybe because you pass 5 parameter with settimerex (playerid, range, x, y, z) but the function countdown only has 4
And the whole script is kind of messy and full with a lot of unused code :S
pawn Код:
new bool:auts;
new Text:T_Countdown;
pawn Код:
//Textdraw by RenisiL
T_Countdown= TextDrawCreate(264.000000,367.000000,"~w~- ~r~C~r~~h~o~r~u~r~~h~n~r~t~r~~h~D~r~o~r~~h~w~r~n ~w~-");
TextDrawLetterSize(T_Countdown, 0.399999, 1.300000);
TextDrawBackgroundColor(T_Countdown, 0x000000ff);
TextDrawSetProportional(T_Countdown, 1);
TextDrawColor(T_Countdown, 0xffffffff);
TextDrawSetOutline(T_Countdown, 1);
TextDrawAlignment(T_Countdown, 0);
TextDrawSetShadow(T_Countdown, 1);
TextDrawFont(T_Countdown, 1);
pawn Код:
COMMAND:count(playerid, params[])
{
new
time;
if(sscanf(params, "d", time)) return SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /count [time in seconds]");
if(time < 1 || time > 30) return SendClientMessage(playerid, COLOR_GRAD2, " Time not greater than 30 seconds, nor below 1 second!");
if(auts == true) return SendClientMessage(playerid, 0xFF9900AA, "Another countdown is currently in progress, please wait!");
new
string[128],
Float:x,
Float:y,
Float:z;
GetPlayerPos(playerid, x, y, z);
GetPlayerName(playerid, string, MAX_PLAYER_NAME);
format(string, sizeof(string), "* %s started a countdown.", sendername);
for(new i; i != MAX_PLAYERS; i++)
{
if(IsPlayerInRangeOfPoint(i, 25.0, x, y, z))
{
TogglePlayerControllable(i, false);
TextDrawShowForPlayer(i, T_Countdown);
SendClientMessage(i, COLOR_PURPLE, string);
}
}
SetTimerEx("Countdown", 1000, false, "iffff", time, 25.0, x, y, z);
return (auts = true);
}
pawn Код:
forward Countdown(time, Float:range, Float:x, Float:y, Float:z);
function Countdown(time, Float:range, Float:x, Float:y, Float:z)
{
if(time != 0)
{
new
string[5];
format(string, sizeof(string), "%d", time--);
TextDrawSetString(T_Countdown, string);
SetTimerEx("Countdown", 1000, false, "iffff", time, 25.0, x, y, z);
} else {
for(new i; i != MAX_PLAYERS; i++)
{
if(IsPlayerInRangeOfPoint(i, range, x, y, z))
{
TogglePlayerControllable(i, true);
PlayerPlaySound(i, 1057, x, y, z);
TextDrawHideForPlayer(i, T_Countdown);
GameTextForPlayer(i, "~g~Go!!", 2500, 6);
}
}
TextDrawSetString(T_Countdown, "~w~- ~r~C~r~~h~o~r~u~r~~h~n~r~t~r~~h~D~r~o~r~~h~w~r~n ~w~-");
auts = false;
}
}
ads while tv can be used to something
Re: Countdown in area help (textdraw) -
Virtual1ty - 30.04.2010
Yes I'm aware there's alot of chunk code in there, thank you so much, I'll test it ASAP, thanks again!!