[Release] VIP Status [ESX]



ESX.RegisterCommand('agregarvip', '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 = 'The player id', type = 'player'}
}})

ESX.RegisterCommand('quitarvip', '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 = 'The player id', type = 'player'}
}})

Change Commands if you want

hi does a person have a working vehicle shop for the VIP? Mine doesn’t seem to want to work

Hi, can someone help me add this to esx_vehicleshop to certain category of vehicle, i try to use the callback but i failed… Thanks

Hello I have this problem however I am vip that I am 0 or 1 in the bdd it does not work I have no console error or F8 an idea of what could make this little problem?

https://gyazo.com/15c4fa583b8bc746b955770e6d96d374
https://gyazo.com/ce196651cd21125a6aeebfa985dd43f7

How do I create a teleporter for ONLY Vip?

What do I have to do to put another dealer that only vip can access?

Hi It is ok if I can have the esx_supermarket from you?

Hello I was wondering if you could help me find out how I put the code in openshopmenu could u show me bc I’ve tried I feel everything but doesn’t work for me. I’m allow a beginner coder so its 100% on my end. Thank you in advance

Did you modify something to work with the new esx?

Nope, only commands.

Can u help me?

Mmm, let me see your __resource.lua

1 Like

I’m no longuer working with ESX since they’ve switched to their new version that has broke everything, this thread is no longer updated by me and the fix for the new ESX version is in the comments :+1:

Hey @RyuShin is sad that you dropped this. Your script looks good. I am trying to fix this for the ESX version ‘1.2.0’ but for some reason writing into the database and reading is not working.

I did changed the commands from essentialmode to the ESX commands as @Kevin_ho suggested but no luck. The queries and functions are similar to other working esx scripts, so i am not really competent enough to understand whats going on.

I would love to get this to work, if you can take a look.

Thanks!

Send code

Try this server side:

ESX.RegisterCommand('command as you want', '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('command as you want', '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'}
}})

change “command as you want” to put the one you like

1 Like

@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)

How can the VIP only last 1 month?

Somebody knows how to set the vip on any weapons shops? i try but i cant, If any generous soul copies and pastes the line with the built-in “pxrp_vip” it would be very helpful, regards and thanks! :slight_smile:

elseif CurrentAction == 'vip_menu' then
					if Config.UseVIPShop then
						if Config.LicenseEnable then
							--[[ESX.TriggerServerCallback('VIPSCRIPT:VIPSCRIPT', function(success)
								if success then
									ESX.TriggerServerCallback('esx_license:checkLicense', function(hasdriverLicense)
										if hasdriverLicense then
											BuyVIPMenu()
										else
											ESX.ShowNotification(_U('license_missing'))
										end
									end, GetPlayerServerId(PlayerId()), 'drive')
								else
									ESX.ShowNotification(_U('vip_no'))
								end
							end)]]--
						else
							BuyVIPMenu()
						end
					end

How should I configure the call here?

can someone help me create the call