at OnFilterScriptInit or OnGameModeInit put this ManualVehicleEngineAndLights();
|
CMD:engine(playerid,params[])
{
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER)return ShowErrorDialog(playerid, "You are not driving a vehicle");
new vehicleid=GetPlayerVehicleID(playerid),engine,lights,alarm,doors,bonnet,boot,objective;
new Float:health;
GetVehicleHealth(vehicleid,health);
GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
if(Fuel[vehicleid] <= 0) return ShowErrorDialog(playerid, "This vehicle is out of fuel!");
if(health <= 650) return ShowErrorDialog(playerid, "The car does not start anymore!");
new Float:x, Float:y, Float:z, name[MAX_PLAYER_NAME], string[100];
GetPlayerName(playerid, name, sizeof(name));
GetPlayerPos(playerid, x, y, z);
for(new i=0; i<GetMaxPlayers(); i++)
{
if(IsPlayerInRangeOfPoint(i, 20.00, x, y, z))
{
if(engine == 1)
{
SetVehicleParamsEx(vehicleid,0,0,alarm,doors,bonnet,boot,objective);
if(Gender[playerid] == 1)
{
format(string,sizeof(string),"%s(%i) switches the engine of his %s off.",PlayerName(playerid),playerid,VehicleNames[GetVehicleModel(vehicleid)-400]);
SendClientMessage(i, ORANGE, string);
}
else if(Gender[playerid] == 2)
{
format(string,sizeof(string),"%s(%i) switches the engine of her %s off.",PlayerName(playerid),playerid);
SendClientMessage(i, ORANGE, string);
}
}
else
{
SetVehicleParamsEx(vehicleid,1,lights,alarm,doors,bonnet,boot,objective);
if(Gender[playerid] == 1)
{
format(string,sizeof(string),"%s(%i) switches the engine of his %s on.",PlayerName(playerid),playerid,VehicleNames[GetVehicleModel(vehicleid)-400]);
SendClientMessage(i, ORANGE, string);
}
else if(Gender[playerid] == 2)
{
format(string,sizeof(string),"%s(%i) switches the engine of her %s on.",PlayerName(playerid),playerid,VehicleNames[GetVehicleModel(vehicleid)-400]);
SendClientMessage(i, ORANGE, string);
}
}
}
}
return 1;
}