# CS\_VISA

* [Get the script](https://core-services.tebex.io/category/products)
* [Watch the preview](https://www.youtube.com/@core-services/videos)

***

## Installation

* [ ] **Drag and drop** the resource somewhere into your resource folder
* [ ] Import the MustImport sql into your database

***

## Configuration

### Config.lua

* In the VisumLevels table you can configure the different visum levels you want to have
  * Make sure to have an increment of 1 for each level. Like this: \[0], \[1], \[2]

{% hint style="info" %}
Make sure to change the **Notification function** to your notify trigger!&#x20;

Or else the script will not work properly.
{% endhint %}

### Webhook.lua

* The script offers 3 different webhooks.&#x20;
  * visumUpgraded
  * getvisumcommand
  * setvisumcommand

If you do not want one of these, just leave the string empty. Like this:

```lua
WebhookVisum = {

    Colors = {
        ["Main"] = 43775,
    },

    visumUpgraded = "",

    getvisumcommand = "https://discord.com/api/webhooks/1253971849193324595/FJS-Tml5AOKdPoXog7qc6VB27__7SzL8XSp5uD23KCFfo4uP6iyuExEkgWeSbCLl-7t_",

    setvisumcommand = "https://discord.com/api/webhooks/1253971849193324595/FJS-Tml5AOKdPoXog7qc6VB27__7SzL8XSp5uD23KCFfo4uP6iyuExEkgWeSbCLl-7t_",
}
```

In this example, you would not be notified when a player visa level is upgraded.

***

## Working with CS\_VISA

### Client

If you want to get the visa level of the client, use this export:

```lua
exports['cs_visum']:getVisum() 
```

### Server

If you want to print the visalevel of a certain playerid, use this export like this:

```lua
exports['cs_visum']:getVisumServer(playerid, function(visum)
    print('Visa Level: ' .. visum)
end)
```

If you want to get the current playtime of a certain playerid, use this export like this:

```lua
exports['cs_visum']:getCurrentPlaytime(playerid, function(playtime)
    print('Current Playtime: ' .. playtime)
end)
```

This export callbacks the playtime that is currently saved in the database and therefore does not give you the correct playtime of the player. So this is only useful in specific cases.

```lua
exports['cs_visum']:getPlaytime(playerid, function(playtime)
    print('Playtime in DB: ' .. playtime)
end)
```

#### Unsupported exports

I also added two exports to save either the playtime or the visa level. But these are not to be used. So really make sure, you know what you are doing when using them!&#x20;

You can find these exports at the bottom of -> script/server/openserver.lua                                                                    and at the bottom of the fxmanifest.lua.

These exports would be used like this:

```lua
local xPlayer = ESX.GetPlayerFromId(playerid)
exports['cs_visum']:savePlaytime(xPlayer)
exports['cs_visum']:saveVisum(xPlayer, visumlevel)
```

***

## Support

If you have any further questions, open a ticket on our discord server: [**discord.gg/core-services**](https://discord.gg/core-services)
