06.01.2011, 00:52
How do i find out if a car engine is on or off
if(strcmp(x_nr,"engine",true) == 0) { new vid = GetPlayerVehicleID(playerid); if(IsPlayerInAnyVehicle(playerid)) if(vid != INVALID_VEHICLE_ID) if(carruning == 0) { carruning = 1; SendClientMessage(playerid,WHITE,"Vehicle {D10000}Engine {11A803}starting,{FFFFFF}please wait."); GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective); SetVehicleParamsEx(vid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective); } else { carruning = 0; GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective); SetVehicleParamsEx(vid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective); }
// Top of script
new carrunning[MAX_PLAYERS];
// In your function
carruning[playerid] = 1; // or 0 depending on where you are using it.
new engine,lights,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
if(engine==-1 || engine ==0)
{
printf("The engine is off");
}
if(engine==1)
{
printf("The engine is on");
}
COMMAND:truck(playerid, params[])
{
new cid = GetPlayerVehicleID(playerid);
if(cid>0)
{
new engine,lights,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(cid,engine,lights,alarm,doors,bonnet,boot,objective);
if (boot == -1||boot==0)
{
SetVehicleParamsEx(cid,engine,lights,alarm,doors,bonnet,1,objective);
GameTextForPlayer(playerid,"Backtruck~r~Opened",2000,1);
return 1;
}
if (boot ==1)
{
SetVehicleParamsEx(cid,engine,lights,alarm,doors,bonnet,0,objective);
GameTextForPlayer(playerid,"Backtruck~r~Closed",2000,1);
return 1;
}
}
return 1;
}