ESX = exports['esextended']:getSharedObject() local spawnedBooths = {} local function…
- User
ESX = exports['es_extended']:getSharedObject() local spawnedBooths = {}
local function createBlip(coords) local blip = AddBlipForCoord(coords.x, coords.y, coords.z) SetBlipSprite(blip, 523) SetBlipDisplay(blip, 2) SetBlipScale(blip, 0.4) SetBlipColour(blip, 43) SetBlipAsShortRange(blip, true) BeginTextCommandSetBlipName("STRING") AddTextComponentString("Rent a car") EndTextCommandSetBlipName(blip) end
local function spawnBooth(location) local coords, heading = location.object[1], location.object[2]
ESX.Game.SpawnObject("prop_tollbooth_1", coords, function(obj) if obj then SetEntityHeading(obj, heading) FreezeEntityPosition(obj, true) table.insert(spawnedBooths, obj) exports.qtarget:AddTargetEntity(obj, { options = { { event = "mRent:cl:otvoriRentu", icon = "fas fa-car", label = "Rent a vehicle", canInteract = function(entity) return entity == obj end } }, distance = 2.5 }) end end)end
Citizen.CreateThread(function() while not ESX do Citizen.Wait(100) end for _, location in pairs(Config.Lokacije) do createBlip(location.object[1]) spawnBooth(location) end end)
RegisterNetEvent("mRent:cl:otvoriRentu") AddEventHandler("mRent:cl:otvoriRentu", function() SendNUIMessage({ action = "otvoriKurvu", cars = Config.Vozila }) SetNuiFocus(true, true) end)
RegisterNUICallback("rentajKurvu", function(data, cb) local vehicleModel = data.vehicle local price = data.price local playerPed = PlayerPedId() local playerCoords = GetEntityCoords(playerPed)
ESX.TriggerServerCallback("mRent:sv:imaliPara", function(success) if success then local closestSpawn = nil local minDist = 99999.0 for _, location in pairs(Config.Lokacije) do for _, spawn in ipairs(location.spawns) do local dist = #(playerCoords - spawn[1]) if dist < minDist then minDist = dist closestSpawn = spawn end end end if closestSpawn then local vehicleHash = GetHashKey(vehicleModel) RequestModel(vehicleHash) while not HasModelLoaded(vehicleHash) do Wait(500) end TriggerServerEvent("mRent:serverSpawnVehicle", vehicleModel, closestSpawn[1], closestSpawn[2]) else ESX.ShowNotification("Nema slobodnih mesta za iznajmljeni auto!") end else ESX.ShowNotification("Nemate dovoljno novca!") end end, price) cb("ok")end)
RegisterNUICallback("zatvoriKurvu", function(_, cb) SetNuiFocus(false, false) cb("ok") end)
RegisterNetEvent('mRent:spawnVehicle') AddEventHandler('mRent:spawnVehicle', function(vehicleModel, spawnLocation) local playerPed = PlayerPedId() local coords = GetEntityCoords(playerPed)
- Assistant