config.lua
config = {}
config.keyPrice = 500
config.ped = {
location = vec4(72.97494506835938, -1027.2388916015625, 28.47573471069336, 246.0971832275391),
model = 'a_m_m_ktown_01'
}
config.categories = {
{
label = 'Fordon',
database = 'owned_vehicles'
},
{
label = 'Båtar',
database = 'owned_vehicles'
}
}
client.lua
ESX = exports['es_extended']:getSharedObject()
locksmith = {
ped = nil
}
CreateThread(function()
while not ESX.IsPlayerLoaded() do
Wait(500)
end
locksmith.ped = spawnPed(config.ped.model, config.ped.location.xyz, config.ped.location[4])
if GetResourceState('ox_target') == 'started' then
exports.ox_target:addLocalEntity(locksmith.ped, {
label = 'Låssmed',
name = 'debug_vehicle',
icon = 'fa-solid fa-car',
canInteract = function(entity, distance, coords)
return entity == locksmith.ped and distance < 2.0
end,
onSelect = function()
SendNUIMessage({
action = 'open',
data = {
categories = config.categories,
keyPrice = config.keyPrice
}
})
SetNuiFocus(true, true)
end
})
end
end)
RegisterNUICallback('close', function(data, cb)
SetNuiFocus(false, false)
cb('ok')
end)
RegisterNUICallback('loadVehicles', function(data, cb)
ESX.TriggerServerCallback('locksmith:loadVehicles', function(vehicles)
cb(vehicles)
end, data)
end)
RegisterNUICallback('buyKeys', function(data, cb)
ESX.TriggerServerCallback('locksmith:buyKeys', function(res)
if not res then
ESX.ShowNotification('Du har inte tillräckligt med pengar :/')
return cb(false)
end
for _, key in pairs(data) do
for i = 1, key.amount do
local keyData = {
["keyName"] = key.plate,
["keyUnit"] = key.plate,
["label"] = key.plate,
["type"] = "vehicle"
}
exports["vnrp_keysystem"]:AddKey(keyData)
Wait(50)
end
end
cb(true)
end, data)
end)
CreateThread(function()
local blip = AddBlipForCoord(config.ped.location.xyz)
SetBlipSprite(blip, 255)
SetBlipScale(blip, 1.0)
SetBlipColour(blip, 30)
SetBlipAsShortRange(blip, true)
BeginTextCommandSetBlipName('STRING')
AddTextComponentSubstringPlayerName('Låssmed')
EndTextCommandSetBlipName(blip)
end)
AddEventHandler('onResourceStop', function(resourceName)
if (GetCurrentResourceName() ~= resourceName) then
return
end
if locksmith.ped then
DeleteEntity(locksmith.ped)
end
end)
skapa en funtions.lua och en server.lua