Files
2026-08-05 01:29:39 +02:00

62 lines
2.0 KiB
Lua

local open = false
local function setOpen(state)
open = state
SetNuiFocus(state, state)
SendNUIMessage({ action = state and 'open' or 'close' })
if state then
DevXTriggerCallback('admin:bootstrap', {}, function(result)
if not result.ok then
open = false
SetNuiFocus(false, false)
SendNUIMessage({ action = 'close' })
exports.devx_core:Notify(result.error or 'Kein Adminzugriff.')
return
end
SendNUIMessage({ action = 'state', players = result.players, weapons = result.weapons })
end)
end
end
RegisterCommand('admin', function()
setOpen(not open)
end, false)
RegisterNUICallback('close', function(_, cb)
setOpen(false)
cb({ ok = true })
end)
RegisterNUICallback('action', function(data, cb)
DevXTriggerCallback('admin:action', data, function(result)
if result.players then SendNUIMessage({ action = 'players', players = result.players }) end
cb(result)
end)
end)
RegisterNetEvent('devx_admin:client:giveWeapon', function(weapon, ammo)
GiveWeaponToPed(PlayerPedId(), GetHashKey(weapon), tonumber(ammo) or 250, false, true)
exports.devx_core:Notify(('Adminwaffe erhalten: %s'):format(weapon))
end)
RegisterNetEvent('devx_admin:client:heal', function()
local ped = PlayerPedId()
SetEntityHealth(ped, GetEntityMaxHealth(ped))
SetPedArmour(ped, 100)
ClearPedBloodDamage(ped)
end)
RegisterNetEvent('devx_admin:client:freeze', function(state)
FreezeEntityPosition(PlayerPedId(), state == true)
exports.devx_core:Notify(state and 'Du wurdest eingefroren.' or 'Du wurdest freigegeben.')
end)
RegisterNetEvent('devx_admin:client:teleport', function(coords)
local ped = PlayerPedId()
SetEntityCoordsNoOffset(ped, coords.x, coords.y, coords.z, false, false, false)
end)
AddEventHandler('onResourceStop', function(resourceName)
if resourceName == GetCurrentResourceName() then SetNuiFocus(false, false) end
end)