local function isPolice()
local player = exports.qbx_core:GetPlayerData()
if not player or not player.job then return false end
local name = player.job.name
return name == 'police' or name == 'sheriff'
end
CreateThread(function()
local lastWarn = 0
while true do
Wait(500)
local ped = PlayerPedId()
if not DoesEntityExist(ped) then goto continue end
-- Get current weapon item from ox_inventory to inspect serial
local current = exports.ox_inventory:GetCurrentWeapon()
if current and current.metadata and current.metadata.serial then
local serial = tostring(current.metadata.serial)
if serial:upper():find('POL', 1, true) and not isPolice() then
-- Force unarmed; keep item but prevent usage
SetCurrentPedWeapon(ped, `WEAPON_UNARMED`, true)
local now = GetGameTimer()
if now - lastWarn > 2000 then
exports.qbx_core:Notify('Et voi käyttää virka-aseita (vain poliisin palveluksessa).', 'error')
lastWarn = now
end
end
end
::continue::
end
end)```
#Restricting police guns to police. - using serial number "POL"
1 messages · Page 1 of 1 (latest)
please use
```lua ```
There you go
could of just edited the message
local function isPolice()
local player = exports.qbx_core:GetPlayerData()
if not player or not player.job then return false end
local name = player.job.name
return name == 'police' or name == 'sheriff'
end
CreateThread(function()
local lastWarn = 0
while true do
Wait(500)
local ped = PlayerPedId()
if not DoesEntityExist(ped) then goto continue end
-- Get current weapon item from ox_inventory to inspect serial
local current = exports.ox_inventory:GetCurrentWeapon()
if current and current.metadata and current.metadata.serial then
local serial = tostring(current.metadata.serial)
if serial:upper():find('POL', 1, true) and not isPolice() then
-- Force unarmed; keep item but prevent usage
SetCurrentPedWeapon(ped, `WEAPON_UNARMED`, true)
local now = GetGameTimer()
if now - lastWarn > 2000 then
exports.qbx_core:Notify('Et voi käyttää virka-aseita (vain poliisin palveluksessa).', 'error')
lastWarn = now
end
end
end
::continue::
end
end)
here you go, lol
where do we add this?
& any chance u can make it so if a person takes a weapon that has the POL serial it auto removes it from the players inv who took it with a ox_lib notify of
Restricted Weapon
You are unable to take this weapon!
wait a sec
i am working on this rn