-
Notifications
You must be signed in to change notification settings - Fork 8
Utilities
The Utilities class provides you utility methods that can be used not only in callouts, but in individual scripts aswell. So in other words, you can make plugins for FivePD.
Returns the closest ped relative to the given ped.
Example: To get the closest ped to the player:
Ped closest = Utilities.GetClosestPed(Game.PlayerPed);
Force a FivePD callout by its GUID or name.
If no callout could be forced, an error message will be printed in the console.
Note: If there are multiple callouts with the same name, the first appearance (in the callouts collection) will be forced.
Example:
ForceCallout("a6f854c1-371a-4b2b-93c5-d99989552898"); // Forces a callout with the given GUID
...
Utilities.ForceCallout("Mugging"); // Forces the "Mugging" callout
Returns the current ongoing callout. (FivePD.API.Callout
)
Example:
...
FivePD.API.Callout callout = Utilities.GetCurrentCallout();
Returns a List<string>
containing every enabled
callout name.
Example:
...
List<string> calloutNames = Utilities.GetCallouts();
Requests a FivePD service to a given position.
You can only request the following services:
Ambulance
AirAmbulance
FireDept
Coroner
AnimalControl
Example:
To request an ambulance at x = 0, y = 0, z = 0 position:
Utilities.RequestService(Services.Ambulance,new Vector3(0,0,0));
Cancels the last requested service.
Example:
Utilities.CancelService(Services.Ambulance); // Cancels the last requested Ambulance
Returns the following data of the given vehicle (with NetworkId)
- LicensePlate
<string>
- Flag
<string>
(eg. "Stolen") - OwnerNetworkID
<int>
- OwnerFirstname
<string>
- OwnerLastname
<string>
- Items
<List<dynamic>>
- An item object contains:
- Name
<string>
- IsIllegal
<bool>
- Name
- Insurance
<bool>
- Registration
<bool>
- VehicleColor
<string>
- VehicleName
<string>
- ID
<int>
(networkId)
Example:
Vehicle vehicle;
...
dynamic data = await Utilities.GetVehicleData(vehicle.NetworkId);
To get the license plate:
string licensePlate = data.LicensePlate;
To get the flag:
string flag = data.Flag;
To get the owner's network id
int ownerNetworkID = data.OwnerNetworkID;
To get the owner's firstname:
string ownerFirstname = data.OwnerFirstname;
To get the owner's lastname:
string ownerLastname = data.OwnerLastname;
To get the insurance status: (true
= value, false
= invalid)
bool insurance = data.Insurance;
To get the registration status: (true
= value, false
= invalid)
bool registration = data.Registration;
To get the color of the vehicle:
string color = data.VehicleColor;
To get the name of the vehicle:
string vehicleName = data.VehicleName;
To get the id of the vehicle: (networkID)
int vehicleID = data.ID;
To get the items:
List<dynamic> items = data.Items;
foreach (var elem in items)
{
string itemName = elem.Name;
bool isIllegal = elem.IsIllegal;
}
Params:
- networkID
<int>
- NetworkID of the vehicle
- vehicleData
<ExpandoObject>
- Vehicle data
Optional
- insurance
<bool>
- registration
<bool>
- items
<object>
First, you need to create a new ExpandoObject:
dynamic vehicleData = new ExpandoObject();
To set insurance status:
vehicleData.insurance = false;
To set registration status:
vehicleData.registration = false;
To set items:
List<object> items = new List<object>();
object phone = new {
Name = "Phone",
IsIllegal = false
};
items.Add(phone);
vehicleData.items = items;
And then call the SetVehicleData
method:
Utilities.SetVehicleData(vehicle.NetworkId,vehicleData);
Extended with (Keys):
- dob
<ExpandoObject>
- warrant
<string>
Example:
dynamic pedData = new ExpandoObject();
pedData.dob = new ExpandoObject();
pedData.dob.day = 1;
pedData.dob.month = 1;
pedData.dob.year = 1970;
pedData.warrant = "<warrant>";
Params:
- networkID
<int>
- Network ID of the vehicle.
- exclude
<bool
>- If set to
true
, the vehicle won't be affected by the traffic stop function. - If set to
false
, the vehicle can be stopped by the player again.
- If set to
The following example disables the traffic stop on the given vehicle:
Vehicle vehicle;
...
Utilities.ExcludeVehicleFromTrafficStop(vehicle.NetworkId,true);