@Kevin_ho as requested, this is what i did and is not working.
client.lua
ESX = nil
local PlayerLoaded = false
vip = false
Citizen.CreateThread(function()
while ESX == nil do
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
Citizen.Wait(0)
end
PlayerLoaded = true
ESX.PlayerData = ESX.GetPlayerData()
end)
RegisterNetEvent('esx:playerLoaded')
AddEventHandler('esx:playerLoaded', function(xPlayer)
ESX.PlayerData = xPlayer
PlayerLoaded = true
end)
AddEventHandler('playerSpawned', function()
vip = false
ESX.TriggerServerCallback('pxrp_vip:getVIPStatus', function(vip)
if vip then
while not PlayerLoaded do
Citizen.Wait(1000)
end
ESX.ShowNotification("Status da Conta: VIP")
end
end)
end)
function addVIPStatus()
TriggerServerEvent('pxrp_vip:setVIPStatus', true)
vip = true
end
function removeVIPStatus()
TriggerServerEvent('pxrp_vip:setVIPStatus', false)
vip = false
end
RegisterNetEvent('pxrp_vip:addVIPStatus')
AddEventHandler('pxrp_vip:addVIPStatus', function()
addVIPStatus()
end)
RegisterNetEvent('pxrp_vip:removeVIPStatus')
AddEventHandler('pxrp_vip:removeVIPStatus', function()
removeVIPStatus()
end)
server.lua
ESX = nil
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
ESX.RegisterServerCallback('pxrp_vip:getVIPStatus', function(source, cb)
local identifier = GetPlayerIdentifiers(source)[1]
MySQL.Async.fetchAll('SELECT vip FROM users WHERE identifier = @identifier', {
['@identifier'] = identifier
}, function(isVIP)
if vip then
print(('pxrp_vip: %s VIP status has been reset for the player!'):format(identifier))
end
cb(isVIP)
end)
end)
RegisterServerEvent('pxrp_vip:setVIPStatus')
AddEventHandler('pxrp_vip:setVIPStatus', function(isVIP)
local identifier = GetPlayerIdentifiers(source)[1]
if type(isVIP) ~= 'boolean' then
print(('pxrp_vip: %s attempted to parse something else than a boolean to setVIPStatus!'):format(identifier))
return
end
MySQL.Sync.execute('UPDATE users SET vip = @vip WHERE identifier = @identifier', {
['@identifier'] = identifier,
['@vip'] = vip
})
end)
ESX.RegisterCommand('setvip', 'admin', function(xPlayer, args, showError)
args.playerId.triggerEvent('pxrp_vip:addVIPStatus')
TriggerClientEvent('chat:addMessage', -1, {
template = '<div style="padding: 0.5vw; margin: 0.5vw; background-color: rgba(158, 35, 35, 0.4); border-radius: 3px;"><i class="fas fa-globe"></i> <b>[USUARIO AGREGADO EN LA LISTA VIP]</b></i></div>'
})
end, true, {help = 'Dar VIP a un usuario', validate = true, arguments = {
{name = 'playerId', help = 'ID DEL JUGADOR', type = 'player'}
}})
ESX.RegisterCommand('removeVIP', 'admin', function(xPlayer, args, showError)
args.playerId.triggerEvent('pxrp_vip:removeVIPStatus')
TriggerClientEvent('chat:addMessage', -1, {
template = '<div style="padding: 0.5vw; margin: 0.5vw; background-color: rgba(158, 35, 35, 0.4); border-radius: 3px;"><i class="fas fa-globe"></i> <b>[USUARIO QUITADO DE LA LISTA VIP]</b></i></div>'
})
end, true, {help = 'Quitar VIP a un usuario', validate = true, arguments = {
{name = 'playerId', help = 'ID DEL JUGADOR', type = 'player'}
}})
esx_vehicleshop (Menu function)
-- Key controls
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if CurrentAction then
ESX.ShowHelpNotification(CurrentActionMsg)
if IsControlJustReleased(0, 38) then
if CurrentAction == 'shop_menu' then
if Config.LicenseEnable then
ESX.TriggerServerCallback('esx_license:checkLicense', function(hasDriversLicense)
if hasDriversLicense then
ESX.TriggerServerCallback('pxrp_vip:getVIPStatus', function(isVIP)
if isVIP then
OpenShopMenu()
else
ESX.ShowNotification("Your character doesn't have the VIP access, please check discord for more information.")
end
end, GetPlayerServerId(PlayerId()), '1')
else
ESX.ShowNotification(_U('license_missing'))
end
end, GetPlayerServerId(PlayerId()), 'drive')
else
ESX.TriggerServerCallback('pxrp_vip:getVIPStatus', function(isVIP)
if isVIP then
OpenShopMenu()
else
ESX.ShowNotification("Your character doesn't have the VIP access, please check discord for more information.")
end
end, GetPlayerServerId(PlayerId()), '1')
end
elseif CurrentAction == 'reseller_menu' then
OpenResellerMenu()
elseif CurrentAction == 'give_back_vehicle' then
ESX.TriggerServerCallback('esx_vehicleshop:giveBackVehicle', function(isRentedVehicle)
if isRentedVehicle then
ESX.Game.DeleteVehicle(CurrentActionData.vehicle)
ESX.ShowNotification(_U('delivered'))
else
ESX.ShowNotification(_U('not_rental'))
end
end, ESX.Math.Trim(GetVehicleNumberPlateText(CurrentActionData.vehicle)))
elseif CurrentAction == 'resell_vehicle' then
ESX.TriggerServerCallback('esx_vehicleshop:resellVehicle', function(vehicleSold)
if vehicleSold then
ESX.Game.DeleteVehicle(CurrentActionData.vehicle)
ESX.ShowNotification(_U('vehicle_sold_for', CurrentActionData.label, ESX.Math.GroupDigits(CurrentActionData.price)))
else
ESX.ShowNotification(_U('not_yours'))
end
end, CurrentActionData.plate, CurrentActionData.model)
elseif CurrentAction == 'boss_actions_menu' then
OpenBossActionsMenu()
end
CurrentAction = nil
end
else
Citizen.Wait(500)
end
end
end)