# Integration

{% hint style="warning" %}
WARNING: ONLY MESS WITH THESE IF YOU KNOW WHAT YOU ARE DOING!!!!
{% endhint %}

### Payphone

{% hint style="info" %}
There is many different types of phones out there so this event is open for you to incorporate whatever you could possibly need!
{% endhint %}

```lua
RegisterNetEvent("DHS-PrisonSim:client:UsePayphone", function()
    if Config.Phone == "lb-phone" then
        local phoneNumber = lib.inputDialog("Enter Phone Number", {
            { type = "input", label = "Phone Number", default = "1234567890" }
        })
        if phoneNumber then
            TriggerServerEvent("DHS-PrisonSim:server:UsePayphoneLB", phoneNumber)
        end
    elseif Config.Phone == "custom" then
        -- Custom Phone Function Here
    end
end)
```

***

### Convoy Start,End, and InConvoy Functions

{% hint style="info" %}
Sometimes you may need to do something on Convoy Start, End or even the minute they are in the convoy, this could be useful for a seatbelt script or something else you might need to do!
{% endhint %}

```lua
function OnConvoyStart()
    -- Triggers When The Convoy Starts
end

function PrisonerInConvoyVehicle()
    -- Probabaly Some Seatbelt Function or Something
end

function OnConvoyEnd()
    -- Triggers When The Convoy Ends
end
```

***

### Gate Door Minigame

{% hint style="info" %}
By default we use ox\_lib for the Gate Door minigame however, in the DHS-PrisonSim/client/editablefunctions\_cl.lua you can edit this to match whatever minigame you want.
{% endhint %}

```lua
function GateDoorMinigame()
    local success = lib.skillCheck({'easy', 'easy', 'easy', 'easy'}, {'w', 'a', 's', 'd'})
    if success then
        return true
    else
        return false
    end
end
```

***

### Workout Minigame

{% hint style="info" %}
By default we use ox\_lib for the workout minigame however, in the DHS-PrisonSim/client/editablefunctions\_cl.lua you can edit this to match whatever minigame you want.
{% endhint %}

```lua
function WorkoutMinigame(info)
    local success = lib.skillCheck({'medium'}, {'w', 'a', 's', 'd'})
    if success then
        TriggerEvent("DHS-PrisonSim:client:WorkoutSuccess", info)
    else
        TriggerEvent("DHS-PrisonSim:client:WorkoutFailed")
    end
end
```

***

### Medical Script Functionality

{% hint style="info" %}
As their is many medical scripts we felt the best way to provide support for healing prisoners was to have a completely open function where you can do absolutely anything you need to make sure your medical script hooks perfectly into PrisonSim if you have any issues open a ticket and we will be glad to help you!
{% endhint %}

```lua
function CustomMedicalFunction()
    -- Custom Medical Function Here
end

RegisterNetEvent("DHS-PrisonSim:client:MedicalEvent", function()
    if Config.UseBuiltInMedicalSystem then
        TriggerEvent("DHS-PrisonSim:client:PrisonHealthCare")
    else
        TriggerEvent("DHS-PrisonSim:client:CustomMedicalFunction")
    end
end)
```

***

### Dispatch Function

{% hint style="info" %}
By default we use qbcore built in system however we have support for both:

* ps-dispatch
* cd-dispatch

however if you know what you are doing you can implement your own as well.

* DHS-PrisonSim/client/editablefunctions\_cl.lua
  {% endhint %}

```lua
function CallPolice(message)
    if Config.DispatchSystem == "qbcore" then
        TriggerServerEvent('police:server:policeAlert', message)
    elseif Config.DispatchSystem == "ps-dispatch" then
        --exports['ps-dispatch']:SuspiciousActivity()
    elseif Config.DispatchSystem == "cd-dispatch" then

        -- local data = exports['cd_dispatch']:GetPlayerInfo()
        -- TriggerServerEvent('cd_dispatch:AddNotification', {
        --     job_table = {'police'},
        --     coords = data.coords,
        --     title = '10-15 - Illegal Fishing Activity',
        --     message = 'A '..data.sex..' using illegal bait at '..data.street,
        --     flash = 0,
        --     unique_id = tostring(math.random(0000000,9999999)),
        --     blip = {
        --         sprite = 431,
        --         scale = 1.2,
        --         colour = 3,
        --         flashes = false,
        --         text = '911 - Illegal Fishing Activity',
        --         time = (5*60*1000),
        --         sound = 1,
        --     }
        -- })
    else
        if Config.Debug then
            print("No Dispatch System Selected")
        end
    end
end
```

***

### Notify System

{% hint style="info" %}
By default we use the built in qbcore notify system however we also support ox\_lib notify but if you know what you are doing you can integrate this as well.

* DHS-PrisonSim/client/editablefunctions\_cl.lua
  {% endhint %}

```lua
function Notify(text, type, time)
    if Config.Notify == "qbcore" then
        local QBCore = exports['qb-core']:GetCoreObject()
        QBCore.Functions.Notify(text, type, time)
    elseif Config.Notify == "ox_lib" then
        lib.notify({
            title = text,
            type = type,
            duration = time
        })
    else
        print("No Notify System Selected")
    end
end
```

***

### Reset Clothing

{% hint style="info" %}
By Default we use Illenium appearance however you can change this to whatever you use

* DHS-PrisonSim/client/editablefunctions\_cl.lua
  {% endhint %}

```lua
function ResetClothing()
    if Config.Clothing == "illenium-appearance" then
        TriggerEvent("illenium-appearance:client:reloadSkin")
    elseif Config.Clothing == "custom" then
        --Custom Clothing System Here
    end
end
```

***

### Fuel System

{% hint style="info" %}
We support many different fuel systems and we make it quite easy to add your own
{% endhint %}

````lua
local fuelEvent = nil

function RefuelVehicle(vehicle)
    if GetResourceState('ox_fuel') ~= 'started' then
      exports[fuelEvent]:SetFuel(vehicle, 100)
      return
    elseif GetResourceState('ox_fuel') == 'started' then
      Entity(vehicle).state.fuel = 100.0
      return
    end
    print('ERROR: No Fuel Resource Detected')
    fuelEvent = nil
end

```lua
CreateThread(function()
    if GetResourceState('LegacyFuel') == 'started' then
       fuelEvent = 'LegacyFuel'
       return
    end
    if GetResourceState('cdn-fuel') == 'started' then
      fuelEvent = 'cdn-fuel'
      return
    end
    if GetResourceState('BigDaddy-Fuel') == 'started' then
      fuelEvent = 'BigDaddy-Fuel'
      return
    end
    if GetResourceState('ps-fuel') == 'started' then
      fuelEvent = 'ps-fuel'
      return
    end
    if GetResourceState('okokGasStation') == 'started' then
      fuelEvent = 'okokGasStation'
      return
    end
    if GetResourceState('qs-fuelstations') == 'started' then
        fuelEvent = 'qs-fuelstations'
        return
    end
end)
````

***

### Custom Vehicle Function

{% hint style="info" %}
If your needing to do something specific like paint or change the livery of the convoy vehicles do so here
{% endhint %}

```lua
function CustomVehicleFunction(vehicle, model)
    if model == "policet" then
        -- Custom Vehicle Function Here
    elseif model == "pbus" then
        -- Custom Vehicle Function Here
    elseif model == "police" then
        -- Custom Vehicle Function Here
    elseif model == "riot" then
        -- Custom Vehicle Function Here
    end
end
```

***

### Give Keys Function

{% hint style="info" %}
If your using a different vehicle key system put it here
{% endhint %}

```lua
function GiveKeys(plate)
    if Config.VehicleKeys == 'qb-vehiclekeys' then
        TriggerEvent("vehiclekeys:client:SetOwner", plate)
    else
        if Config.Debug then
            print("No Vehicle Key System Selected")
        end
    end
end
```

***

### Gate Door Minigame

{% hint style="info" %}
For those that use the gate door escape you can change the minigame for hacking the gate here
{% endhint %}

```lua
function GateDoorMinigame()
    local success = lib.skillCheck({'easy', 'easy', 'easy', 'easy'}, {'w', 'a', 's', 'd'})
    if success then
        return true
    else
        return false
    end
end
```

***

### On Prisoner Sentenced Function

{% hint style="info" %}
When the prisoner is sentenced you can have something happen like notifying the whole server or whatever it is you want to do
{% endhint %}

```lua
function OnPrisonerSentenced(sentenceTime)
    print("Prisoner Sentenced For: " .. sentenceTime)
    -- Triggers When The Prisoner Is Sentenced
end
```

***
