-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.lua
More file actions
46 lines (39 loc) · 1.27 KB
/
client.lua
File metadata and controls
46 lines (39 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
local isAdmin = false
RegisterNetEvent("st-adminitem:setAdmin", function(status)
isAdmin = status
end)
RegisterCommand("giveitemui", function()
TriggerServerEvent("st-adminitem:openUI")
end)
RegisterKeyMapping("giveitemui", "Admin Item Giver UI", "keyboard", "F7")
RegisterNetEvent("st-adminitem:open", function(items)
SetNuiFocus(true, true)
SendNUIMessage({
type = "open",
items = items
})
end)
-- NUI callbacks
RegisterNUICallback("giveItem", function(data, cb)
if data and data.item and data.amount then
local item = tostring(data.item)
local amount = tonumber(data.amount) or 1
local target = data.target and tonumber(data.target) or nil
TriggerServerEvent("st-adminitem:give", item, amount, target)
end
cb({})
end)
RegisterNUICallback("close", function(_, cb)
SetNuiFocus(false, false)
cb({})
end)
-- ESC from NUI (optional explicit callback if you want to call it from JS)
RegisterNUICallback("escape", function(_, cb)
SetNuiFocus(false, false)
cb({})
end)
-- Optional: when resource stops, clear focus
AddEventHandler('onResourceStop', function(resName)
if GetCurrentResourceName() ~= resName then return end
SetNuiFocus(false, false)
end)