From 4f02caef47b10cb8e2b932a07a95dd15809e7220 Mon Sep 17 00:00:00 2001 From: Thekuca <63980591+Thekuca@users.noreply.github.com> Date: Sun, 7 May 2023 21:25:37 +0200 Subject: [PATCH] refactor(modules/nwpd): format code --- [core]/es_extended/client/modules/npwd.lua | 59 +++++++++++----------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/[core]/es_extended/client/modules/npwd.lua b/[core]/es_extended/client/modules/npwd.lua index b8de8dab..b6c7ac75 100644 --- a/[core]/es_extended/client/modules/npwd.lua +++ b/[core]/es_extended/client/modules/npwd.lua @@ -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 = ESX.SearchInventory('phone') - npwd:setPhoneDisabled((phoneItem and phoneItem.count or 0) <= 0) + local phoneItem = 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) \ No newline at end of file + npwd:setPhoneDisabled(false) +end)