#define FILTERSCRIPT
#include <a_samp>
#include <izcmd>
#include <sscanf2>
native IsValidVehicle(vehicleid);
enum vehicle_data
{
vehicle_plate[32],
vehicle_engine,
vehicle_lights,
vehicle_alarm,
vehicle_locked,
vehicle_bonnet,
vehicle_boot,
vehicle_objective
}
new VehicleData[MAX_VEHICLES][vehicle_data];
stock IsVehicleBicycle(vehicleid)
{
if(GetVehicleModel(vehicleid)==381 || GetVehicleModel(vehicleid)==509 ||GetVehicleModel(vehicleid)==510)return 1;
return 0;
}
stock SetVehicleParamsForAll(vehicleid, objective, doorslocked)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
SetVehicleParamsForPlayer(vehicleid, i, objective, doorslocked);
}
return 1;
}
stock GetNearestVehicle(playerid)
{
for(new i = 0; i < MAX_VEHICLES; i++)
{
if(IsValidVehicle(i))
{
new float:pos[3];
GetVehiclePos(i, pos[0],pos[1],pos[2]);
if(IsPlayerInRangeOfPoint(playerid,5.0,pos[0],pos[1],pos[2]))return i;
}
}
return INVALID_VEHICLE_ID;
}
public OnFilterScriptInit()
{
for(new v = 0; v < MAX_VEHICLES; v++)
{
VehicleData[v][vehicle_engine]=VEHICLE_PARAMS_OFF;
VehicleData[v][vehicle_lights]=VEHICLE_PARAMS_OFF;
VehicleData[v][vehicle_alarm]=VEHICLE_PARAMS_OFF;
VehicleData[v][vehicle_locked]=VEHICLE_PARAMS_OFF;
VehicleData[v][vehicle_bonnet]=VEHICLE_PARAMS_OFF;
VehicleData[v][vehicle_boot]=VEHICLE_PARAMS_OFF;
VehicleData[v][vehicle_objective]=VEHICLE_PARAMS_OFF;
if(IsVehicleBicycle(v))
{
VehicleData[v][vehicle_engine]=VEHICLE_PARAMS_ON;
}
SetVehicleParamsEx(v,VehicleData[v][vehicle_engine],VehicleData[v][vehicle_lights],VehicleData[v][vehicle_alarm],VehicleData[v][vehicle_locked],VehicleData[v][vehicle_bonnet],VehicleData[v][vehicle_boot],VehicleData[v][vehicle_objective]);
}
return 1;
}
public OnVehicleStreamIn(vehicleid,forplayerid)
{
SetVehicleParamsEx(vehicleid,VehicleData[vehicleid][vehicle_engine], VehicleData[vehicleid][vehicle_lights],VehicleData[vehicleid][vehicle_alarm],VehicleData[vehicleid][vehicle_locked],VehicleData[vehicleid][vehicle_bonnet],VehicleData[vehicleid][vehicle_boot],VehicleData[vehicleid][vehicle_objective]);
SetVehicleParamsForAll(vehicleid, VehicleData[vehicleid][vehicle_objective],VehicleData[vehicleid][vehicle_locked]);
}
COMMAND:engine(playerid,params[])
{
if(!IsPlayerInAnyVehicle(playerid) || GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, -1 ,"Only driver can start engine");
new vehicleid = GetPlayerVehicleID(playerid);
if(VehicleData[vehicleid][vehicle_engine] == VEHICLE_PARAMS_OFF)
{
VehicleData[vehicleid][vehicle_engine] = VEHICLE_PARAMS_ON;
SetVehicleParamsEx(vehicleid,VehicleData[vehicleid][vehicle_engine],VehicleData[vehicleid][vehicle_lights],VehicleData[vehicleid][vehicle_alarm],VehicleData[vehicleid][vehicle_locked],VehicleData[vehicleid][vehicle_bonnet],VehicleData[vehicleid][vehicle_boot],VehicleData[vehicleid][vehicle_objective]);
return GameTextForPlayer(playerid,"~g~Engine: On", 3000, 5);
}
else
{
VehicleData[vehicleid][vehicle_engine] = VEHICLE_PARAMS_OFF;
SetVehicleParamsEx(vehicleid,VehicleData[vehicleid][vehicle_engine],VehicleData[vehicleid][vehicle_lights],VehicleData[vehicleid][vehicle_alarm],VehicleData[vehicleid][vehicle_locked],VehicleData[vehicleid][vehicle_bonnet],VehicleData[vehicleid][vehicle_boot],VehicleData[vehicleid][vehicle_objective]);
GameTextForPlayer(playerid,"~r~Engine: Off", 3000, 5);
}
return 1;
}
COMMAND:lights(playerid,params[])
{
if(!IsPlayerInAnyVehicle(playerid) || GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, -1 ,"Only driver can turn on lights");
new vehicleid = GetPlayerVehicleID(playerid);
if(VehicleData[vehicleid][vehicle_lights] == VEHICLE_PARAMS_OFF)
{
VehicleData[vehicleid][vehicle_lights] = VEHICLE_PARAMS_ON;
SetVehicleParamsEx(vehicleid,VehicleData[vehicleid][vehicle_engine],VehicleData[vehicleid][vehicle_lights],VehicleData[vehicleid][vehicle_alarm],VehicleData[vehicleid][vehicle_locked],VehicleData[vehicleid][vehicle_bonnet],VehicleData[vehicleid][vehicle_boot],VehicleData[vehicleid][vehicle_objective]);
return GameTextForPlayer(playerid,"~g~Lights: On", 3000, 5);
}
else
{
VehicleData[vehicleid][vehicle_lights] = VEHICLE_PARAMS_OFF;
SetVehicleParamsEx(vehicleid,VehicleData[vehicleid][vehicle_engine],VehicleData[vehicleid][vehicle_lights],VehicleData[vehicleid][vehicle_alarm],VehicleData[vehicleid][vehicle_locked],VehicleData[vehicleid][vehicle_bonnet],VehicleData[vehicleid][vehicle_boot],VehicleData[vehicleid][vehicle_objective]);
GameTextForPlayer(playerid,"~r~Lights: Off", 3000, 5);
}
return 1;
}
COMMAND:alarm(playerid,params[])
{
new vehicleid = GetNearestVehicle(playerid);
if(vehicleid == INVALID_VEHICLE_ID)return SendClientMessage(playerid, -1, "There are no vehicles nearby to toggle the alram for.");
if(VehicleData[vehicleid][vehicle_alarm] == VEHICLE_PARAMS_OFF)
{
VehicleData[vehicleid][vehicle_alarm] = VEHICLE_PARAMS_ON;
SetVehicleParamsEx(vehicleid,VehicleData[vehicleid][vehicle_engine],VehicleData[vehicleid][vehicle_lights],VehicleData[vehicleid][vehicle_alarm],VehicleData[vehicleid][vehicle_locked],VehicleData[vehicleid][vehicle_bonnet],VehicleData[vehicleid][vehicle_boot],VehicleData[vehicleid][vehicle_objective]);
return GameTextForPlayer(playerid,"~g~Alarm: On", 3000, 5);
}
else
{
VehicleData[vehicleid][vehicle_alarm] = VEHICLE_PARAMS_OFF;
SetVehicleParamsEx(vehicleid,VehicleData[vehicleid][vehicle_engine],VehicleData[vehicleid][vehicle_lights],VehicleData[vehicleid][vehicle_alarm],VehicleData[vehicleid][vehicle_locked],VehicleData[vehicleid][vehicle_bonnet],VehicleData[vehicleid][vehicle_boot],VehicleData[vehicleid][vehicle_objective]);
GameTextForPlayer(playerid,"~r~Alarm: Off", 3000, 5);
}
return 1;
}
COMMAND:bonnet(playerid,params[])
{
new vehicleid = GetNearestVehicle(playerid);
if(vehicleid == INVALID_VEHICLE_ID)return SendClientMessage(playerid, -1, "There are no vehicles nearby to open the bonet for");
if(VehicleData[vehicleid][vehicle_bonnet] == VEHICLE_PARAMS_OFF)
{
VehicleData[vehicleid][vehicle_bonnet] = VEHICLE_PARAMS_ON;
SetVehicleParamsEx(vehicleid,VehicleData[vehicleid][vehicle_engine],VehicleData[vehicleid][vehicle_lights],VehicleData[vehicleid][vehicle_alarm],VehicleData[vehicleid][vehicle_locked],VehicleData[vehicleid][vehicle_bonnet],VehicleData[vehicleid][vehicle_boot],VehicleData[vehicleid][vehicle_objective]);
return GameTextForPlayer(playerid,"~g~Bonnet: Open", 3000, 5);
}
else
{
VehicleData[vehicleid][vehicle_bonnet] = VEHICLE_PARAMS_OFF;
SetVehicleParamsEx(vehicleid,VehicleData[vehicleid][vehicle_engine],VehicleData[vehicleid][vehicle_lights],VehicleData[vehicleid][vehicle_alarm],VehicleData[vehicleid][vehicle_locked],VehicleData[vehicleid][vehicle_bonnet],VehicleData[vehicleid][vehicle_boot],VehicleData[vehicleid][vehicle_objective]);
GameTextForPlayer(playerid,"~r~Bonnet: Closed", 3000, 5);
}
return 1;
}
COMMAND:boot(playerid,params[])
{
new vehicleid = GetNearestVehicle(playerid);
if(vehicleid == INVALID_VEHICLE_ID)return SendClientMessage(playerid, -1, "There are no vehicles nearby to open the boot for");
if(VehicleData[vehicleid][vehicle_boot] == VEHICLE_PARAMS_OFF)
{
VehicleData[vehicleid][vehicle_boot] = VEHICLE_PARAMS_ON;
SetVehicleParamsEx(vehicleid,VehicleData[vehicleid][vehicle_engine],VehicleData[vehicleid][vehicle_lights],VehicleData[vehicleid][vehicle_alarm],VehicleData[vehicleid][vehicle_locked],VehicleData[vehicleid][vehicle_bonnet],VehicleData[vehicleid][vehicle_boot],VehicleData[vehicleid][vehicle_objective]);
return GameTextForPlayer(playerid,"~g~boot: Open", 3000, 5);
}
else
{
VehicleData[vehicleid][vehicle_boot] = VEHICLE_PARAMS_OFF;
SetVehicleParamsEx(vehicleid,VehicleData[vehicleid][vehicle_engine],VehicleData[vehicleid][vehicle_lights],VehicleData[vehicleid][vehicle_alarm],VehicleData[vehicleid][vehicle_locked],VehicleData[vehicleid][vehicle_bonnet],VehicleData[vehicleid][vehicle_boot],VehicleData[vehicleid][vehicle_objective]);
GameTextForPlayer(playerid,"~r~boot: Closed", 3000, 5);
}
return 1;
}
COMMAND:lock(playerid,params[])
{
new vehicleid = GetNearestVehicle(playerid);
if(vehicleid == INVALID_VEHICLE_ID)return SendClientMessage(playerid, -1, "There are no vehicles nearby to open the boot for");
if(VehicleData[vehicleid][vehicle_boot] == VEHICLE_PARAMS_OFF)
{
VehicleData[vehicleid][vehicle_boot] = VEHICLE_PARAMS_ON;
SetVehicleParamsEx(vehicleid,VehicleData[vehicleid][vehicle_engine],VehicleData[vehicleid][vehicle_lights],VehicleData[vehicleid][vehicle_alarm],VehicleData[vehicleid][vehicle_locked],VehicleData[vehicleid][vehicle_bonnet],VehicleData[vehicleid][vehicle_boot],VehicleData[vehicleid][vehicle_objective]);
SetVehicleParamsForAll(vehicleid,VehicleData[vehicleid][vehicle_objective],VehicleData[vehicleid][vehicle_locked]);
return GameTextForPlayer(playerid,"~g~Lock: Open", 3000, 5);
}
else
{
VehicleData[vehicleid][vehicle_boot] = VEHICLE_PARAMS_OFF;
SetVehicleParamsEx(vehicleid,VehicleData[vehicleid][vehicle_engine],VehicleData[vehicleid][vehicle_lights],VehicleData[vehicleid][vehicle_alarm],VehicleData[vehicleid][vehicle_locked],VehicleData[vehicleid][vehicle_bonnet],VehicleData[vehicleid][vehicle_boot],VehicleData[vehicleid][vehicle_objective]);
SetVehicleParamsForAll(vehicleid,VehicleData[vehicleid][vehicle_objective],VehicleData[vehicleid][vehicle_locked]);
GameTextForPlayer(playerid,"~r~Lock: Closed", 3000, 5);
}
return 1;
}