From da62365ab0a54c05f25206cba3833e93b32a1fac Mon Sep 17 00:00:00 2001 From: Csoki Date: Sun, 22 Jan 2023 15:57:20 +0100 Subject: [PATCH] refactor(server/classes/player): refactor some functions small code format --- [core]/es_extended/server/classes/player.lua | 51 ++++++++++---------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/[core]/es_extended/server/classes/player.lua b/[core]/es_extended/server/classes/player.lua index a9c2fa54c..d02757e04 100644 --- a/[core]/es_extended/server/classes/player.lua +++ b/[core]/es_extended/server/classes/player.lua @@ -121,17 +121,17 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory, end function self.getAccounts(minimal) - if minimal then - local minimalAccounts = {} + if not minimal then + return self.accounts + end - for i=1, #self.accounts do - minimalAccounts[self.accounts[i].name] = self.accounts[i].money - end + local minimalAccounts = {} - return minimalAccounts - else - return self.accounts + for i=1, #self.accounts do + minimalAccounts[self.accounts[i].name] = self.accounts[i].money end + + return minimalAccounts end function self.getAccount(account) @@ -163,32 +163,31 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory, end function self.getLoadout(minimal) - if minimal then - local minimalLoadout = {} + if not minimal then + return self.loadout + end + local minimalLoadout = {} - for k,v in ipairs(self.loadout) do - minimalLoadout[v.name] = {ammo = v.ammo} - if v.tintIndex > 0 then minimalLoadout[v.name].tintIndex = v.tintIndex end + for k,v in ipairs(self.loadout) do + minimalLoadout[v.name] = {ammo = v.ammo} + if v.tintIndex > 0 then minimalLoadout[v.name].tintIndex = v.tintIndex end - if #v.components > 0 then - local components = {} + if #v.components > 0 then + local components = {} - for k2,component in ipairs(v.components) do - if component ~= 'clip_default' then - components[#components + 1] = component - end + for k2,component in ipairs(v.components) do + if component ~= 'clip_default' then + components[#components + 1] = component end + end - if #components > 0 then - minimalLoadout[v.name].components = components - end + if #components > 0 then + minimalLoadout[v.name].components = components end end - - return minimalLoadout - else - return self.loadout end + + return minimalLoadout end function self.getName()