25.07.2013, 10:51
Hello eveyone how can i make cowntdown with 3dlabel? 5 4 3 2 1.
Thanks
Thanks

new Text3D:cdlabel[MAX_PLAYERS];
new labeltimer[MAX_PLAYERS];
new labelcount[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
labelcount[playerid] = 0;
return 1;
}
CMD:countdown(playerid, params[])
{
if(labelcount[playerid] > 0) return SendClientMessage(playerid, 0xFF0000FF, "You already have a countdown running!");
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z); //Get player's position
cdlabel[playerid] = Create3DTextLabel("Counting Down...\n5", 0x00FF00FF, x, y, z, 30.0, GetPlayerVirtualWorld(playerid), 0);
labelcount[playerid] = 5;
labeltimer[playerid] = SetTimerEx("CountdownLabel", 1000, true, "i", playerid);
SendClientMessage(playerid, 0xFFFF00FF, "The countdown has started.");
return 1;
}
forward CountdownLabel(playerid);
public CountdownLabel(playerid)
{
if(labelcount[playerid] == 0)
{
Destroy3DTextLabel(cdlabel[playerid]);
KillTimer(labeltimer[playerid]);
return 1;
}
if(labelcount[playerid] < 2)
{
labelcount[playerid] = 0;
Update3DTextLabelText(cdlabel[playerid], 0x00FF00FF, "Counting Down...\n{FF0000}GO!");
}
else
{
labelcount[playerid]--;
new fstr[30];
format(fstr, sizeof(fstr), "Counting Down...\n{FFFF00}%d", labelcount[playerid]);
Update3DTextLabelText(cdlabel[playerid], 0x00FF00FF, fstr);
}
return 1;
}