# VRPex

You will receive the script in [`keymaster.fivem.net`](https://keymaster.fivem.net/asset-grants) profile, after this click in blue "download" button.

After download, put the script in your server files.

{% hint style="warning" %}
Remeber:

You need to be logged with the same cfx.re account you used to buy in my tebex store.
{% endhint %}

1. Install all [dependencies](#dependencies-part), and follow their respective installation instructions.

## Dependencies Part

* vrp
* [**oxmysql**](https://github.com/overextended/oxmysql)
* [**screenshot-basic**](https://github.com/citizenfx/screenshot-basic)&#x20;
* **qb-input (**&#x50;rovided on downloaded file&#x73;**)**
* [**xsound**](https://github.com/Xogy/xsound)

Download all the scripts by clicking on their respective names, put them in the server files and ensure in server.cfg

## Webhooks

JPR Phone System uses webhooks for photo system, video system and audios files.\
All you need to do is replace the default webhooks, via config.lua\
\
Our log system works for regular players as well as more detailed logs for staff.

<figure><img src="https://3317815405-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAcw6nAW8IGe15skCfMoj%2Fuploads%2F7AqHe6zeCeThuXFscKK6%2FCaptura%20de%20ecr%C3%A3%202023-05-25%20150122.png?alt=media&#x26;token=50e5c67e-ecea-4235-949e-b466fbc7527d" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
For more info how to create a discord webhook follow this tutorial:\
<https://www.youtube.com/watch?v=fKksxz2Gdnc&t=7s&ab_channel=NoIntroTutorials>
{% endhint %}

## Integration with the home system

Due to the huge variety of home systems for VRPex, if you want to make your system compatible with the phone system, you should follow and adapt following template:

{% tabs %}
{% tab title="Template" %}
This part is a template of our callback to house script owners being able to be supported by us, just need to adapt this little callback and everything will work perfect:\
\
(Should be added inside **server\_config**.lua of **Phone System.**)

```lua
function GetPlayerHouses(serie)
    local src = source
    local Player = GetPlayerSource(src)
    local user_id = getUserId(Player)
    local MyHouses = {}
    local CitizenId = MySQL.Sync.fetchAll('SELECT * FROM vrp_homes_permissions WHERE user_id = ?', {serie})

    if (CitizenId[1]) then
        local houseInfo = {}
        local houseList = Config.house.houseList

        for k, v in pairs(CitizenId) do
            local home = v.home
            local id = v.user_id

            for k, v in pairs(houseList) do
                if k == home then
                    table.insert(houseInfo, {house = v.name,type = v.type,Entrance = v.entrada})
                end        
            end
        end

        if houseInfo then
            local finalInfo = {}
            for k, v in pairs(houseInfo) do
                local tempVar = {}
                tempVar.house = v.house
                tempVar.citizenid = id
                tempVar.HouseData = {
                    coords = {
                        enter = {
                            x = v.Entrance.x,
                            y = v.Entrance.y,
                        }
                    },
                    adress = v.house,
                }
                tempVar.tier = v.type
                tempVar.label = v.house

                table.insert(finalInfo, tempVar)
            end

            return finalInfo
        else
            return nil
        end
    else
        return nil
    end
end
```

{% endtab %}
{% endtabs %}

## MDT :warning:

MDT app has all its code open, the filtering part is in **openFunctions.js** and the part that takes information from **SQL** is in **client\_config** and **server\_config**. \
Any change to your **SQL** can affect the way **MDT** works, so if you have the **programming skills** to adapt it to your server or **it's already working** (most of them) use it, otherwise **disable it in the config**.

## Permissions to JPR Phone System

JPR Phone System needs permissions to record your voice, so you can send audio messages and record videos with audio by the phone.

If you receive a message like this, click **F8**, "**Allow**".

<figure><img src="https://3317815405-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAcw6nAW8IGe15skCfMoj%2Fuploads%2FKSd1vSqz5cqlHNXm9VTQ%2F15.png?alt=media&#x26;token=8a14a8e0-7539-4539-aa4e-c9a5a3fb0646" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
This message appears only once.
{% endhint %}

## SQL

Execute `JPR - Phone System.sql` file in your SQL

{% hint style="danger" %}
This is mandatory!
{% endhint %}

## Inventory

{% tabs %}
{% tab title="Usual Inventorys" %}
To create new items we provide some help:

**cfg - items.lua:**

```lua
["phone"] = { "Phone",0.3 },
["phone_white"] = { "White Phone",0.3 },
["phone_gold"] = { "Gold Phone",0.3 },
["phone_red"] = { "Red Phone",0.3 },
["phone_blue"] = { "Blue Phone",0.3 },
["phone_green"] = { "Green Phone",0.3 },
["phone_pink"] = { "Pink Phone",0.3 },
["phone_green_light"] = { "Green Light Phone",0.3 },
["powerbank"] = { "Powerbank",0.3 },
["phone_purple"] = { "Purple Phone",0.3 },
["phone_purple_deep"] = { "Deep Purple Phone",0.3 },
["phone_case_1"] = { "Phone Case 1",0.3 },
["phone_case_2"] = { "Phone Case 2",0.3 },
["phone_case_3"] = { "Phone Case 3",0.3 },
["phone_case_4"] = { "Phone Case 4",0.3 },
["phone_case_5"] = { "Phone Case 5",0.3 },
["phone_case_6"] = { "Phone Case 6",0.3 },
["phone_case_7"] = { "Phone Case 7",0.3 },
["phone_case_8"] = { "Phone Case 8",0.3 },
["phone_case_9"] = { "Phone Case 9",0.3 },
["phone_case_10"] = { "Phone Case 10",0.3 },
["phone_no_case"] = { "No Phone Case",0.3 },
```

**modules - inventory.lua:**

```lua
["phone"] = { index = "phone", nome = "Phone", type = "usar", desc = "Smartphone" },
["phone_white"] = { index = "phone_white", nome = "White Phone", type = "usar", desc = "White Smartphone" },
["phone_gold"] = { index = "phone_gold", nome = "Gold Phone", type = "usar", desc = "Gold Smartphone" },
["phone_red"] = { index = "phone_red", nome = "Red Phone", type = "usar", desc = "Red Smartphone" },
["phone_blue"] = { index = "phone_blue", nome = "Blue Phone", type = "usar", desc = "Blue Smartphone" },
["phone_green"] = { index = "phone_green", nome = "Green Phone", type = "usar", desc = "Green Smartphone" },
["phone_pink"] = { index = "phone_pink", nome = "Pink Phone", type = "usar", desc = "Pink Smartphone" },
["phone_green_light"] = { index = "phone_greenLight", nome = "Green Light Phone", type = "usar", desc = "Light Green Smartphone" },
["powerbank"] = { index = "powerbank", nome = "Powerbank", type = "usar", desc = "Powerbank" },
["phone_purple"] = { index = "phone_purple", nome = "Purple Phone", type = "usar", desc = "Purple Smartphone" },
["phone_purple_deep"] = { index = "phone_purple_deep", nome = "Deep Purple Phone", type = "usar", desc = "Deep Purple Smartphone" },
["phone_no_case"] = { index = "phone_no_case", nome = "Phone without Case", type = "usar", desc = "Smartphone without a case" },
["phone_case_1"] = { index = "phone_case_1", nome = "Phone Case 1", type = "usar", desc = "Case for Phone" },
["phone_case_2"] = { index = "phone_case_2", nome = "Phone Case 2", type = "usar", desc = "Case for Phone" },
["phone_case_3"] = { index = "phone_case_3", nome = "Phone Case 3", type = "usar", desc = "Case for Phone" },
["phone_case_4"] = { index = "phone_case_4", nome = "Phone Case 4", type = "usar", desc = "Case for Phone" },
["phone_case_5"] = { index = "phone_case_5", nome = "Phone Case 5", type = "usar", desc = "Case for Phone" },
["phone_case_6"] = { index = "phone_case_6", nome = "Phone Case 6", type = "usar", desc = "Case for Phone" },
["phone_case_7"] = { index = "phone_case_7", nome = "Phone Case 7", type = "usar", desc = "Case for Phone" },
["phone_case_8"] = { index = "phone_case_8", nome = "Phone Case 8", type = "usar", desc = "Case for Phone" },
["phone_case_9"] = { index = "phone_case_9", nome = "Phone Case 9", type = "usar", desc = "Case for Phone" },
["phone_case_10"] = { index = "phone_case_10", nome = "Phone Case 10", type = "usar", desc = "Case for Phone" },
```

**Phones item usage (server side):**

```lua
TriggerClientEvent('jpr-phonesystem:client:openPhoneSystem', source)
```

**Phone cases item usage (server side):**

*Case names:*

```lua
phone_no_case, phone_case_1, phone_case_2, phone_case_3, phone_case_4, phone_case_5, phone_case_6, phone_case_7, phone_case_8, phone_case_9, phone_case_10
```

```lua
TriggerEvent('jpr-phonesystem:server:usedCase', source, caseName)
```

**Powerbank item usage (server side):**

```lua
elseif itemName == "powerbank" then
    TriggerEvent('jpr-phonesystem:server:usedPowerbank', source)
end
```

{% endtab %}
{% endtabs %}

## Using [Fivemanage](https://www.fivemanage.com/)

Follow this little video to know how to use [Fivemanage ](https://www.fivemanage.com/)for media uploads ( avoid discord future problems ) with our **Phone System**:

{% embed url="<https://www.youtube.com/watch?ab_channel=JPResources&v=XaV_jAJZDdI>" %}

(If you dont want this and keep "risking", we provide old system at same, just turn on **UseOtherUploadSystem** to true, **UseFivemerrSystem** to false and **UseFiveManageSystem** to false)

## Setup Google API Key

Just need to follow this quick 1 min video:\
[**Website Link**](https://console.cloud.google.com/apis)

{% embed url="<https://www.youtube.com/watch?v=1Nbv3slB2ZU>" %}

{% hint style="danger" %}
Without this **Google API Key**, your **spotify and youtube WILL NOT WORK!!**
{% endhint %}

## Video tutorial

If you have trouble installing it after all the explanation, you can watch this video of the script installation:

[**Click me**](https://www.youtube.com/watch?v=YiixJhw1KbY) **( video 1 ) or** [**Click me**](https://www.youtube.com/watch?v=tGro1tqqCLM) **( video 2 ) or** [**Click me**](https://www.youtube.com/watch?v=mLETX6l318I) **( video 3)**
