Skip to main content

Callout


Namespace: FivePD.API#
File: Source/Callout.cs#

Fields#

AssignedPlayers#

Type:List<Ped>

A list of players that have accepted the callout.

note

The Game.PlayerPed is always present in the list.

CalloutDescription#

Type:string

The description of the callout. This will be displayed in the 'MDT'.

ShortName#

Type:string

The shortname of the callout. This will be displayed in notifications (header).

CaseID#

Type:string

CaseID is a unique, randomly generated identifier. You must not modify the value (unless you know what you are doing).

ResponseCode#

Type:int

The value should be either 1, 2, 3, or 99.

StartDistance#

Type:float

If the player is in range, the callout will automatically start.

Location#

Type:Vector3

The location of the callout. The position (by default) will be marked on the map, and a waypoint will also be set for the local player.

Marker#

Type:Blip

The blip that will be used to mark the location on the map.

Identifier#

Type:string

A unique identifier generated by the Callout Manager for each, new callout. You must not modify the value (unless you know what you are doing).

Started#

Type:bool

The value will be set to true once the callout starts.

FixedLocation#

Type:bool

If the value is set to true, only 1 player on the server can receive this callout. (It won't be generated for other players until the scene is cleaned up)

Radius#

Type:float

The radius of the callout (map).


Methods#

SpawnPed#

Spawns a properly networked ped.

The ped will be marked as a mission entity.

Returns: Task<Ped>

Params:

  • pedHash
    • Type: PedHash
    • PedHash value
  • location
    • Type: Vector3
    • The spawn location of the ped
  • heading
    • Type: float
    • Heading direction

Example#

await SpawnPed(PedHash.Agent,new Vector3(0f,0f,0f),180f);

SpawnVehicle#

Spawns a properly networked vehicle.

The vehicle will be marked as a mission entity.

Returns: Task<Ped>

Params:

  • vehicleHash
    • Type: VehicleHash
    • VehicleHash value
  • location
    • Type: Vector3
    • The spawn location of the vehicle
  • heading
    • Type: float
    • Heading direction

Example#

await SpawnVehicle(VehicleHash.Ambulance,new Vector3(0f,0f,0f),180f);

AddPedQuestion#

Adds a (temp) question to the callout's ped question menu.

The question will be removed once the callout is over.

Returns: -

Params:

  • question
    • Type: PedQuestion
    • A PedQuestion instance

Example#

Ped suspect;PedQuestion question = new PedQuestion();question.Question = "Where have you been today?";question.Answers = new List<string>{    "At home",    "At work"};AddPedQuestion(ped,question);

AddPedQuestions#

Adds an array of (temp) questions to the callout's ped question menu.

The questions will be removed once the callout is over.

Returns: -

Params:

  • question
    • Type: PedQuestion[]
    • An array of PedQuestion instances

Example#

Ped suspect;PedQuestion question = new PedQuestion();question.Question = "Where have you been today?";question.Answers = new List<string>{    "At home",    "At work"};
PedQuestion [] pedQuestions = new PedQuestion[]{    question // You can add multiple questions};
AddPedQuestions(ped,question);

ShowDialog#

Displays a networked dialog for every player in a given radius.

Returns: -

Params:

  • question
    • Type: string
    • The message that you want to display
  • duration
    • Type: int
    • How long should the message be displayed ( in ms, 1000ms = 1s )
  • radius
    • Type: float
    • Display radius

Example#

The following code displays 'Hello!' in a 15f radius for 5 seconds.

ShowDialog("Hello!",5000,15f);

ShowNetworkedNotification#

Displays a networked notification message for every player in a given radius.

Returns: -

Params:

  • text
    • Type: string
    • The message that you want to display
  • textureDict
    • Type: string
    • Texture dictionary
  • textureName
    • Type string
    • Texture name
  • sender
    • Type: string
    • The name of the sender
  • subject
    • Type: string
    • Subject
  • radius
    • Type: float
    • Display radius

Example#

The following code displays a notification in a 15f radius.

ShowNetworkedNotification("Hello!","CHAR_CALL911","CHAR_CALL911","Sender","Subject",15f);

EndCallout#

Terminates the current callout.

Returns: -

Params: -

Example#

base.EndCallout();

UpdateData#

Updates the following data in the 'MDT' (and in the dispatch window):

  • ShortName
  • ResponseCode
  • Description
  • Location (based on the coordinates)

To change these values, you have to update it in your instance and then call the UpdateData() method.

By calling UpdateData(), the computer and the dispatch window will display the latest info of your callout.

If you pass a string (optional) to UpdateData(), the location will be changed to the given string (custom text).

Returns: -

Params:

  • location (optional)
    • Type: string
    • Custom location text

Example#

// call UpdateData() somewhere in your code...this.ShortName = "New name!";this.ResponseCode = 1;this.Description = "New description!";this.Location = new Vector3(x,y,z);  UpdateData();...

With custom text

UpdateData("My location!");

CheckRequirements#

Callout requirements.

This method is called before your called is initiated.

If it returns true, the callout will start, otherwise it'll be skipped.

Default return value is true.

See Issue #10.

Returns: bool

Params: -

Example#

public override async Task<bool> CheckRequirements(){    if (World.CurrentDayTime.Hours < 20)    return false; // Your callout won't start if the time is less than 20    return true; // start your callout}

OnAccept#

caution

base.InitBlip() must be called to initialize default values!

Lifecycle method.

Invoked when the player accepts the callout.

Returns: -

Params: -

Example#

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

OnStart#

caution

base.OnStart(player) must be called to remove the default blip, and mark the callout as Started.

Lifecycle method.

Invoked when (any) player gets in range of the callout.

The player ped ( who triggered the event ) will be passed as a param.

Returns: -

Params:

  • player
    • Type: Ped
    • The player who triggered the event

Example#

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

OnBackupCalled#

Event.

Invoked when the local player requests a backup.

The backup code will be passed as a parameter, which can be either 1, 2, 3, or 99.

Returns: -

Params:

  • code
    • Type: int
    • The code of the backup request

Example#

public override void OnBackupCalled(int code){   switch(code)   {       case 1:           // do something if code is 1           break;        case 2:            // do something if code is 2            break;        ...   }}

OnBackupReceived#

Invoked when a player (another) accepts the local player's backup request.

The player who accepted the backup will be passed as a parameter.

Returns: -

Params:

  • player
    • Type: Ped
    • The player who accepted the backup request

Example#

public override void OnBackupReceived(Ped player){   ...}

OnPlayerRevokedBackup#

Invoked when a player stops responding to the callout's backup request.

Returns: -

Params:

  • player
    • Type: Ped
    • The player who cancelled the backup request

Example#

public override void OnPlayerRevokedBackup(Ped player){   ...}

OnCancelBefore#

Lifecycle method.

Invoked when the player presses the Code 4 button (before marking entities as no longer needed).

This can be useful if you are storing your entities in nested objects ( because FivePD might not be able to clear those automatically ), so you can manually remove your spawned entities, blips, etc.

Returns: -

Params: -

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#

caution

Spawned entities might be null at this point.

Lifecycle method.

Invoked after clearing the callout, after OnCancelBefore().

Returns: -

Params: -

Example#

public override void OnCancelAfter() {    // most of the spawned entities are null at this point}