26.04.2011, 05:23
Ok i have problem with this code but get no errors. When the car engine is off you can only turn on/open the other commands and when the engine is on you can only turn off/close the other commands. I need it to where you can open close/ turn off on the features without depending if the engine is off or on someone please help me
pawn Код:
if(strcmp(cmdtext, "/engine", true) == 0)
{
if(!IsPlayerConnected(playerid)) return false;
if(IsPlayerInAnyVehicle(playerid) == 0) return SendClientMessage(playerid,0xB4B5B7FF,"You're not in a car!");
new vehicleid = GetPlayerVehicleID(playerid);
new engine,lights,doors,alarm,bonnet,boot,objective;
GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
if(engine != 1)
{
if(vehicleid != INVALID_VEHICLE_ID)
{
SetVehicleParamsEx(vehicleid,1,lights,alarm,doors,bonnet,boot,objective);
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "%s sticks the keys into the ignition and turns their vehicle on.", sendername);
ProxDetector(30.0, playerid, string, COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE);
printf("%s", string);
}
}
else
{
if(vehicleid != INVALID_VEHICLE_ID)
{
SetVehicleParamsEx(vehicleid,0,lights,alarm,doors,bonnet,boot,objective);
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "%s sticks the keys into the ignition and turns the vehicle off.", sendername);
ProxDetector(30.0, playerid, string, COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE);
printf("%s", string);
}
}
return true;
}
if(strcmp(cmdtext, "/lights", true) == 0)
{
if(!IsPlayerConnected(playerid)) return false;
if(IsPlayerInAnyVehicle(playerid) == 0) return SendClientMessage(playerid,0xB4B5B7FF,"You're not in a car!");
new vehicleid = GetPlayerVehicleID(playerid);
new engine,lights,doors,alarm,bonnet,boot,objective;
GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
if(engine != 1)
{
if(vehicleid != INVALID_VEHICLE_ID)
{
SetVehicleParamsEx(vehicleid,engine,1,alarm,doors,bonnet,boot,objective);
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "%s turns on the vehicle lights.", sendername);
ProxDetector(30.0, playerid, string, COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE);
printf("%s", string);
}
}
else
{
if(vehicleid != INVALID_VEHICLE_ID)
{
SetVehicleParamsEx(vehicleid,engine,0,alarm,doors,bonnet,boot,objective);
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "%s turns off the vehicle lights.", sendername);
ProxDetector(30.0, playerid, string, COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE);
printf("%s", string);
}
}
return true;
}
if(strcmp(cmdtext, "/hood", true) == 0)
{
if(!IsPlayerConnected(playerid)) return false;
if(IsPlayerInAnyVehicle(playerid) == 0) return SendClientMessage(playerid,0xB4B5B7FF,"You're not in a car!");
new vehicleid = GetPlayerVehicleID(playerid);
new engine,lights,doors,alarm,bonnet,boot,objective;
GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
if(engine != 1)
{
if(vehicleid != INVALID_VEHICLE_ID)
{
SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,1,boot,objective);
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "%s pops the hood and opens it.", sendername);
ProxDetector(30.0, playerid, string, COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE);
printf("%s", string);
}
}
else
{
if(vehicleid != INVALID_VEHICLE_ID)
{
SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,0,boot,objective);
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "%s slams the hood shut.", sendername);
ProxDetector(30.0, playerid, string, COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE);
printf("%s", string);
}
}
return true;
}
if(strcmp(cmdtext, "/trunk", true) == 0)
{
if(!IsPlayerConnected(playerid)) return false;
if(IsPlayerInAnyVehicle(playerid) == 0) return SendClientMessage(playerid,0xB4B5B7FF,"You're not in a car!");
new vehicleid = GetPlayerVehicleID(playerid);
new engine,lights,doors,alarm,bonnet,boot,objective;
GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
if(engine != 1)
{
if(vehicleid != INVALID_VEHICLE_ID)
{
SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,1,objective);
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "%s pops the trunk and opens it.", sendername);
ProxDetector(30.0, playerid, string, COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE);
printf("%s", string);
}
}
else
{
if(vehicleid != INVALID_VEHICLE_ID)
{
SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,0,objective);
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "%s slams the trunk shut.", sendername);
ProxDetector(30.0, playerid, string, COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE);
printf("%s", string);
}
}
return true;
}