No, you don’t need to clone any ressources to use this.
You can simply call the VipCallBack to a new server event from vehicleshop and in that event for the price you can reduce it by 25% using a simple math line.
exemple here for supermarket:
So for exemple using esx_shops in client.lua
-- 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
OpenShopMenu(currentActionData.zone)
end
currentAction = nil
end
else
Citizen.Wait(500)
end
end
end)
in the OpenShopMenu you can simply modify this line:
if data2.current.value == 'yes' then
ESX.TriggerServerCallback('pxrp_vip:getVIPStatus', function(isVIP)
if isVIP then
TriggerServerEvent('esx_shops:buyItemVIP', data.current.item, data.current.value, zone)
else
TriggerServerEvent('esx_shops:buyItem', data.current.item, data.current.value, zone)
end
end, GetPlayerServerId(PlayerId()), '1')
end
in the server.lua you can create this new event:
RegisterServerEvent('esx_shops:buyItemVIP')
AddEventHandler('esx_shops:buyItemVIP', function(itemName, amount, zone)
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
local sourceItem = xPlayer.getInventoryItem(itemName)
amount = ESX.Math.Round(amount)
-- is the player trying to exploit?
if amount < 0 then
print('esx_shops: ' .. xPlayer.identifier .. ' attempted to exploit the shop!')
return
end
-- get price
local price = 0
local itemLabel = ''
for i=1, #ShopItems[zone], 1 do
if ShopItems[zone][i].item == itemName then
price = ShopItems[zone][i].price
itemLabel = ShopItems[zone][i].label
break
end
end
price = price / 25 * 100 * amount
-- can the player afford this item?
if xPlayer.getMoney() >= price then
-- can the player carry the said amount of x item?
if xPlayer.canCarryItem(itemName, amount) then
xPlayer.removeMoney(price)
xPlayer.addInventoryItem(itemName, amount)
xPlayer.showNotification(_U('bought', amount, itemLabel, ESX.Math.GroupDigits(price)))
else
xPlayer.showNotification(_U('player_cannot_hold'))
end
else
local missingMoney = price - xPlayer.getMoney()
xPlayer.showNotification(_U('not_enough', ESX.Math.GroupDigits(missingMoney)))
end
end)
There is a simplier way to do it, but it will work.