# Installation

{% hint style="danger" %}
Please go through each step carefully and allow enough time. Support tickets opened due to simple errors will be forwarded to the documentation.
{% endhint %}

### 1. Download

Download the latest version of the script from your [keymaster account](https://keymaster.fivem.net/).

***

### 2. Database

Add the gp\_InsuranceSystem.sql file to your database.

***

### 3. Restart your server

{% hint style="danger" %}
In order for your new asset to be recognized and the database changes to be applied, you must restart your server!
{% endhint %}

***

### 4. Society Accounts and other integrations

{% hint style="info" %}
In the server/sv\_customizeMe.lua file you will find countless functions that can be edited as desired.

In this file you will also find the function to add or remove money from a society account. If you do not use qb-banking or esx\_addonaccount, you must integrate your corresponding system in the respective functions, AddSocietyMoney and RemoveSocietyMoney.
{% endhint %}

***

### 5. Your Billing System

{% hint style="info" %}
When an invoice is issued, it should be checked directly whether the player has insurance and the invoice should be reduced by the corresponding amount. For this we need to add an export to your billing system.
{% endhint %}

{% hint style="info" %}
You don't have to do anything for JakSam's Billing UI
{% endhint %}

{% tabs %}
{% tab title="okokBilling" %}
Navigate in "sv\_utils.lua" to line 151 to&#x20;

```lua
RegisterServerEvent(Config.EventPrefix..":createInvoiceSociety")
```

and add&#x20;

```lua
price = exports['gp_InsuranceSystem']:checkInsuranceCoverage(receiverPlayer.identifier, authorPlayer.getJob().name, price)
if (price == 0) then
    return
end
```

below `local note = data.note`
{% endtab %}

{% tab title="codem-billing" %}
Navigate to "editable/server\_editable.lua" to function createBilling at line 1342.\
Insert above jobname = society in line 1379:

{% code fullWidth="true" %}

```lua
amount = exports['gp_InsuranceSystem']:checkInsuranceCoverage(targetIdentifier, society, amount)
jobname = society
```

{% endcode %}

So the if-statement should look like this:

```lua
if Config.AllowBillingJobs[society] == nil then
    if Config.SendInvoiceAsStaffAccount then
        jobname = 'identifier'
    else
        Config.Notification(Config.NotificationText['notallowpersonelaccount'].text,
                            Config.NotificationText['notallowpersonelaccount'].type, 
                            true, 
                            src)
       return
    end
else
    amount = exports['gp_InsuranceSystem']:checkInsuranceCoverage(targetIdentifier, society, amount)
    jobname = society
end
```

{% endtab %}
{% endtabs %}

***

### 6. Adding a new insurance/membership for a job

Go into the Config to the item Config.InsuranceTypes and add your new insurance/membership:

* pedModels can be found [here](https://docs.fivem.net/docs/game-references/ped-models/).

```lua
Config.InsuranceTypes = {
    --[[ Basic health insurance system ]]
    ["ambulance"] = {
        npc = {
            pedModel = "s_m_m_paramedic_01",
            coords = {
                vector4(420.7623, -1029.6794, 29.1032, 17.1359),
            },
            deactivateOnMemberCount = 1,   
            peds = {}, -- dont touch!
        },
        menuLocations = {
            vector3(427.6365, -1029.2020, 28.9919)
        }
    },
    --[[ Basic vehicle membership system ]]
    ["mechanic"] = {
        npc = {
            pedModel = "s_m_m_paramedic_01",
            coords = {
                vector4(424.8792, -1029.4376, 29.0332, 359.9969),
            },
            deactivateOnMemberCount = 1,   
            peds = {}, -- dont touch!
        },
        menuLocations = {
            vector3(429.4537, -1029.9272, 28.9554)
        }
    },
    -- your new insurance/membership you like to add
    ["unicorn"] = {
        npc = {
            pedModel = "csb_stripper_01",
            coords = {
                vector4(130.1392, -1285.2379, 29.2755, 130.4824),
            },
            deactivateOnMemberCount = 1,   
            peds = {}, -- dont touch!
        },
        menuLocations = {
            vector3(94.8770, -1294.7925, 29.2688)
        }
    },
}
```

Open the config.js file which is located at ./web/config.js.

{% hint style="info" %}
So that you can determine for each job whether it is an insurance, membership, subscription or other, you can set the most important labels and texts for the UI for each job separately.
{% endhint %}

As in the Config, you can simply copy and paste an existing translation and adjust the values. \
Make sure to replace the old jobname as well.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.gpscripts.dev/insurancesystem/installation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
