Simple counting in textdraw
Well, a few months ago, I made a count in textdraw with main idea of GTA V.
Sample: https://imgur.com/PTEFT3V
Let's do it
Code:
//At first
#include a_samp
#include zcmd
#define BGColour -1
new
Global_countdown[4],
Text:TextDraw_countdown[2];
In OnGameModeInit
Code:
public OnGameModeInit()
{
TextDraws();
return 1;
}
In the command
Code:
CMD:conteo(playerid, params[])
{
if(sscanf(params, "d", params[0]))
return SendClientMessage(playerid,-1, "{999999} Use /countdown [SECONDS] >> example: /countdown 4");
if(params[0] < 3 || params[0] > 10)
return SendClientMessage(playerid,-1, "{999999}The seconds for a countdown, are between (3 - 10).");
if(Global_countdown[2] > 0 || Global_countdown[2] == -1)
return SendClientMessage(playerid,-1, "{999999}Countdown in progress."),PlayerPlaySound(playerid,1085,0.0,0.0,0.0);
new string1[650];
format(string1,sizeof(string1),"{F0F0F0}** %s start a countdown of a (%d) seconds.",PlayerName(playerid),params[0]);
SendClientMessageToAll(-1,string1);
Global_countdown[3] = SetTimer("ConteoA", 1000, true);
Global_countdown[2] = params[0];
new string[10];
format(string, sizeof(string), "%d", Global_countdown[2]);
TextDrawSetString(TextDraw_countdown[0], string);
TextDrawShowForAll(TextDraw_countdown[0]);
TextDrawShowForAll(TextDraw_countdown[1]);
PlayerPlaySoundForAll(1056, 0.0, 0.0, 0.0);
return 1;
}
At the end
Code:
stock TextDraws()
{
TextDraw_countdown[0] = TextDrawCreate(320.000396, 100.499938, "5");
TextDrawLetterSize(TextDraw_countdown[0], 0.783118, 3.017499);
TextDrawTextSize(TextDraw_countdown[0], 145.241561, 303.916381);
TextDrawAlignment(TextDraw_countdown[0], 2);
TextDrawColor(TextDraw_countdown[0], -1);
TextDrawSetShadow(TextDraw_countdown[0], 0);
TextDrawSetOutline(TextDraw_countdown[0], 1);
TextDrawBackgroundColor(TextDraw_countdown[0], 51);
TextDrawFont(TextDraw_countdown[0], 3);
TextDrawSetProportional(TextDraw_countdown[0], 1);
TextDraw_countdown[1] = TextDrawCreate(291.250000, 94.499923, "ld_pool:ball");
TextDrawLetterSize(TextDraw_countdown[1], 0.449999, 1.600000);
TextDrawTextSize(TextDraw_countdown[1], 56.250000, 43.750015);
TextDrawAlignment(TextDraw_countdown[1], 1);
TextDrawColor(TextDraw_countdown[1], 65535);
TextDrawSetShadow(TextDraw_countdown[1], 0);
TextDrawSetOutline(TextDraw_countdown[1], 1);
TextDrawBackgroundColor(TextDraw_countdown[1], BGColour);
TextDrawFont(TextDraw_countdown[1], 4);
TextDrawSetProportional(TextDraw_countdown[1], 1);
return 1;
}
forward ConteoA();
public ConteoA()
{
if(Global_countdown[2] == -1)
{
TextDrawHideForAll(TextDraw_countdown[0]);
TextDrawHideForAll(TextDraw_countdown[1]);
TextDrawSetString(TextDraw_countdown[0], "~y~10");
TextDrawTextSize(TextDraw_countdown[0], 145.241561, 300.916381);
KillTimer(Global_countdown[3]);
Global_countdown[3] = 0;
Global_countdown[2] = 0;
return 1;
}
Global_countdown[2]--;
if(Global_countdown[2] != 0)
{
switch(Global_countdown[2])
{
case 9:
{
TextDrawShowForAll(TextDraw_countdown[1]);
TextDrawSetString(TextDraw_countdown[0], "~w~9");
TextDrawTextSize(TextDraw_countdown[0], 135.241561, 290.916381);
TextDrawShowForAll(TextDraw_countdown[0]);
PlayerPlaySoundForAll(1056, 0.0, 0.0, 0.0);
}
case 8:
{
TextDrawSetString(TextDraw_countdown[0], "~w~8");
TextDrawTextSize(TextDraw_countdown[0], 125.241561, 270.916381);
TextDrawShowForAll(TextDraw_countdown[0]);
PlayerPlaySoundForAll(1056, 0.0, 0.0, 0.0);
}
case 7:
{
TextDrawSetString(TextDraw_countdown[0], "~w~7");
TextDrawTextSize(TextDraw_countdown[0], 115.241561, 250.916381);
TextDrawShowForAll(TextDraw_countdown[0]);
PlayerPlaySoundForAll(1056, 0.0, 0.0, 0.0);
}
case 6:
{
TextDrawSetString(TextDraw_countdown[0], "~w~6");
TextDrawTextSize(TextDraw_countdown[0], 105.241561, 230.916381);
TextDrawShowForAll(TextDraw_countdown[0]);
PlayerPlaySoundForAll(1056, 0.0, 0.0, 0.0);
}
case 5:
{
TextDrawSetString(TextDraw_countdown[0], "~w~5");
TextDrawTextSize(TextDraw_countdown[0], 95.241561, 210.916381);
TextDrawShowForAll(TextDraw_countdown[0]);
PlayerPlaySoundForAll(1056, 0.0, 0.0, 0.0);
}
case 4:
{
TextDrawSetString(TextDraw_countdown[0], "~w~4");
TextDrawTextSize(TextDraw_countdown[0], 85.241561, 190.916381);
TextDrawShowForAll(TextDraw_countdown[0]);
PlayerPlaySoundForAll(1056, 0.0, 0.0, 0.0);
}
case 3:
{
TextDrawSetString(TextDraw_countdown[0], "~w~3");
TextDrawTextSize(TextDraw_countdown[0], 75.361633, 170.416439);
TextDrawShowForAll(TextDraw_countdown[0]);
PlayerPlaySoundForAll(1056, 0.0, 0.0, 0.0);
}
case 2:
{
TextDrawSetString(TextDraw_countdown[0], "~w~2");
TextDrawTextSize(TextDraw_countdown[0], 65.241561, 150.916381);
TextDrawShowForAll(TextDraw_countdown[0]);
PlayerPlaySoundForAll(1056, 0.0, 0.0, 0.0);
}
case 1:
{
TextDrawSetString(TextDraw_countdown[0], "~w~1");
TextDrawTextSize(TextDraw_countdown[0], 55.241561, 130.916381);
TextDrawShowForAll(TextDraw_countdown[0]);
PlayerPlaySoundForAll(1056, 0.0, 0.0, 0.0);
}
}
}
else if(Global_countdown[2] == 0)
{
TextDrawSetString(TextDraw_countdown[0], "~w~0!");
TextDrawTextSize(TextDraw_countdown[0], 145.241561, 300.916381);
TextDrawShowForAll(TextDraw_countdown[0]);
PlayerPlaySoundForAll(1057,0.0,0.0,0.0);
Global_countdown[2] = -1;
}
return 1;
}