09.03.2014, 18:22
well well ^^
just use else if
instead of
if(strcm....
if(strcm...
and so on
do
if(strcm...
else if(str....
and at the end
else Sendcl..... Invalid option
see, i used this to test it and it works.
You setup the control structure for the options in an invalid way
the code:
(it's basically your code, just slightly modifyed the parts with these player vars and functions i didn't have ofc.)
just use else if
instead of
if(strcm....
if(strcm...
and so on
do
if(strcm...
else if(str....
and at the end
else Sendcl..... Invalid option
see, i used this to test it and it works.
You setup the control structure for the options in an invalid way
the code:
pawn Код:
YCMD:car(playerid, params[], help)
{
new Option[32];//isn't that too much? 6 would do the trick :) well, it's your code
new vid = GetPlayerVehicleID(playerid);
if(sscanf(params, "s[32]", Option)) return SendClientMessage(playerid, -1, "Usage: /car [Engine/Lights/Hood/Trunk/Speedo]");
new eengine,llights,aalarm,ddoors,bbonnet,bboot,oobjective;
GetVehicleParamsEx(vid,eengine,llights,aalarm,ddoors,bbonnet,bboot,oobjective);
if(strcmp(Option, "engine", true) == 0)
{
if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
if(eengine != VEHICLE_PARAMS_ON)
{
new TextString[128];
SetVehicleParamsEx(vid,VEHICLE_PARAMS_ON,llights,aalarm,ddoors,bbonnet,bboot,oobjective);
format(TextString, sizeof TextString,"* %s turns the vehicle key, attempting to start the vehicle.","b");
SendClientMessage(playerid,-1,TextString);
}
else
{
SetVehicleParamsEx(vid,VEHICLE_PARAMS_OFF,llights,aalarm,ddoors,bbonnet,bboot,oobjective);
new TextString[128];
format(TextString, sizeof TextString,"* %s turns the vehicle key, Turning the vehicle off.","b");
SendClientMessage(playerid,-1,TextString);
}
}
}
else if(strcmp(Option, "lights", true) == 0)
{
if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
if(llights != VEHICLE_PARAMS_ON)
{
SetVehicleParamsEx(vid,eengine,VEHICLE_PARAMS_ON,aalarm,ddoors,bbonnet,bboot,oobjective);
}
else
{
SetVehicleParamsEx(vid,eengine,VEHICLE_PARAMS_OFF,aalarm,ddoors,bbonnet,bboot,oobjective);
}
}
}
else if(strcmp(Option, "trunk", true) == 0)
{
if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
if(bboot != VEHICLE_PARAMS_ON)
{
SetVehicleParamsEx(vid,eengine,llights,aalarm,ddoors,bbonnet,VEHICLE_PARAMS_ON,oobjective);
}
else
{
SetVehicleParamsEx(vid,eengine,llights,aalarm,ddoors,bbonnet,VEHICLE_PARAMS_OFF,oobjective);
}
}
}
else if(strcmp(Option, "hood", true) == 0)
{
if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
if(bbonnet != VEHICLE_PARAMS_ON)
{
SetVehicleParamsEx(vid,eengine,llights,aalarm,ddoors,VEHICLE_PARAMS_ON,bboot,oobjective);
}
else
{
SetVehicleParamsEx(vid,eengine,llights,aalarm,ddoors,VEHICLE_PARAMS_OFF,bboot,oobjective);
}
}
}
else SendClientMessage(playerid,-1,"INVALID Option");
return 1;
}