Skip to main content

Events


Namespace: FivePD.API#
File: Source/Events.cs#
info

Events can also be captured with EventHandlers, so you can create standalone scripts that use FivePD events.


Events#

OnCalloutReceived#

Raised when the local player received a callout.

Returns: Task

Params:

  • callout
    • Type: Callout
    • The received callout

Example#

...using CitizenFX.Core;using FivePD.API;
class MyScript : Plugin{  internal MyScript()  {    // constructor must be internal!    Events.OnCalloutReceived += OnCalloutReceived;  }  public async Task OnCalloutReceived(FivePD.API.Callout callout)  {    // this method will be called when the player receives a callout    ...  }}

OnCalloutAccepted#

Raised when the local player accepts a callout.

Returns: Task

Params:

  • callout
    • Type: Callout
    • The accepted callout

Example#

...using CitizenFX.Core;using FivePD.API;
class MyScript : BaseScript{  internal MyScript()  {    // constructor must be internal!    Events.OnCalloutAccepted += OnCalloutAccepted;  }  public async Task OnCalloutAccepted(FivePD.API.Callout callout)  {    // this method will be called when the player accepts a callout    ...  }}

OnCalloutCompleted#

Raised when the local player completes a callout.

Returns: Task

Params:

  • callout
    • Type: Callout
    • The completed callout

Example#

using CitizenFX.Core;using FivePD.API;
class MyScript : BaseScript{  internal MyScript()  {    // constructor must be internal!    Events.OnCalloutCompleted += OnCalloutCompleted;  }  public async Task OnCalloutCompleted(FivePD.API.Callout callout)  {    // this method will be called when the player completes a callout    ...  }}

OnDutyStatusChange#

Raised when the player's duty status changes.

Returns: Task

Params:

  • onDuty
    • Type: bool
    • true available, false otherwise

Example#

...using CitizenFX.Core;using FivePD.API;
class MyScript : BaseScript{  internal MyScript()  {    // constructor must be internal!    Events.OnDutyStatusChange += OnDutyChange;  }  public async Task OnDutyChange(bool onDuty)  {    // this method will be called when the player goes on/off duty    if(onDuty)    {      // the player went on duty      ...    }    else    {      // the player went off duty      ...    }  }}

OnServiceCalled#

Raised when the local player requests a service.

Returns: Task

Params:

  • service
    • Type: Service
    • The type of the requested service (enum)

Example#

...using CitizenFX.Core;using FivePD.API;
class MyScript : BaseScript{  internal MyScript()  {    // constructor must be internal!    Events.OnServiceCalled += OnServiceCalled;  }  // The 'Utilities' class contains the Services enum (available services)  public async Task OnServiceCalled(Utilities.Services service)  {    // this method will be called when the player requests a service    ...  }}

OnRankChanged#

Raised when the local player's rank changes.

Returns: Task

Params:

  • rank
    • Type: string
    • The name of the player's new rank

Example#

...using CitizenFX.Core;using FivePD.API;
class MyScript : BaseScript{  internal MyScript()  {    // constructor must be internal!    Events.OnRankChanged += OnRankChanged;  }  // The 'Utilities' class contains the Services enum (available services)  public async Task OnRankChanged(string rank)  {    // this method will be called when the player's rank changes    ...  }}

OnPedArrested#

Raised when a ped gets arrested by the local player.

Returns: Task

Params:

  • ped
    • Type: Ped
    • The arrested ped

Example#

...using CitizenFX.Core;using FivePD.API;
class MyScript : BaseScript{  internal MyScript()  {    // constructor must be internal!    Events.OnPedArrested += OnPedArrested;  }  public async Task OnPedArrested(Ped ped)  {    // this method will be called when a ped gets arrested    ...  }}