[HELP] Command Bug. -
RenovanZ - 07.12.2012
Hey, I added Neon System on my GM, and I added command /neon for turn on or turn off the neon, it's worked when I outside the vehicle, but, when I Inside the vehicle, it's say command not found.
This is the command:
pawn Код:
CMD:neon(playerid, params[])
{
new vehid = GetPlayerVehicleID(playerid);
if(IsPlayerInAnyVehicle(playerid))
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
if(PlayerVehicleInfo[playerid][vehid][pvNeon] >= 1)
{
if(Neon[vehid] == 1)
{
UnloadNeon(playerid, vehid);
SendClientMessageEx(playerid, COLOR_GREY, "Neon turned off.");
Neon[vehid] = 0;
}
else
{
LoadNeon(playerid, vehid);
SendClientMessageEx(playerid, COLOR_GREY, "Neon turned on.");
Neon[vehid] = 1;
}
}
else SendClientMessageEx(playerid, COLOR_GREY, "This vehicle doesn't have neon!");
}
else SendClientMessageEx(playerid, COLOR_GREY, "You are not the driver!");
}
else SendClientMessageEx(playerid, COLOR_GREY, "You are not inside Vehicle!");
return 1;
}
Please Help
Re: [HELP] Command Bug. -
HireMe - 07.12.2012
have you tried to put something like SendClientMessageEx(playerid, COLOR_GREY, "Neon Check."); in the script to check till where it goes right and where it got stuck on?
for instance if it dont show up after if(PlayerVehicleInfo[playerid][vehid][pvNeon] >= 1) but it does before you know something goes wrong with the info
Re: [HELP] Command Bug. -
RenovanZ - 08.12.2012
Im Using
doesnt work then I Change to
pawn Код:
new Neon[MAX_PLAYERS] = INVALID_VEHICLES_ID;
doesnt work too, what function should I use ?
Re: [HELP] Command Bug. -
Threshold - 08.12.2012
Try this:
Код:
CMD:neon(playerid, params[])
{
if(IsPlayerInAnyVehicle(playerid))
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
new vehid = GetPlayerVehicleID(playerid);
if(PlayerVehicleInfo[playerid][vehid][pvNeon] >= 1)
{
if(Neon[vehid] == 1)
{
UnloadNeon(playerid, vehid);
SendClientMessageEx(playerid, COLOR_GREY, "Neon turned off.");
Neon[vehid] = 0;
}
else if(Neon[vehid] == 0)
{
LoadNeon(playerid, vehid);
SendClientMessageEx(playerid, COLOR_GREY, "Neon turned on.");
Neon[vehid] = 1;
}
}
else return SendClientMessageEx(playerid, COLOR_GREY, "This vehicle doesn't have neon!");
}
else return SendClientMessageEx(playerid, COLOR_GREY, "You are not the driver!");
}
else return SendClientMessageEx(playerid, COLOR_GREY, "You are not inside a Vehicle!");
return 1;
}
Where did you go wrong?
Код:
if(Neon[vehid] == 1)
{
UnloadNeon(playerid, vehid);
SendClientMessageEx(playerid, COLOR_GREY, "Neon turned off.");
Neon[vehid] = 0;
}
else if(Neon[vehid] == 0)
{
LoadNeon(playerid, vehid);
SendClientMessageEx(playerid, COLOR_GREY, "Neon turned on.");
Neon[vehid] = 1;
}
You use else instead of an else if statement, otherwise you would be setting the variable to 0, therefore the code just resets.
Re: [HELP] Command Bug. -
RenovanZ - 08.12.2012
The problem is, when i use the command inside the vehicle, its say unknown command, but when i outside the vehicle it's say You Must Inside Vehicle aka Work.
Re: [HELP] Command Bug. -
RajatPawar - 08.12.2012
Try using a switch statement instead of multiple 'ifs.' It's clearer and helps you get the problem easily.
Also, as 'HireMe' said, Put print messages after everyline, like print("Check 1."); to see where you script stops working.
Re: [HELP] Command Bug. -
RenovanZ - 08.12.2012
switch like what ?
Re: [HELP] Command Bug. -
Faisal_khan - 08.12.2012
Switch something like this
https://sampwiki.blast.hk/wiki/Control_Structures#switch_2
Re: [HELP] Command Bug. -
leonardo1434 - 08.12.2012
Give a try.
PHP код:
CMD:neon(playerid, params[])
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) return SendClientMessageEx(playerid, COLOR_GREY, "You are not the driver!");
if(PlayerVehicleInfo[playerid][vehid][pvNeon] < _:true) return SendClientMessageEx(playerid, COLOR_GREY, "This vehicle doesn't have neon!");
if(Neon[vehid] == _:true) return (UnloadNeon(playerid, vehid),SendClientMessageEx(playerid, COLOR_GREY, "Neon turned off."),Neon[vehid] = false,true);
return (LoadNeon(playerid, vehid),SendClientMessageEx(playerid, COLOR_GREY, "Neon turned on."),Neon[vehid] = true,true);
}
Re: [HELP] Command Bug. -
RenovanZ - 08.12.2012
I Think the error is this.
The command stop when
Is the
wrong ?