⚙️Configuration

Here we'll see how to configure your own VIP's and integrate custom rewards.

1. Configure your Admins

Add your admins

To add a player in ug-vipsystem admin, you can use any of these identifiers. You can find them in your txAdmin:

  • Steam Identifier

  • License Identifier

  • XBL Identifier

  • Live Identifier

  • Discord Identifier

  • FiveM Identifier

After copying the identifier of the admin, you can open the config.lua file in the ug-vipsystem resource folder. Now, paste the identifier as a new string in Config.Settings > admins, like the example:

config.lua
Config.Settings = {
    admins = {
        'Your Admins Identifier', -- < Put here your Admins Identifiers
    }
}

2. Create Custom VIP's

New VIP Creation

To create a new VIP, let's open the file VIPs/VIPs.lua in ug-vipsystem resource folder, then, copy the VIP Example and modify as your like. Here will be an example of VIP.

VIPs.lua
VIPs.Rewards = {
    ["EXAMPLEVIP1"] = { -- Example VIP
        Settings = {
            triggerClientEvent = true,
            triggerServerEvent = true,
        },
        Events = {
            Client = {
                "ug-vipsystem:EXAMPLEVIP1:event_client"
            },
            Server = {
                "ug-vipsystem:EXAMPLEVIP1:event_server"
            }
        }
    },
    ["GoldVIP"] = { -- VIP Type
        Settings = {
            triggerClientEvent = true, -- Would you like to trigger client events?
            triggerServerEvent = true, -- Would you like to trigger server events?
        },
        Events = { -- This is the events that will trigger when the VIP is activated.
            Client = {
                "ug-vipsystem:GoldVIP:event_client" -- Client events to be triggered. (triggerClientEvent must be true to work!)
            },
            Server = {
                "ug-vipsystem:GoldVIP:event_server" -- Server events to be triggered. (triggerServerEvent must be true to work!)
            }
        }
    },
}

VIP Events - Basic Events

Now, let's open the Event Files in VIPs/events/client.lua and VIPs/events/client.lua

In this example, we'll send a notification using ug-notify script to the player.

client.lua
RegisterNetEvent('ug-vipsystem:EXAMPLEVIP1:event_client')
AddEventHandler('ug-vipsystem:EXAMPLEVIP1:event_client', function ()
    local _source = source
    print("Client Event is Working!")
end)

RegisterNetEvent('ug-vipsystem:GoldVIP:event_client')
AddEventHandler('ug-vipsystem:GoldVIP:event_client', function ()
    local _source = source
    exports['ug-notify']:CreateNotify('Gold VIP', 'The Gold VIP was activated successfully! :)', 'success', 10000)
end)
server.lua
RegisterServerEvent('ug-vipsystem:EXAMPLEVIP1:event_server')
AddEventHandler('ug-vipsystem:EXAMPLEVIP1:event_server', function ()
    local _source = source
    print("Server Event is Working!")
end)

RegisterServerEvent('ug-vipsystem:GoldVIP:event_server')
AddEventHandler('ug-vipsystem:GoldVIP:event_server', function ()
    local _source = source
    TriggerClientEvent('ug-notify:CreateAlert', _source, 'Gold VIP', 'The Gold VIP was activated successfully! :)', 'success', 10000)
end)

VIP Events - ESX Integration

Let's suppose that we want to give 100'000 € to the bank of the player and to spawn a vehicle. Let's learn on how to do that. Let's create a Server Event to make it work.

ESX 1.1 (Old ESX)

client.lua
ESX = nil

CreateThread(function ()
    while ESX == nil do
        TriggerEvent('esx:getSharedObject', function (obj) ESX = obj end)
        Wait(0)
    end
end)

RegisterNetEvent('ug-vipsystem:EXAMPLEVIP1:event_client')
AddEventHandler('ug-vipsystem:EXAMPLEVIP1:event_client', function ()
    local _source = source
    print("Client Event is Working!")
end)

RegisterNetEvent('ug-vipsystem:GoldVIP:event_client')
AddEventHandler('ug-vipsystem:GoldVIP:event_client', function ()
    local _source = source
    local carModel = 'zentorno' -- Car Model
    local playerPed = GetPlayerPed(_source) -- Player Ped
    local playerCoords = GetEntityCoords(playerPed) -- Coords of the Player
    local playerHeading = GetEntityHeading(playerPed) -- Heading of the Player
    ESX.Game.SpawnVehicle(carModel, playerCoords, playerHeading, function (veh)
        print("Spawned Vehicle: " .. veh) -- Print that the car was spawned.
    end)
end)
server.lua
ESX = nil

TriggerEvent('esx:getSharedObject', function (obj) ESX = obj end)

RegisterServerEvent('ug-vipsystem:EXAMPLEVIP1:event_server')
AddEventHandler('ug-vipsystem:EXAMPLEVIP1:event_server', function ()
    local _source = source
    print("Server Event is Working!")
end)

RegisterServerEvent('ug-vipsystem:GoldVIP:event_server')
AddEventHandler('ug-vipsystem:GoldVIP:event_server', function ()
    local _source = source
    local xPlayer = ESX.GetPlayerFromId(_source) -- Get Player from ESX
    local playerMoney = xPlayer.getAccount('bank').money -- Get Player Bank Money
    xPlayer.addAccountMoney('bank', 100000) -- Gives 100'000 €
    print("Gave player 100'000 €. He had " .. playerMoney .. " €, now he has " .. playerMoney + 100000 .. " € in his bank account.")
end)

Now, if we use the VIP, then it should give us the car and the money.

BEFORE:

AFTER:

Last updated