Try this:
Put this on top
pawn Code:
#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
This in OnPlayerCommandText
pawn Code:
dcmd(engine, 6, cmdtext);
And finally, somewhere where you want:
pawn Code:
dcmd_engine(playerid, params[])
{
#pragma unused params
if(IsPlayerInAnyVehicle(playerid))
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
new vehicleid = GetPlayerVehicleID(playerid);
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
if(engine == 1)
{
SetVehicleParamsEx(vehicleid, 0, lights, alarm, doors, bonnet, boot, objective);
SendClientMessage(playerid, COLOR_WHITE, "The vehicle's engine stopped succesfully.");
}
else
{
SetVehicleParamsEx(vehicleid, 1, lights, alarm, doors, bonnet, boot, objective);
SendClientMessage(playerid, COLOR_WHITE, "The vehicle's engine started succesfully.");
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, "You are not at the driver's seat!");
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, "You are not in a vehicle!");
}
return 1;
}