26.01.2014, 15:23
does anyone know how to make a cmd called /killengine to stop cars
#define GREY 0xCECECEFF
new Engine[MAX_VEHICLES], Lights[MAX_VEHICLES];
Engine[vehicleid] = 0;
Lights[vehicleid] = 0;
command(engineoff, playerid, params[])//This bit is creating the command
{
#pragma unused params
if(GetPlayerState(playerid) == 2) //This bit is checking the players seat
{
new vehicle = GetPlayerVehicleID(playerid);
if(Engine[vehicle] == 1)
{
new engine, lights, alarm, doors, bonnet, boot, objective; //Same procedure, this is defining the variables
Engine[vehicle] = 0; //This bit here, is quite vital. because if you left it at: Engine[vehicle] = 0; Then the vehicle would turn off, then not start again unless respawned.
GetVehicleParamsEx(vehicle, engine, lights, alarm, doors, bonnet, boot, objective);//This bit is checking the current status of the vehicles.
SetVehicleParamsEx(vehicle, 0, lights, alarm, doors, bonnet, boot, 0);//This bit is setting the engine to be turned off.
}
else return SendClientMessage(playerid, GREY, "This vehicle's engine is already off.");//This will display on the screen if the engine is already off.
}
else return SendClientMessage(playerid, GREY, "You must be in the drivers seat of a vehicle.");//This message will display on the screen if the player doing the command isn't in the drivers seat of a vehicle
return 1;
}
new engine,lights,alarm,doors,bonnet,boot,objective;
if(strcmp(cmd, "/stopengine",true) == 0) {
new vid = GetPlayerVehicleID(playerid);
if(vid != INVALID_VEHICLE_ID) {
GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(vid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
}
return 1;
}