refactor(server/classes/player): refactor some functions

small code format
This commit is contained in:
Csoki
2023-01-22 15:57:20 +01:00
parent e4f81a7523
commit da62365ab0
+32 -33
View File
@@ -121,17 +121,17 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
end
function self.getAccounts(minimal)
if minimal then
local minimalAccounts = {}
for i=1, #self.accounts do
minimalAccounts[self.accounts[i].name] = self.accounts[i].money
end
return minimalAccounts
else
if not minimal then
return self.accounts
end
local minimalAccounts = {}
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 = {}
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 = {}
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
end
end
return minimalLoadout
else
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
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
end
if #components > 0 then
minimalLoadout[v.name].components = components
end
end
end
return minimalLoadout
end
function self.getName()