A prob with a command..
#1

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;
}
Reply
#2

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.8999938964818849);
     return 
1;
}
public 
fifteen()
{
     for(new 
0MAX_PLAYERSi++)
     {
          if(
IsPlayerInRangeOfPoint(i500.0268.8999938964818849))
          {
               
GameTextForPlayer(,"~r~15 secs until launch",2000,4);
               
PlayerPlaySound(32000.00.00.0);
          }
     }
     
reloading true;
     return 
1;
}
if (
strcmp("/launch"cmdtexttrue10) == 0)
{
     new 
pName[MAX_PLAYER_NAME];
     new 
string[124];
     if(
reloading)
     {
          
SendClientMessage(playeridCOLOR_LIGHTBLUE"The cannon is reloading.. please wait.");
     }
     else
     {
          
SetTimer("reload"1200000);
          
SetTimer("fifteen"10000);
          
SetTimer("ten"50000);
          
SetTimer("five"100000);
          
SetTimer("four"110000);
          
SetTimer("three"120000);
          
SetTimer("two"130000);
          
SetTimer("one"140000);
          
SetTimer("start"150000);
     }
     
GetPlayerName(playeridpNameMAX_PLAYER_NAME);
     
format(stringsizeof(string), "{00CDCD}%*s {00FFFF}started the cannon countdown."pName);
     
SendClientMessageToAll(COLOR_LIGHTBLUEstring);
     return 
1;

Reply
#3

Thank ya very much !
I've fixed my other filescripts too with your sugg, thank ya again!
I've gived +1 rep :3
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)