A prob with a command.. -
Steezy_ - 04.07.2013
Hey guys, first of all i would say sorry for my poor english.. but ok, i have i prob in my code..
I wanted to make that if you use /launch when the boolean is true, playerid gets an error.. the compiler don't give errors but in game when i do that, i get the error.. but the real function too
Someone told me that i've forgot a bracket but i don't see where..
Here is my code
Код:
new bool: reloading;
public reload()
{
GameTextForAll("The cannon has been reloaded.",2000,4);
SetObjectPos(obj , 268.89999389648, 1884, 9);
reloading = false;
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);
if(IsPlayerInRangeOfPoint(i, 500.0, 268.89999389648, 1884, 9))
PlayerPlaySound(i , 3200, 0.0, 0.0, 0.0);
reloading = true;
}
return 1;
}
if (strcmp("/launch", cmdtext, true, 10) == 0){
if(reloading == true)
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, 30);
format(string, 280, "{00CDCD}%*s {00FFFF}started the cannon countdown.", pName);
SendClientMessageToAll(COLOR_LIGHTBLUE, string);
}
return 1;
}
Re: A prob with a command.. -
Income - 04.07.2013
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.
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;
}
Re: A prob with a command.. -
Steezy_ - 04.07.2013
Thank ya very much !
I've fixed my other filescripts too with your sugg, thank ya again!
I've gived +1 rep :3