Skip to content
Stefan Unković edited this page Aug 8, 2021 · 1 revision

Introduction

  • Alarms are a safety device. It's the device which gives us audio, visual or some other type of signal to alert o us. It referrs to a problem or condition that needs urgent intervention. Vehicle alarms are the ones which triggers when one want to hijack a car, steal it or damages car drastically. In SA:MP, alarms are modified by SetVehicleParamsEx.

SA:MP functions

  • There are functions in SA:MP which allows you to change alarm states. It's as mentioned above, modified by SetVehicleParamsEx. The function is used to modify all values of all vehicle parts, like bonnet, objective, alarms, boot etc... Therefore, you need to take into account you are going to need all those values gotten before you can modify. The values from all vehicle params. Let's take a look how it looks. We'll take a closer look into an example from SA:MP/open.mp wikipedia.
// If setting a single parameter, you should obtain the current parameters so they aren't ALL changed
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vehicleid, engine, lights, VEHICLE_PARAMS_ON, doors, bonnet, boot, objective); // ONLY the lights param was changed to VEHICLE_PARAMS_ON (1)

With vehicle-framework, this becomes a lot easier, as framework finishes all this work for you.

Framework

  • Like we've just learnt. Framework finishes all of the work for you. Also, it uses tags.

A tag is a prefix to a variable which tells the compiler to treat the variable specially under certain circumstances.

The tags are different, thus, they can't be used with different function. They are

E_ALARMS_OFF = 0,
E_ALARMS_ON 

The tags' names are pretty self-explanatory. You got the point just by reading them, ones turn alarm on, the other turn its off. Take a closer look.

new e_ALARMS_STATE: alarm;

alarm = Vehicle_GetAlarmState(vehicleid);

Easy, huh? Look how we have to use tagged variables to get light damage statuses. Don't mix it with non-tagged.

The function's first argument, Vehicle_SetAlarmState, is tagged with VEHICLE_FRAMEWORK_TAGS, so it accepts either groupid or vehicleid.

new VehicleGroup: vehicleGroup;
Vehicle_SetAlarmState(vehicleGroup, E_ALARM_ON);

Getting functions can only use vehicleid.

Sidebar

Clone this wiki locally