mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 17:28:53 +00:00
refactor(modules/nwpd): format code
This commit is contained in:
@@ -1,56 +1,57 @@
|
||||
local npwd = GetResourceState('npwd'):find('start') and exports.npwd or nil
|
||||
|
||||
local function checkPhone()
|
||||
if not npwd then
|
||||
return
|
||||
end
|
||||
if not npwd then
|
||||
return
|
||||
end
|
||||
|
||||
local phoneItem <const> = ESX.SearchInventory('phone')
|
||||
npwd:setPhoneDisabled((phoneItem and phoneItem.count or 0) <= 0)
|
||||
local phoneItem <const> = ESX.SearchInventory('phone')
|
||||
npwd:setPhoneDisabled((phoneItem and phoneItem.count or 0) <= 0)
|
||||
end
|
||||
|
||||
RegisterNetEvent('esx:playerLoaded', checkPhone)
|
||||
|
||||
AddEventHandler('onClientResourceStart', function(resource)
|
||||
if resource ~= 'npwd' then
|
||||
return
|
||||
end
|
||||
if resource ~= 'npwd' then
|
||||
return
|
||||
end
|
||||
|
||||
npwd = GetResourceState('npwd'):find('start') and exports.npwd or nil
|
||||
npwd = GetResourceState('npwd'):find('start') and exports.npwd or nil
|
||||
|
||||
if ESX.PlayerLoaded then
|
||||
checkPhone()
|
||||
end
|
||||
if ESX.PlayerLoaded then
|
||||
checkPhone()
|
||||
end
|
||||
end)
|
||||
|
||||
AddEventHandler('onClientResourceStop', function(resource)
|
||||
if resource == 'npwd' then
|
||||
npwd = nil
|
||||
end
|
||||
if resource == 'npwd' then
|
||||
npwd = nil
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterNetEvent('esx:onPlayerLogout', function()
|
||||
if not npwd then
|
||||
return
|
||||
end
|
||||
if not npwd then
|
||||
return
|
||||
end
|
||||
|
||||
npwd:setPhoneVisible(false)
|
||||
npwd:setPhoneDisabled(true)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('esx:removeInventoryItem', function(item, count)
|
||||
if not npwd then
|
||||
return
|
||||
end
|
||||
if not npwd then
|
||||
return
|
||||
end
|
||||
|
||||
if item == 'phone' and count == 0 then
|
||||
npwd:setPhoneDisabled(true)
|
||||
end
|
||||
if item == 'phone' and count == 0 then
|
||||
npwd:setPhoneDisabled(true)
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterNetEvent('esx:addInventoryItem', function(item)
|
||||
if not npwd or item ~= 'phone' then
|
||||
return
|
||||
end
|
||||
if not npwd or item ~= 'phone' then
|
||||
return
|
||||
end
|
||||
|
||||
npwd:setPhoneDisabled(false)
|
||||
end)
|
||||
npwd:setPhoneDisabled(false)
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user