Skip to content

Callout lifecycle

Daniel K edited this page Jun 25, 2020 · 1 revision

OnAccept

Invoked when the player (presses Y) accepts the callout.
You must also initialize the default values by calling this.InitBlip().

Example:

 public async override Task OnAccept()
{
   this.InitBlip();
   ...
}

OnStart

Invoked when an AssignedPlayer gets in range of the callout. This can be either the player, who originally accepted the callout, or someone else, who is responding to a callout backup request.
The player's ped (who triggered OnStart) will be passed along.
Note: base.OnStart(player) must be called to remove the default blip and mark the callout as Started.

Example:

public override void OnStart(Ped player)
{
   base.OnStart(player); // pass the player
   ...
}

OnBackupCalled

Invoked when the player requests backup.
The backup code will be passed along, which can be either 1, 2, 3, 99

OnBackupReceived

Invoked when someone accepts the callout backup request.
The player's ped will be passed along.

OnPlayerRevokedBackup

Invoked when someone stops responding to the callout backup request.
The player's ped will be passed along.

OnCancelBefore

Invoked when the player presses the Code 4 button, but before clearing entities.
This can be useful if you are storing your entities in objects ( because FivePD might not be able to clear them ), so you can manually remove spawned entities, blips, etc that.
Note: Always check for null.

Example:

internal class MyEntityStorage
{
   public Ped ped;
   public Blip blip;
}

MyEntityStorage storage; // Spawn and store your entities

...

public override void OnCancelBefore() 
{ 
   if(storage != null)
   {
      ped?.MarkAsNoLongerNeeded();
      blip?.Delete();
   }
}

OnCancelAfter

Invoked after clearing the callout, after OnCancelBefore().

Clone this wiki locally