Utilities
FivePD.API
#
Namespace: Source/Utilities.cs
#
File: These utility functions can be used in both callouts and plugins.
#
Enums#
Services- Ambulance
0
- AirAmbulance
1
- FireDept
2
- Coroner
3
- AnimalControl
4
- TowTruck
5
- Mechanic
6
- PrisonTransport
7
#
Methods#
GetPassengersFromTrafficStopReturns an array of passenger peds from the pulled over vehicle.
caution
The driver ped will not be added into the array.
Returns: Ped[]
Params: -
#
Examplevar passengers = Utilities.GetPassengersFromTrafficStop();
#
GetDriverFromTrafficStopReturns the driver ped from of pulled over vehicle.
Returns: Ped
Params: -
#
Examplevar driver = Utilities.GetDriverFromTrafficStop();
#
SetPlayerDataChanging the player's data will be saved in the database.
Returns: -
Params:
- playerData
- Type: PlayerData
- The data that you want to set
- setPlayerDataFlags
- Type: SetPlayerDataFlags
- The data that you want to set with the playerData object
#
Examplevar playerData = new PlayerData();playerData.DepartmentID = -1;
// This will kick the player from the department (only changes the department id)Utilities.SetPlayerData(playerData, SetPlayerDataFlags.DepartmentID);
#
EnableModEnables the mod for the local player. Can be useful to make FivePD to work along with other resources.
Can be called dynamically. (can be toggled)
Returns: -
Params: -
#
ExampleEnableMod();
#
DisableModDisables the mod for the local player. Can be useful to make FivePD to work along with other resources.
Can be called dynamically. (can be toggled)
Returns: -
Params: -
#
ExampleDisableMod();
#
GetRandomPosInPlayerDepartmentAreaReturns a random position within the range of the player's department.
Returns: Vector3
Params: -
#
Examplevar position = GetRandomPosInPlayerDepartmentArea();
#
GetClosestPedReturns the closest ped to the given ped's location.
Returns: Ped
Params:
- ped
- Type: Ped
- Ped
#
ExampleTO get the closest ped to the player
Ped closest = GetClosestPed(Game.PlayerPed);
#
IsPlayerOnDutyReturns whether the local player is on duty.
Returns: bool
Params: -
#
Examplebool isOnDuty = IsPlayerOnDuty();
#
SetPlayerDutySets the local player's duty status.
Returns: -
Params:
- onDuty
- Type: bool
true
available,false
otherwise
#
ExampleSetPlayerDuty(true); // to set the player on duty
#
SyncBlipSyncs a blip globally (every player on the server will be able to see the synced blip).
Returns: -
Params:
- blip
- Type: Blip
- The blip that you want to sync
#
ExampleBlip blip = World.CreateBlip(...); // spawn blip with your settingsSyncBlip(blip);
#
SyncBlipWithRadiusSyncs a blip globally with radius .
Returns: -
Params:
- blip
- Type: Blip
- The blip that you want to sync
- radius
- Type: float
- The blip's radius
#
ExampleBlip blip = World.CreateBlip(...); // spawn blip with your settingsSyncBlipWithRadius(blip,125f); // sync the blip with 125f radius
#
SyncBlipDeleteDeletes a (previously) synced blip (from every connected client).
Returns: -
Params:
- blip
- Type: Blip
- The blip that you want to delete (and was previously synced)
#
ExampleBlip blip = World.CreateBlip(...); // spawn blip with your settingsSyncBlip(blip);...// later in your codeSyncBlipDelete(blip); // the blip will be deleted from every client
#
RequestBackupRequests backup for the local player (if the player is in a department).
Returns: -
Params:
- backup
- Type: Backups
- The code of the backup request (
1
,2
,3
,99
)
#
ExampleRequestBackup(Backups.Code1); // To request Code1 backup
#
CancelBackupCancels the current backup request.
Returns: -
Params: -
#
ExampleCancelBackup(); // The current backup will be cancelled
#
ForceCalloutcaution
If there are multiple callouts with the same name, the first in the collection will be selected.
Forces a FivePD callout by its GUID or name.
If the callout could not be found, an error message will be displayed in the console.
Returns: -
Params:
- identifier
- Type: string
- The name or GUID of the callout
#
ExampleForceCallout("a6f854c1-371a-4b2b-93c5-d99989552898"); // Forces a callout with the given GUID...ForceCallout("Mugging"); // Forces the "Mugging" callout
#
GetCurrentCalloutReturns the current (ongoing) callout.
Returns: Callout
Params: -
#
ExampleFivePD.API.Callout callout = GetCurrentCallout();
#
GetCalloutsReturns a list of every enabled
callout.
Returns: List<Callout>
Params: -
#
Examplevar callouts = GetCallouts();
#
ExcludeVehicleFromTrafficStopThe vehicle won't stop when the player initiates a traffic stop on the given vehicle.
Returns: -
Params:
- networkId
- Type: int
- The network id of the vehicle
#
ExampleExcludeVehicleFromTrafficStop(vehicle.NetworkId);
#
IsPlayerPerformingTrafficStopReturns whether the local player is performing a traffic stop.
Returns: bool
Params: -
#
Examplebool isPlayerInTrafficStop = IsPlayerPerformingTrafficStop();
#
GetVehicleFromTrafficStopcaution
Returns null
if the player is not in a traffic stop or the vehicle could not be found.
Returns the vehicle from the current traffic stop.
Returns: Vehicle
Params: -
#
ExampleVehicle vehicle = GetVehicleFromTrafficStop();
#
RequestServiceRequests a FivePD service to a given position.
You can request the following services:
Ambulance
AirAmbulance
FireDept
Coroner
AnimalControl
TowTruck
Mechanic
PrisonTransport
Returns: -
Params:
- service
- Type: Service
- The type of the requested service
- position
- Type: Vector3
- The position where you want to request the service
#
ExampleRequestService(Services.Ambulance,new Vector3(0,0,0));
#
CancelServiceCancels the previously requested service.
Returns: -
Params:
- service
- Type: Service
- The type of the requested service
#
ExampleCancelService(Services.Ambulance); // Cancels the previously requested Ambulance
#
GetVehicleDatainfo
This method is also available as a Vehicle extension.
See EntityExtensions
class.
Returns a VehicleData object.
Returns: VehicleData
Params:
- networkId
- Type: int
- The network id of the vehicle
#
ExampleVehicle vehicle;...VehicleData data = await GetVehicleData(vehicle.NetworkId);
string licensePlate = data.LicensePlate;
string flag = data.Flag;
int ownerNetworkID = data.OwnerNetworkID;
string ownerFirstname = data.OwnerFirstname;
string ownerLastname = data.OwnerLastname;
bool insurance = data.Insurance; // true = valid, false = invalid
bool registration = data.Registration; // true = valid, false = invalid
string color = data.VehicleColor;
string vehicleName = data.Name;
int vehicleID = data.ID;
List<Item> items = data.Items;
foreach (var elem in items){ string itemName = elem.Name; bool isIllegal = elem.IsIllegal;}
#
SetVehicleDatainfo
This method is also available as a Vehicle extension.
See EntityExtensions
class.
Returns: -
Params:
- networkId
- Type: int
- The network id of the vehicle
- vehicleData
- Type: VehicleData
- The data that you want to set
#
ExampleVehicleData vehicleData = new VehicleData();// To set insurance statusvehicleData.Insurance = false;// To set registration statusvehicleData.Registration = false;// To set itemsvar items = new List<Item>();
Item phone = new Item { Name = "Phone", IsIllegal = false};
items.Add(phone);vehicleData.Items = items; // to set items
// And then you must call the SetVehicleData method
SetVehicleData(vehicle.NetworkId,vehicleData);
#
GetPlayerDataReturns FivePD information from the local player.
Returns: PlayerData
Params: -
#
ExamplePlayerData playerData = GetPlayerData();// To get the name of the playerstring displayName = playerData.DisplayName;// To get the ID of the player's departmentint departmentID = playerData.DepartmentID;// To get the name of the player's departmentstring department = playerData.Department;// To get the player's rankstring rank = playerData.Rank;// To get the player's callsignstring callsign = playerData.Callsign;
#
GetPedDatainfo
This method is also available as a Ped extension.
See EntityExtensions
class.
Returns FivePD information about the given ped.
Returns: Task<PedData>
Params:
- networkId
- Type: int
- The network id of the ped
#
ExamplePedData data = await GetPedData(ped.NetworkId); // GetPedData returns a task// To get the name of the pedstring firstname = data.FirstName;string lastname = data.LastName;// To get the warrant (null or empty if none)string warrant = data.Warrant;// To get the licensevar license = data.License;// To get the date of birthstring dob = data.DOB;// To get the ped's blood alcohol leveldouble alcoholLevel = data.BloodAlcoholLevel;// To get the used drugsbool[] drugs = data.DrugsUsed;// drugs[0] -> Meth (if true)// drugs[1] -> Cocaine (if true)// drugs[2] -> Marijuana (if true)// To get the gender of the pedGender gender = data.Gender;// To get the age of the pedint age = data.Age;// To get the home address of the pedstring address = data.Address;// To get the items that the player possessesList<Item> items = data.Items;// To get an item from the liststring name = items[0].Name;bool isIllegal = items[0].IsIllegal;// To get the player's violationsList<Violation> violations = data.Violations;// To get a violation from the liststring offence = violations[0].Offence;string charge = violations[0].Charge;// A way to get the itemsforeach (var elem in items){ string itemName = elem.Name; bool isIllegal = elem.IsIllegal;}// A way to get the violationsforeach (var elem in items){ string offence = elem.Offence; string charge = elem.Charge;}
#
SetPedDatainfo
This method is also available as a Ped extension.
See EntityExtensions
class.
Sets information about the ped.
Returns: -
Params:
- networkId
- Type: int
- The network id of the ped
- pedData
- Type: PedData
- Object with information about the ped
#
ExampleFirst, you need to create a new PedData instance
Ped ped;...PedData data = new PedData();
To set the name of the ped
// using the same data object that we've just createddata.FirstName = "...";data.LastName = "...";
Utilities.SetPedData(ped.NetworkId,data);
To set used drugs
// using the same data object that we've just createdPedData.Drugs [] usedDrugs = new PedData.Drugs[2]; // if we want only 2 typesusedDrugs[0] = PedData.Drugs.Meth;usedDrugs[1] = PedData.Drugs.Cocaine;
Utilities.SetPedData(ped.NetworkId,data);
To set the drivers license (same with other types of licenses, eg hunting
)
// using the same data object that we've just createdPedData.License newLicense = new PedData.License();newLicense.Expiration = "10/03/2020";newLicense.Status = PedData.License.State.Expired;
Utilities.SetPedData(ped.NetworkId,data);
To set item(s)
// using the same data object that we've just createdItem item = new Item();item.Name = "Phone";item.IsIllegal = false;
data.Items = new List<Item>();
data.Items.Add(item);
Utilities.SetPedData(ped.NetworkId,data);