# gpScripts

Official documentation site.

Hey, nice that you found here!

Before you open a support Ticket, please have a look on those pages!

If you still have problems installing, or notice other bugs, feel free to join my [Discord](https://discord.gg/zRg8HdSH5W) and open a support ticket.

My scripts:

* [gp\_Emergencyphone](https://forum.cfx.re/t/paid-esx-emergency-phone-leitstellen-script/3339180/2)
* [gp\_Visum](https://forum.cfx.re/t/paid-esx-visasystem-visumsystem-by-gpscripts/4900715)
* [gp\_BusinessCard](https://forum.cfx.re/t/esx-paid-gp-businesscards-give-businesscards-to-other-players/3326197)
* [gp\_RandomDealer](https://forum.cfx.re/t/paid-esx-randomdealer-add-random-dealer-to-your-server/3564929)
* [gp\_NewPhoneNumber](https://forum.cfx.re/t/paid-esx-change-phone-number-gp-newphonenumber/3381102)
* [gp\_NoHUD](https://forum.cfx.re/t/paid-esx-nohud-hunger-and-thirst-notifications/4771352)
* [gp\_vehicleTracker](https://forum.cfx.re/t/esx-gp-vehicletracker-easy-vehicle-tracker/4774176) (Currently not available)
* [gp\_TaxSystem](https://forum.cfx.re/t/paid-esx-qb-advanced-tax-system-umfangreiches-steuersystem/5028062)
* [gp\_InsuranceSystem](https://forum.cfx.re/t/insurance-membershipsystem-esx-qb-gpscripts/5177462)
* gp\_Clothingshop (Coming soon)
* [gp\_AdventCalendar](https://forum.cfx.re/t/esx-qb-paid-chirstmas-advent-calendar-clean-and-simple-ui/5188178/1)


# Installation

Installation Steps for gp\_Clothingshop.

{% 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. Framework adjustments

{% tabs %}
{% tab title="QB" %}
***a)*** Open ***qb-clothing/client/main.lua*** and insert this code snipped.

```lua
-- Exports for gp_Clothingshop
exports('SaveSkin', SaveSkin)
exports('ChangeVariation', ChangeVariation)
-- end of exports for gp_Clothingshop
```

***b)*** Navigate to  ***qb-clothing/config.lua***\
&#x20;    Remove  every shop you do not need in Config.Shops.\
&#x20;    Remove every wardrobe you dont need in Config.OutfitChangers.\
&#x20;    Remove every clothingroom you dont need in Config.ClothingRooms.&#x20;

***c)*** Restart your Server to apply the changes!\
&#x20;    Some Scripts have qb-clothing as dependency. So do not just restart the Script!
{% endtab %}

{% tab title="ESX" %}
{% hint style="success" %}
No Framework adjustments needed!
{% endhint %}
{% endtab %}
{% endtabs %}

### 3. Insert SQL

{% tabs %}
{% tab title="QB" %}

```sql
# Insert SQL to your database

ALTER TABLE player_outfits
ADD outfitCode BIGINT,
ADD outfitCodePrice INT;
```

{% endtab %}

{% tab title="ESX" %}
{% hint style="warning" %}
First of all, please check whether you have a user\_clothes table. If this is NOT the case, please execute this SQL, which adds the corresponding table to your database.
{% endhint %}

```sql
# Only need if you DO NOT have a user_clothes table!

CREATE TABLE IF NOT EXISTS `user_clothes` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `identifier` varchar(46) DEFAULT NULL,
  `name` varchar(60) DEFAULT NULL,
  `clothesData` longtext DEFAULT NULL,
  `outfitCode` bigint(20) DEFAULT NULL,
  `outfitCodePrice` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
```

{% hint style="warning" %}
If you have a user\_clothes table then use the following SQL
{% endhint %}

```sql
# SQL if you already have a user_clothes table

ALTER TABLE user_clothes
ADD outfitCode BIGINT,
ADD outfitCodePrice INT;
```

{% endtab %}
{% endtabs %}

Restart your server in order to apply database changes.

### 4. Set configuration file

Go through the ***gp\_Clothingshop/configs/config.lua*** file step by step and adjust it to suit your needs. \
All points are described in the file and should be clear so far.&#x20;

### 5. Translate the Script

{% hint style="info" %}
The script must be translated at several points.
{% endhint %}

a) Translation of ***gp\_Clothingshop/locales/de.lua*** or ***gp\_Clothingshop/locales/en.lua*** or create a new\
&#x20;    one like the other ones.

b) Translation of ***gp\_Clothingshop/locales/ui\_translations.js***\
&#x20;    This file contains one of two halves for the translation of the UI.\
&#x20;    Simply translate this file to your liking.

c) The second half of the UI translation must be translated in ***gp\_Clothingshop/web/index.html***.\
&#x20;    This file contains the basic structure of the UI. Translate the remaining parts.

{% hint style="warning" %}
It is quite possible that I have overlooked translations myself and they are still in the encrypted files. If this is the case, please open a ticket on my [Support Discord](https://discord.gg/zRg8HdSH5W) and I will take care of it. Thanks!
{% endhint %}

### 6. Explanation of Config.js

You can create clothing stores in the in-game creator. There are 3 drop-down menus for the *clothing categories, blacklist and clothing categories that can be hidden.*

{% tabs %}
{% tab title="ClothingCategories" %}
Here is a small excerpt of ***ClothingCategories***.

```lua
ClothingCategories: {
    basic: {
        1: {
            name: 'helmet_1',
            label: 'Helmet',
            price: 100,
            defaultPerspective: 'head',
        },
        2: {
            name: 'glasses_1',
            label: 'Glasses',
            price: 100,
            defaultPerspective: 'head',
        }
    }
},
```

a) “basic” is the name of the setting.

b) The added categories must be numbered consecutively.

c) Each category must contain a name, label, price and defaultPerspective.

<table><thead><tr><th width="94"></th><th width="151">name</th><th>label</th><th>price</th><th>defaultPerspective</th></tr></thead><tbody><tr><td>data typ</td><td>string</td><td>string</td><td>number</td><td>string or nil</td></tr><tr><td>info</td><td>The componentID of the clothing component.</td><td>Label what is displayed in the clothing store. </td><td>The price that is charged.</td><td>The camera setting that is set when the category is selected.</td></tr></tbody></table>

***Example of a new Setting named "mask":***

<pre class="language-lua" data-full-width="true"><code class="lang-lua">ClothingCategories: {
    basic: {
        1: {
            name: 'helmet_1',
            label: 'Helmet',
            price: 100,
            defaultPerspective: 'head',
        },
        2: {
            name: 'glasses_1',
            label: 'Glasses',
            price: 100,
            defaultPerspective: 'head',
        }
    },
    mask: {
        1: {
            name: 'mask_1',
            label: 'Masks',
            price: 250,
            defaultPerspective: 'head',
        }
<strong>    }
</strong>}
</code></pre>

{% endtab %}

{% tab title="ClothingBlacklist" %}
Here is a small excerpt of ***ClothingBlacklist***.

<pre class="language-lua"><code class="lang-lua"><strong>ClothingBlacklist: {
</strong>    basic: {
        male: {
            tshirt_1: [10, 17, 21],
        },
        female: {
            tshirt_1: [18],
        },
    }
},
</code></pre>

a) “basic” is the name of the setting.

b) Each setting **must** contain both “male” and “female”, even if it is empty.

c) The individual componentIDs can now be added. The numbers that are listed in black can simply be separated by a comma.

***Example of a new Setting named "noCopClothing":***

```lua
ClothingBlacklist: {
    basic: {
        male: {
            tshirt_1: [10, 17, 21],
        },
        female: {
            tshirt_1: [18],
        },
    },
    noCopClothing: {
        male: {
            tshirt_1: [71, 30, 90, 102],
            torso_1: [24, 68, 83]
        },
        female: {
            tshirt_1: [72, 29, 89, 103],
            torso_1: [19, 66, 53]
        },
    }
},
```

{% hint style="danger" %}
The setting for noCopClothing is just an example! The numbers and categories are randomly selected and are for demonstration purposes only!
{% endhint %}
{% endtab %}

{% tab title="CategoriesToHide" %}
Here is a small excerpt of ***CategoriesToHide.***

<pre class="language-lua"><code class="lang-lua"><strong>CategoriesToHide: {
</strong>    basic: {
        1: {
            name: 'helmet_1',
        },
        2: {
            name: 'mask_1',
        },
    },
},
</code></pre>

a) “basic” is the name of the setting.

b) The added categories must be numbered consecutively.

c) "name" is the componentID that should be able to be hidden.

***Example of a new Setting named "noHelemt":***

```lua
CategoriesToHide: {
    basic: {
        1: {
            name: 'helmet_1',
        },
        2: {
            name: 'mask_1',
        },
    },
    noHelemt: {
        1: {
            name: 'helmet_1',
        },
    }
},
```

{% endtab %}
{% endtabs %}

### 7. Change Logo for clothingshops

The logo that is displayed in the clothing stores is located in gp\_Clothingshop/configs as logo.png.

You can change the logo as you wish.

{% hint style="danger" %}
Just make sure that the name is exactly "logo.png"
{% endhint %}


# Developers

Usefull exports and events for the script.

{% hint style="info" %}
On this page you should find everything useful. If you still need things and can't find them here, feel free to contact me. I'll try to add events or exports as soon as possible.
{% endhint %}


# Client

## Open Wardrobe

<pre class="language-lua"><code class="lang-lua"><strong>-- Export to open the wardrobe of the player
</strong><strong>exports["gp_Clothingshop"]:OpenWardrobe()
</strong></code></pre>


# 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.


# Developers

{% hint style="info" %}
On this page you should find everything useful. If you still need things and can't find them here, feel free to contact me. I'll try to add events or exports as soon as possible.
{% endhint %}


# Client

### Exports

<mark style="color:blue;">OpenEmployeeMenu - Open the employee menu from anywhere</mark>

```lua
exports["gpInsuranceSystem"]:OpenEmployeeMenu()
```


# Server

Here you can find all server events and exports you can use.

### Exports

<mark style="color:blue;">GetInsuredPlayers - Returns all insured players of the job</mark>

{% code fullWidth="false" %}

```lua
-- @param job: insurance job to get insured players from 
exports['gp_InsuranceSystem']:GetInsuredPlayers(job)

-- example usage
local Players = exports['gp_InsuranceSystem_ESX']:GetInsuredPlayers('ambulance')
for identifier,playerData in pairs(Players) do
    print("Identifier: " .. identifier ..
          "\nPlan: " .. playerData.plan .. 
          "\nPlayername: " .. playerData.playername ..
          "\nStartDate: " .. playerData.startDate ..
          "\nNextPaymentDate: " .. playerData.nextPaymentDate)
end
```

{% endcode %}

Variables for the playerData for each player:

| variable        | description                                   |
| --------------- | --------------------------------------------- |
| plan            | Plan name of the insurance/membership         |
| playername      | Name of the player                            |
| startDate       | Start date of the insurance/membership        |
| nextPaymentDate | Next payment date of the insurance/membership |

***

<mark style="color:blue;">GetPlanDetails - Returns the insurance/membership details of the player</mark>

{% hint style="warning" %}
You only need source or identifier! Input nil for the other parameter.
{% endhint %}

{% code fullWidth="false" %}

```lua
-- @param source: source of the player
-- @param identifier: identifier of the player (citizenid for QB)
-- @param insurance: insurance job
exports['gp_InsuranceSystem']:GetPlanDetails(source, identifier, insurance)
```

{% endcode %}

| variable        | description                    |
| --------------- | ------------------------------ |
| label           | Insurance/Membership plan name |
| coverage        | coverage of the plan           |
| price           | price of the plan              |
| paymentInterval | payment interval of the plan   |
| startingPrice   | startingprice of the plan      |
| cancelPrice     | cancelprice of the plan        |

***

<mark style="color:blue;">GetPrivateInsuranceCoverage - Returns the insurance/membership coverage of the player</mark>

{% hint style="warning" %}
You only need source or identifier! Input nil for the other parameter.
{% endhint %}

```lua
-- @param source: source of the player
-- @param identifier: identifier of the player (citizenid for QB)
-- @param insurance: insurance job
exports['gp_InsuranceSystem']:GetPrivateInsuranceCoverage(source, identifier, insurance)
```

***

<mark style="color:blue;">GetPlayerBusinessInsuranceCoverage</mark> \ <mark style="color:blue;">- Returns coverage of the players business insurance/membership</mark>

{% hint style="warning" %}
You only need source or identifier! Input nil for the other parameter.
{% endhint %}

```lua
-- @param source: source of the player
-- @param identifier: identifier of the player (citizenid for QB)
-- @param insurance: insurance job
exports['gp_InsuranceSystem']:GetPlayerBusinessInsuranceCoverage(source, identifier, insurance)
```

***

<mark style="color:blue;">GetBusinessInsuranceDetails - Returns insurance/membership contitions of the business</mark>

```lua
-- @param business: business name to get conditions
-- @param insurance: insurance job
exports['gp_InsuranceSystem']:GetBusinessInsuranceDetails(business, insurance)
```

| variable        | description       |
| --------------- | ----------------- |
| methode         | "fix" or "member" |
| coverage        | coverage          |
| price           | price             |
| paymentInterval | payment interval  |
| startingPrice   | startingprice     |
| cancelPrice     | cancelprice       |


# 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. Insert the .sql file to your database

### 2. Install dependencys

* [NativeUI](https://github.com/FrazzIe/NativeUILua)

### 3. Restart your Server

In order for your new asset to be recognized and the database changes to be applied, you must restart the server!


# Developers

{% hint style="info" %}
On this page you should find everything useful. If you still need things and can't find them here, feel free to contact me. I'll try to add events or exports as soon as possible.
{% endhint %}


# Events

### Client-Events

{% hint style="info" %}
Client-Event to open the menu.
{% endhint %}

```lua
TriggerEvent("gp_businessCard:openMenu")
```


# 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. Insert the .sql file to your database

***

### 2. Install dependencys

* [NativeUI](https://github.com/iZerkahh/NativeUILua_Reloaded)

***

### 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 the server!
{% endhint %}

***

### 4. Config

{% hint style="info" %}
The visa system has a relatively large config. You should adjust everything in peace through and accordingly. All settings have an additional comment to briefly explain what it does.
{% endhint %}

<details>

<summary>Restarts</summary>

The visa end of the players is set via the server restarts. This means that the players' visa always ends at the time of a server restart. This makes things easier and more efficient. Enter all server restarts in the config accordingly, so that the visa end is always placed perfectly at a server restart.

</details>

<details>

<summary>Current Players</summary>

You decide what happens to players who are already playing on the server before the visa system is integrated.&#x20;

Either these players will have their whitelist directly..

```lua
Config.fetchOldPlayers = true
```

..or they will have a visum as well.

```lua
Config.fetchOldPlayers = true
```

For both versions you have to enter the command "fetchplayer" once in the server console. This will add all old players to the visa table.

</details>

<details>

<summary>Visum-Vehicles</summary>

Players can pick up a visa vehicle from the NPC which they can use for the duration of the visa. When the visa expires, the vehicle is automatically confiscated. Everything in the vehicle will be deleted!

The reason for this is that there are many different systems for storing items in cars.&#x20;

</details>

{% hint style="warning" %}
There are also important functions in the Config. So that everything works with your system you should have a look at these functions and if necessary adapt them to your systems&#x20;
{% endhint %}


# Developers

{% hint style="info" %}
On this page you should find everything useful. If you still need things and can't find them here, feel free to contact me. I'll try to add events or exports as soon as possible.
{% endhint %}


# Commands

### */visumstats*

{% hint style="info" %}
Outputs the current visum stats visumstats (serverconsole)
{% endhint %}

### ***/fetchplayer***

{% hint style="info" %}
To fetch your old players and register them in the visumsystem
{% endhint %}


# Exports

{% hint style="info" %}
If you need any other callback or event, just let me know!
{% endhint %}

## ***getVisumState (client)***

{% hint style="info" %}
Returns the current visum state of the player:

"whitelisted" -> Player is whitelisted

"visum" -> Player has valid visum

"expired" -> Player visum has expired&#x20;
{% endhint %}

```lua
local visumState = exports['gp_visum']:getVisumState()
```

Example how to limit shops using ox\_inventory:

{% code title="ox\_inventory/client.lua in line 166" lineNumbers="true" %}

```lua
...
if inv == 'shop' and invOpen == false then
    -- get user state
    local visumState = exports['gp_visum']:getVisumState()
    -- return if user is not whitelisted
    if visumState ~= "whitelisted" then return end

    if cache.vehicle then
        return lib.notify({ id = 'cannot_perform', type = 'error', description = locale('cannot_perform') })
    end

    left, right = lib.callback.await('ox_inventory:openShop', 200, data)
elseif inv == 'crafting' then
...
```

{% endcode %}

{% hint style="info" %}
You can block all functions for people who are not listed and only have visa or it has expired.
{% endhint %}


# Events

{% hint style="info" %}
Event to register the player in the visumsystem.

Should be triggered immediately after character creation.
{% endhint %}

{% code title="Clientsided Event:" %}

```lua
TriggerServerEvent("visum:registerPlayerVisum")
```

{% endcode %}

{% code title="Serversided Event:" %}

```lua
TriggerEvent("visum:registerPlayerVisum", source)
```

{% endcode %}


# Code Snippets


# QB-Garages

If you are having trouble parking or unparking visa vehicles with QB garages, this should solve your problem.

{% hint style="info" %}
File: gp\_visum/configs/config.lua

Replace the addVehicleToOwner function in line 239
{% endhint %}

{% code title="gp\_visum/configs/config.lua" lineNumbers="true" %}

```lua
-- (Server)
-- Simple function to add the visum vehicle to a player
Config.addVehicleToOwner = function(src, plate, visumVehicleData)
    local player = QBCore.Functions.GetPlayer(src)
    MySQL.Async.execute('INSERT INTO player_vehicles (license, citizenid, vehicle, hash, mods, plate, garage, state) VALUES (@license, @citizenid, @vehicle, @hash, @mods, @plate, @garage, @state)',
    {
        ['@license'] = player.PlayerData.license,
        ['@citizenid'] = player.PlayerData.citizenid,
        ['@vehicle'] = visumVehicleData.vehicleModel,
        ['@hash'] = GetHashKey(visumVehicleData.vehicleModel),
        ['@mods'] = json.encode({model = GetHashKey(visumVehicleData.vehicleModel), plate = plate}),
        ['@plate'] = plate,
        ['@garage'] = "pillboxgarage",
        ['@state'] = "0",
    }, function(rowsChanged)
        Config.debug("Added vehicle to player " .. visum.getPlayerName(src) .. " with plate " .. plate)
        -- Add key to the user with the given plate and source
        Config.addVehicleKeys(src, plate, visumVehicleData.vehicleName)
    end)
end
```

{% endcode %}


# 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. Insert the .sql file to your database

***

### 2. Install dependencys

* [NativeUI](https://github.com/FrazzIe/NativeUILua)

***

### 3. Framework changes

#### QB-Framework

{% tabs %}
{% tab title="QB" %}
{% hint style="info" %}
To make everything work with QB-Core you have to add a function to qb-core.\
Include it after "function self.Functions.SetPlayerData(key, val)" in Line 257.
{% endhint %}

{% code title="qb-core/server/player.lua" %}

```lua
function self.Functions.SetPhoneNumber(val)
    self.PlayerData.charinfo.phone = val
    self.Functions.UpdatePlayerData()
end
```

{% endcode %}
{% endtab %}

{% tab title="ESX" %}
Nothing needs to be changes for ESX. 😄👍
{% endtab %}
{% endtabs %}

### 4. 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 the server!
{% endhint %}

***

### 5. Smartphone changes

{% tabs %}
{% tab title="Chezza's phone" %}
Create a new folder in phone/apps/emergencyphone and copy the file sv\_changenumber.lua into it which can be found in the emergencyphone folder.
{% endtab %}

{% tab title="GKS Phone" %}
{% code title="In /client/clientAPI.lua add" %}

```lua
RegisterNetEvent("gksphone:changePhoneNumber")
AddEventHandler("gksphone:changePhoneNumber", function(newNumber)
  SendNUIMessage({event = 'updateMyPhoneNumber', myPhoneNumber = newNumber})
end)
```

{% endcode %}
{% endtab %}

{% tab title="Quasar-Smartphone" %}
{% hint style="danger" %}
Please use only one of the 2 variants!
{% endhint %}

#### Variant one:

In this variant, we used Quasar's workcalls. \
The advantage in this variant is that players can keep their private numbers and thus still receive private calls and messages.

So you have to set the corresponding numbers in the config of the qs-smartphone and set the Config.useQuasarWorkCalls to true in the emergencyphone.

#### Variant two:

In this variant, the number of a player is replaced by the control center number. Thus, no private messages or calls can be received!

* Download qs-base and qs-fakenumber DLC for qs-smartphone and install it\
  **If you have problems installing them, please ask the support of Quasar.** \
  **Those are not my scripts and I won't help you with it!**
* Config.useQuasarWorkCalls = false
* Remove any existing workcall from the config of qs-smartphone
  {% endtab %}

{% tab title="NPWD" %}
Add this code in *<mark style="color:orange;">**npwd\dist\game\server**</mark>* after line *<mark style="color:orange;">**57577**</mark>**.***

```javascript
exp5('setPhoneNumber', (src, newNumber) => {
    player_service_default.getPlayer(src).setPhoneNumber(newNumber)
    console.log(`Phonenumber was set to ${player._phoneNumber}`)
})
```

<figure><img src="/files/ScP0FtLsSxmHYZCKsFUz" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="ySeries" %}
{% hint style="danger" %}
IMPORTANT!
{% endhint %}

Due to the current limitation of ySeries phone, the control center numbers **MUST** have exactly the same format **as all other numbers**. If you have a prefix of 855 and a length (excluding prefix) of 6, every control center number must also be in this format.&#x20;

So for 911 -> 855000911 or any other number in this format!
{% endtab %}
{% endtabs %}


# Common mistakes

{% hint style="info" %}
On this page you should find everything useful. If you still need things and can't find them here, feel free to contact me. I'll try to add events or exports as soon as possible.
{% endhint %}


# Common mistakes

{% hint style="danger" %}
Before you open a ticket on my Discord, please see if you can find your problem on this page.
{% endhint %}

## *Error parsing script / Failed to load script*

Your server artifacts are likely outdated. Update your server to version 5181 or above.

## You lack the required entitlement to use..

Try restarting your server and make sure your server license key is correct. If you bought the resource on the wrong account, you can transfer it to another account on keymaster.

## Failed to verify protected resource

Files were possibly corrupted during transfer. Ensure hidden files are copied; the `.fxap` file in a protected resource must be included. Some FTP programs skip these files.\
Please use WinSCP instead of FileZilla.

## Attempt to index a nil value (global NativeUI)

Seems like you don't have the NativeUI script installed. NativeUI is a dependency and is a library to create menus. Without NativeUI gp\_emergencyphone will not work.

{% hint style="info" %}
Download-Link for NativeUI: <https://github.com/FrazzIe/NativeUILua>
{% endhint %}

\ <br>


# Developer

{% hint style="info" %}
On this page you will find helpful events or tips to work with the script. If there are things missing, please let me know.
{% endhint %}


# Events

{% hint style="danger" %}
Here you can find helpful events for the script.
{% endhint %}

## *Open Menu*

{% hint style="info" %}
The script checks if the player has a matching job. \
So it does not need to be checked by you.
{% endhint %}

{% code title="On client side:" overflow="wrap" lineNumbers="true" %}

```lua
TriggerEvent("emergencyPhone:openMenu")
```

{% endcode %}

{% code title="On server side:" overflow="wrap" lineNumbers="true" %}

```lua
TriggerClientEvent("emergencyPhone:openMenu", src)
```

{% endcode %}

\ <br>


# 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 %}


# Step 1 - SQL-File

{% tabs %}
{% tab title="phpMyAdmin" %}
**Using file-import:**\
1\. Select your database on the left side\
2\. Click on the top navigation bar on "Import"\
3\. Select the .sql from the download folder\
4\. Click on the "OK" button on the bottom of the page

\
U**sing sql-request:**\
1\. Select your database on the left side\
2\. Click on the top navigation bar on "SQL"\
3\. Copy an paste the code from the .sql file into the field\
4\. Click on the "OK" button on the bottom-right of the page
{% endtab %}

{% tab title="HeidiSQL" %}
**Using sql-query:**\
1\. Select your database on the left side\
2\. Click on the top navigation bar on "Query"\
3\. Paste the content from the sql file in it\
4\. Click on the blue arrow named "Execute Query"
{% endtab %}
{% endtabs %}


# Step 2 - \[QB-Core] Changes

Adding SetPhoneNumber function to qb-core/server/player.lua...

{% hint style="info" %}
To make everything work with QB-Core you have to add some code to qb-menu.

Add "TriggerEvent("gp\_taxSystem:closeMenu")" like shown below
{% endhint %}

{% code title="qb-menu/client/main.lua" lineNumbers="true" %}

```lua
local function closeMenu()
    sendData = nil
    headerShown = false
    TriggerEvent("gp_taxSystem:closeMenu")
    SetNuiFocus(false)
    SendNUIMessage({
        action = 'CLOSE_MENU'
    })
end
```

{% endcode %}

{% code title="qb-menu/client/main.lua" lineNumbers="true" %}

```lua
RegisterNUICallback('closeMenu', function(_, cb)
    headerShown = false
    sendData = nil
    SetNuiFocus(false)
    TriggerEvent("gp_taxSystem:closeMenu")
    cb('ok')
end)
```

{% endcode %}


# Step 3 - \[ESX] Changes

{% hint style="info" %}
Download [esx\_context](https://github.com/esx-framework/esx_core/tree/main/%5Bcore%5D/esx_context)
{% endhint %}

{% hint style="danger" %}
For older ESX versions, you need to change some things in esx\_context. If you have no idea what to do, join my Discord and open a support ticket. I'll help you.
{% endhint %}

Next, you need to check if your "users" table has an column named "last\_seen".\
If not, insert this SQL.

{% code lineNumbers="true" %}

```sql
ALTER TABLE users
ADD `last_seen` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp();
```

{% endcode %}


# Step 4 - Restart your server

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


# Step 5 - Set first deduction date

{% hint style="info" %}
In order for the system to know when to start calculating and deducting taxes, we need to set the first date for the first tax settlement. **(You only have to do this once!)**
{% endhint %}

1. Set `Config.setupMode` in your Config to true

   <pre class="language-lua" data-full-width="false"><code class="lang-lua">Config.setupMode = true
   </code></pre>
2. Restart the script via the server console
3. Use the command `setTaxDate YYYY-MM-DD HH:MM:SS` to set the first date\
   example: `setTaxDate 2023-12-16 20:00:00`\
   In this case the taxes would be deducted at `2023-12-16 20:00:00` for the first time.\
   \
   The next date is generated automatically, depending on the days you have set (Config.payTaxInterval), and saved in the database.
4. Set `Config.setupMode` in your Config to false

   ```lua
   Config.setupMode = false
   ```
5. Restert the script via the server console


# Exclude inactive vehicles

{% hint style="info" %}
Would you like inactive vehicles not to have to pay taxes?&#x20;

No problem! On this page you can find out how to set it up.
{% endhint %}

#### 1. Check Script Version

To use this function you need **at least** the following script version:

* For ESX -> 1.2.5
* For QBCore -> 1.2.6

#### 2. Adjust database

First we need to add a new column in the database (based on your framework)

{% tabs %}
{% tab title="ESX" %}

```sql
ALTER TABLE owned_vehicles
ADD COLUMN last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;
```

{% endtab %}

{% tab title="QB" %}
{% code fullWidth="false" %}

```sql
ALTER TABLE player_vehicles
ADD COLUMN last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;
```

{% endcode %}
{% endtab %}
{% endtabs %}

#### 3. Set Config.ignoreVehiclesTaxPayment

The last thing you need to do is set the minimum number of days a car must be inactive before it is exempt from tax. In this example 14 Days.

```lua
Config.ignoreVehiclesTaxPayment = 14
```

{% hint style="danger" %}

```lua
Config.ignoreVehiclesTaxPayment = nil
```

This will deactivates it and does not check if vehicles is inactive!
{% endhint %}


# Common mistakes

{% hint style="info" %}
On this page you should find everything useful. If you still need things and can't find them here, feel free to contact me. I'll try to add events or exports as soon as possible.
{% endhint %}


# Common mistakes

{% hint style="danger" %}
Before you open a ticket on my Discord, please see if you can find your problem on this page.
{% endhint %}

## *Error parsing script / Failed to load script*

Your server artifacts are likely outdated. Update your server to version 5181 or above.

## You lack the required entitlement to use..

Try restarting your server and make sure your server license key is correct. If you bought the resource on the wrong account, you can transfer it to another account on keymaster.

## Failed to verify protected resource

Files were possibly corrupted during transfer. Ensure hidden files are copied; the `.fxap` file in a protected resource must be included. Some FTP programs skip these files.\
Please use WinSCP instead of FileZilla.


# Developer

{% hint style="info" %}
On this page you will find helpful events or tips to work with the script. If there are things missing, please let me know.
{% endhint %}


# Events

{% hint style="danger" %}
There is nothing here yet. If you need something let me know, then I build it in!
{% endhint %}


