Events
Daniel K edited this page Jun 28, 2020
·
1 revision
From v1.0, you can subscribe to and call FivePD events. These events can be used after the script has loaded (FivePD).
Note that these events are independent and don't require you to use it in callouts (so you can create addon scripts with FivePD events (Must be a FivePD plugin!) ).
Raised when the player receives a callout.
Passed:
-
callout
<Callout>
- The callout that the player has received
Example:
...
using CitizenFX.Core;
using FivePD.API;
class MyScript : BaseScript
{
public MyScript()
{
Events.OnCalloutReceived += OnCalloutReceived;
}
public async Task OnCalloutReceived(FivePD.API.Callout callout)
{
...
}
}
Raised when the player accepts a callout.
Passed:
-
callout
<Callout>
- The callout that the player has accepted
Example:
...
using CitizenFX.Core;
using FivePD.API;
class MyScript : BaseScript
{
public MyScript()
{
Events.OnCalloutAccepted += OnCalloutAccepted;
}
public async Task OnCalloutAccepted(FivePD.API.Callout callout)
{
...
}
}
Raised when the player completes a callout.
Passed:
-
callout
<Callout>
- The callout that the player has completed
Example:
...
using CitizenFX.Core;
using FivePD.API;
class MyScript : BaseScript
{
public MyScript()
{
Events.OnCalloutCompleted += OnCalloutCompleted;
}
public async Task OnCalloutCompleted(FivePD.API.Callout callout)
{
...
}
}
Raised when the player goes on/off duty.
Params: onDuty
<bool>
(true
= on, false
= off)
Example:
...
using CitizenFX.Core;
using FivePD.API;
class MyScript : BaseScript
{
public MyScript()
{
Events.OnDutyStatusChange += OnDutyChange;
}
public async Task OnDutyChange(bool onDuty)
{
if(onDuty)
{
// the player went on duty
...
}
else
{
// the player went off duty
...
}
}
}
Raised when the player requests a service.
Params: service
<enum>
Services:
Ambulance
AirAmbulance
FireDept
Coroner
AnimalControl
TowTruck
Mechanic
PrisonTransport
Example:
...
using CitizenFX.Core;
using FivePD.API;
class MyScript : BaseScript
{
public MyScript()
{
Events.OnServiceCalled += OnServiceCalled;
}
// The `Utilities` class contains the Services enum (available services)
public async Task OnServiceCalled(Utilities.Services service)
{
...
}
}