Callout
FivePD.API
#
Namespace: Source/Callout.cs
#
File: #
Fields#
AssignedPlayersType:List<Ped>A list of players that have accepted the callout.
note
The Game.PlayerPed
is always present in the list.
#
CalloutDescriptionType:stringThe description of the callout. This will be displayed in the 'MDT'.
#
ShortNameType:stringThe shortname of the callout. This will be displayed in notifications (header).
#
CaseIDType:stringCaseID is a unique, randomly generated identifier. You must not modify the value (unless you know what you are doing).
#
ResponseCodeType:intThe value should be either 1
, 2
, 3
, or 99
.
#
StartDistanceType:floatIf the player is in range, the callout will automatically start.
#
LocationType:Vector3The 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.
#
MarkerType:BlipThe blip that will be used to mark the location on the map.
#
IdentifierType:stringA unique identifier generated by the Callout Manager for each, new callout. You must not modify the value (unless you know what you are doing).
#
StartedType:boolThe value will be set to true once the callout starts.
#
FixedLocationType:boolIf 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)
#
RadiusType:floatThe radius of the callout (map).
#
Methods#
SpawnPedSpawns 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
#
Exampleawait SpawnPed(PedHash.Agent,new Vector3(0f,0f,0f),180f);
#
SpawnVehicleSpawns 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
#
Exampleawait SpawnVehicle(VehicleHash.Ambulance,new Vector3(0f,0f,0f),180f);
#
AddPedQuestionAdds 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
#
ExamplePed suspect;PedQuestion question = new PedQuestion();question.Question = "Where have you been today?";question.Answers = new List<string>{ "At home", "At work"};AddPedQuestion(ped,question);
#
AddPedQuestionsAdds 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
#
ExamplePed 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);
#
ShowDialogDisplays 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
#
ExampleThe following code displays 'Hello!' in a 15f
radius for 5 seconds.
ShowDialog("Hello!",5000,15f);
#
ShowNetworkedNotificationDisplays 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
#
ExampleThe following code displays a notification in a 15f
radius.
ShowNetworkedNotification("Hello!","CHAR_CALL911","CHAR_CALL911","Sender","Subject",15f);
#
EndCalloutTerminates the current callout.
Returns: -
Params: -
#
Examplebase.EndCallout();
#
UpdateDataUpdates 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!");
#
CheckRequirementsCallout 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: -
#
Examplepublic 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}
#
OnAcceptcaution
base.InitBlip() must be called to initialize default values!
Lifecycle method.
Invoked when the player accepts the callout.
Returns: -
Params: -
#
Examplepublic async override Task OnAccept(){ this.InitBlip(); ...}
#
OnStartcaution
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
#
Examplepublic override void OnStart(Ped player){ base.OnStart(player); // pass the player ...}
#
OnBackupCalledEvent.
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
#
Examplepublic 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; ... }}
#
OnBackupReceivedInvoked 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
#
Examplepublic override void OnBackupReceived(Ped player){ ...}
#
OnPlayerRevokedBackupInvoked when a player stops responding to the callout's backup request.
Returns: -
Params:
- player
- Type: Ped
- The player who cancelled the backup request
#
Examplepublic override void OnPlayerRevokedBackup(Ped player){ ...}
#
OnCancelBeforeLifecycle 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: -
#
Exampleinternal 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(); }}
#
OnCancelAftercaution
Spawned entities might be null at this point.
Lifecycle method.
Invoked after clearing the callout, after OnCancelBefore()
.
Returns: -
Params: -
#
Examplepublic override void OnCancelAfter() { // most of the spawned entities are null at this point}