04.07.2013, 16:49
A few things:
1) You can set the bool to either true or false in the define line itself instead of "falsing" it right after.
2) No need to set the reloading bool to true INSIDE the loop, better to place that right after.
3) In commands/loops/etc you can also if(variable) INCASE it's a boolean, instead of if(variable == true), for false you can use if(!variable) instead of if(reloading == false).
4) I guess you forgot to define the pName variable(?)
4) I guess you forgot to define the string variable(?) - AVOID from using strings that are more than 124 bits.
5) I narrowed the whole code as I like in order to provide you a better answer.
1) You can set the bool to either true or false in the define line itself instead of "falsing" it right after.
2) No need to set the reloading bool to true INSIDE the loop, better to place that right after.
3) In commands/loops/etc you can also if(variable) INCASE it's a boolean, instead of if(variable == true), for false you can use if(!variable) instead of if(reloading == false).
4) I guess you forgot to define the pName variable(?)
4) I guess you forgot to define the string variable(?) - AVOID from using strings that are more than 124 bits.
5) I narrowed the whole code as I like in order to provide you a better answer.
PHP код:
new bool:reloading = false;
public reload()
{
GameTextForAll("The cannon has been reloaded.",2000,4);
SetObjectPos(obj , 268.89999389648, 1884, 9);
return 1;
}
public fifteen()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerInRangeOfPoint(i, 500.0, 268.89999389648, 1884, 9))
{
GameTextForPlayer(i ,"~r~15 secs until launch",2000,4);
PlayerPlaySound(i , 3200, 0.0, 0.0, 0.0);
}
}
reloading = true;
return 1;
}
if (strcmp("/launch", cmdtext, true, 10) == 0)
{
new pName[MAX_PLAYER_NAME];
new string[124];
if(reloading)
{
SendClientMessage(playerid, COLOR_LIGHTBLUE, "The cannon is reloading.. please wait.");
}
else
{
SetTimer("reload", 120000, 0);
SetTimer("fifteen", 1000, 0);
SetTimer("ten", 5000, 0);
SetTimer("five", 10000, 0);
SetTimer("four", 11000, 0);
SetTimer("three", 12000, 0);
SetTimer("two", 13000, 0);
SetTimer("one", 14000, 0);
SetTimer("start", 15000, 0);
}
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
format(string, sizeof(string), "{00CDCD}%*s {00FFFF}started the cannon countdown.", pName);
SendClientMessageToAll(COLOR_LIGHTBLUE, string);
return 1;
}