-
Notifications
You must be signed in to change notification settings - Fork 25
Using the API
So you may have looked at the API already, and you might be thinking, "Well, what am I suppose to do with this?".
This page will explain just that.
Note: I'll be using the wrapper class throughout this explanation.
Another note: When calling any of the API functions, you must check if Computer+ 1.3.0.0 or higher is running or not. Not doing this will cause crashes. This is covered in Albo1125's API guide.
One more note: I've uploaded an example callout. If you just want to look at that, you can find it here.
Last note I promise: Consider making a CalloutBase class that the rest of your callouts inherit from. This will make your life a lot easier. Check out Stealth22's inheritance example for more info.
The first step to integrating your callout with the computer is creating it and getting your unique ID. With the use of the wrapper class, this can be done by simply calling
CreateCallout(string CallName, string ShortName, Vector3 Location, int ResponseType, string Description = "", int CallStatus = 1, List<Ped> CallPeds = null, List<Vehicle> CallVehicles = null)
Yes, there are a lot of parameters. But don't be overwhelmed! Only half of them are required.
CallName is the full name of your call. This is what you will see on the Active Call screen.
ShortName is a shorter name for your call. If your call name isn't longer than 5 or so words, there's no harm in making the short name the same as your call name. This is what you will see on the Call List screen.
Location is the location of your callout.
ResponseType is the response type needed for your callout. Use the EResponseType enum.
(Optional) Description is the description of your callout. This is what the user will see in the "Comments" area of the Active Call screen. This is also where you can give suspect or vehicle descriptions, but full names and license plates should be left to CallPeds and CallVehicles. If not specified, the player will not be given a description. This can be updated as the callout progresses.
(Optional) CallStatus is the initial status of your call. You can set this to either Created or Dispatched by using the ECallStatus enum. If not specified, call status will start off as Created. This can be updated as the callout progresses.
(Optional) CallPeds are all peds relevant to your call. All peds in this list with have their names displayed on the Active Call screen. Don't be afraid to leave this part blank - you can add peds to your call as it progresses. This can add a layer of realism to your callouts.
(Optional) CallVehicles are all vehicles relevant to your call. All vehicles in this list will have their license plates shown on the Active Call screen. Similar to CallPeds, this can be updated as the call progresses.
Once the function has created your callout, it will return a Guid. This is what you will use to refer to your callout for the rest of the functions. Store this somewhere your entire class can access.
In this section, I'll be explaining the use for every other function in the wrapper class.
UpdateCalloutStatus(Guid ID, int Status)
This function updates the current status of your callout. Use the ECalloutStatus enum to specify a specific status.
UpdateCalloutDescription(Guid ID, string Description)
This function updates the description of your callout. If you just want to add a small update rather than change the entire description, use AddUpdateToCallout.
SetCalloutStatusToAtScene(Guid ID)
This function changes the callout's status to At Scene. You'll typically want to call this when the player is, well, at the scene.
SetCalloutStatusToUnitResponding(Guid ID)
This function changes your callout's status to Unit Responding. Call this in your OnCalloutAccepted() function.
ConcludeCallout(Guid ID)
This function changes your callout's status to Completed and concludes it. Call this in your End() function.
CancelCallout(Guid ID)
This function is similar to ConcludeCallout, but will instead change your callout's status to Cancelled. This should typically be called when your callout runs into an error.
AddPedToCallout(Guid ID, Ped PedToAdd)
This function adds a ped to the Active Call screen. This is where the ped's name is displayed for easy searching. You'll typically want to call this when a new ped is introduced.
AddVehicleToCallout(Guid ID, Vehicle VehicleToAdd)
This function adds a vehicle to the Active Call screen. This is where the vehicle's license plate is displayed for easy searching. You'll typically want to call this when a new vehicle is introduced.
AddUpdateToCallout(Guid ID, string Update)
This function adds a small update to your callout. For example, you could call this when you get a better description of a suspect.
AssignCallToAIUnit(Guid ID)
This function assigns your callout to an AI unit. It will simulate the AI unit's response in the computer, dynamically changing the callout's status over different periods of time. Call this in your OnCalloutNotAccepted() function.