brigde/esx.lua
if config.framework ~= 'esx' then return end
ESX = exports[config.baseExport]:getSharedObject()
function triggerCallback(event, ...)
local p = promise.new()
ESX.TriggerServerCallback(event, function(res)
p:resolve(res)
end, ...)
return Citizen.Await(p)
end
function showNotification(message)
ESX.ShowNotification(message)
end
client.lua
local resoucreName = GetCurrentResourceName()
CreateThread(function()
while not ESX.IsPlayerLoaded() do
Wait(500);
end
while true do
local interval = 750;
for key, value in pairs(config.locations) do
local distance = #(GetEntityCoords(PlayerPedId()) - value.coords.xyz);
if distance < 10.0 then
interval = 0;
DrawMarker(27, value.coords.x, value.coords.y, value.coords.z - 1.0, 0, 0, 0, 0, 0, 0, 1.0, 1.0, 1.0, 0, 100, 255, 200, false, false, 2, nil, nil, false);
if distance < 1.5 then
ESX.ShowHelpNotification('Tryck ~INPUT_CONTEXT~ för att öppna katalogen')
if IsControlJustPressed(0, 38) then
SendNUIMessage({
action = 'open',
data = {
categoriesLocation = value.categories,
vehicleLocation = value.vehicles
}
})
SetNuiFocus(true, true);
end
end
end
end
Wait(interval);
end
end)
RegisterCommand('catalog', function()
SendNUIMessage({
action = 'open'
})
SetNuiFocus(true, true);
end)
RegisterNUICallback('close', function()
SetNuiFocus(false, false);
end)
RegisterNUICallback('getvehicles', function(data, cb)
local res = triggerCallback('dillen-cardealer:getdata', data)
for key, value in pairs(res.vehicles) do
value.model = string.lower(value.model)
end
cb(res);
end)
config.lua
config = {}
-- Which framework are you using?
config.framework = 'esx' -- Options: 'esx', 'revoked'
config.baseExport = 'es_extended' -- The base export to use for the framework
config.locations = {
-- { coords = vector3(-63.72814178466797, 74.0592269897461, 71.67547607421875), categories = 'vehicle_categories', vehicles = 'vehicles' },
{ coords = vector3(-1610.380859375, -817.2627563476562, 10.71971988677978), categories = 'vehicle_categories', vehicles = 'vehicles' },
}
kolla på koden och gör en server.lua