---
description: The vRP Proxy Guide!
---

# Proxy Documentation

## Introduction

The main purpose of this guide is to teach you how to use the vRP outside of other resources.&#x20;

You should learn by the end of this guide:&#x20;

* How to use the Proxy/Tunnel System
* How to make your own Proxy/Tunnel functions

{% hint style="info" %}
This is for the server sided proxy, not the client!
{% endhint %}



## How to Begin

Now if you just want to use the server proxy system & tunnel which will allow you to access the vRPClient and vRP functions like:

[vRP.addUserGroup(user\_id,group)](https://jamesuk.gitbook.io/fivem-guides/dunko-vrp/docs#vrp-addusergroup-user_id-group)



Then it's pretty simple and you can just add the utils to the fxManifest.

So what'd we want to do is reference the utils.lua in the lib folder inside the main vRP resource and to do this we can add this line into our server\_scripts:&#x20;

```lua
server_scripts{ 
    "@vrp/lib/utils.lua",
}
```

Adding this line will allow us to use the module function which will allow us to load the Tunnel and Proxy server versions.

Now, that we have access to the module system provided by utils we can reference it in our server scripts like this: (Note this server script must be loaded after the utils are!)

```lua
local Tunnel = module("vrp", "lib/Tunnel")
local Proxy = module("vrp", "lib/Proxy")
vRP = Proxy.getInterface("vRP") -- This reference allows us to access the vRP related functions
vRPclient = Tunnel.getInterface("vRP","vRP") -- This allows us to access vRP Client Functions.
-- Now we have access to the vRP & vRPClient Functions 
-- We can start using and doing example usages!
```

Now that we have that setup in a server file! Here's some must know!

* You must wrap the functions in brackets when using them outside of the main vRP resources example:&#x20;

```lua
vRP.addUserGroup({user_id, group}) -- Wrapped in a table.
```

Or, let's say we were doing prompt!&#x20;

```lua
vRP.prompt({player,"Example!","",function(player,response) 

end})
```

So, as you can see it's all wrapped in brackets! Which is required so the Proxy and Tunnel can unpack the table.

## Let's set a main example

Now, after all that waffle let's setup a good example!&#x20;

Here is how our file structuring should go:&#x20;

{% tabs %}
{% tab title="fxmanifest.lua" %}
```lua
dependency "vrp"

server_scripts{ 
  "@vrp/lib/utils.lua",
  "server.lua"
}
```
{% endtab %}

{% tab title="server.lua" %}
```lua
local Tunnel = module("vrp", "lib/Tunnel")
local Proxy = module("vrp", "lib/Proxy")
vRP = Proxy.getInterface("vRP") -- This reference allows us to access the vRP related functions
vRPclient = Tunnel.getInterface("vRP","vRP") -- This allows us to access vRP Client Functions.

RegisterCommand('getmypermid', function(source)
    local userid = vRP.getUserId({source})
    print('Your UserID is: ' .. userid)
    vRPclient.notify(source,{"~g~Congratulations on your usage with vRP!"})
    --Example on vRPClient
end)

RegisterCommand('getpermid', function(source, args)
    if args and args[1] then 
        local userid = vRP.getUserId({args[1]})
        if userid then 
            print('The UserID for: ' .. args[1] .. ' is ' .. userid)
        else 
            print('UserID could not be found! This user likely does not exist.') 
        end
    else 
        print('Please specify a user eg: /getpermid [tempid]')
    end
end)

```
{% endtab %}
{% endtabs %}

This all above is an example on how to use the Tunnel & Proxy Server Sided. Soon another guide will come on how to make your own functions for both Client & Proxy and Use them. &#x20;
