FiveM
Client
Client tarafı kalıpları — olaylar, threadler, NUI focus, ox_target.
Temel olay + thread
local QBCore = exports['qb-core']:GetCoreObject()
local isMenuOpen = false
RegisterNetEvent('liveDev:openMenu', function()
if isMenuOpen then return end
isMenuOpen = true
SetNuiFocus(true, true)
SendNUIMessage({ action = 'open' })
end)
RegisterNUICallback('close', function(_, cb)
isMenuOpen = false
SetNuiFocus(false, false)
cb('ok')
end)Marker + yakınlık döngüsü
Uzaktayken Wait(1000), yakınken Wait(0) — performans için klasik kalıp:
CreateThread(function()
while true do
local sleep = 1000
local ped = PlayerPedId()
local coords = GetEntityCoords(ped)
for _, point in ipairs(Config.Locations) do
local dist = #(coords - point)
if dist < 15.0 then
sleep = 0
DrawMarker(2, point.x, point.y, point.z + 0.5,
0, 0, 0, 0, 0, 0, 0.3, 0.3, 0.3,
163, 230, 53, 200, false, true, 2)
if dist < 1.5 and IsControlJustPressed(0, 38) then -- E
TriggerEvent('liveDev:openMenu')
end
end
end
Wait(sleep)
end
end)ox_target ile etkileşim
exports.ox_target:addBoxZone({
coords = vec3(-254.12, -971.48, 31.22),
size = vec3(1.5, 1.5, 2.0),
rotation = 45.0,
options = {
{
name = 'livedev_open',
icon = 'fa-solid fa-list',
label = 'Menüyü Aç',
onSelect = function()
TriggerEvent('liveDev:openMenu')
end,
},
},
})NUI focus
SetNuiFocus(true, true) açtıktan sonra mutlaka bir close callback'inde
SetNuiFocus(false, false) ile geri al — yoksa oyuncu kilitli kalır.