From 4851c61c479c07d7ad0e9a72a5d326ee444d0e5a Mon Sep 17 00:00:00 2001 From: erfan ebrahimi Date: Tue, 9 Mar 2021 16:40:36 +0330 Subject: [PATCH] fix nil value of add salary to player --- server/salary.lua | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/server/salary.lua b/server/salary.lua index c2f9a3e..a51bdfe 100644 --- a/server/salary.lua +++ b/server/salary.lua @@ -25,16 +25,18 @@ function payCheck() local salaries = selectFromDB("SELECT g.accountMoney,gm.gangId,gm.playerIdentifiers,gg.salary FROM gangs_member gm Left Join gangs_grade gg on (gm.gangId = gg.gangId and gm.grade = gg.grade ) Left Join gangs g on (g.id = gm.gangId ) where g.expireTime > NOW() and gg.salary > 0 " .. query , queryParameter) local gradeSalary = {} for _k,salary in ipairs(salaries) do - if not gradeSalary[salary.gangId] then - gradeSalary[salary.gangId] = tonumber(salary.accountMoney) - end - if gradeSalary[salary.gangId] >= tonumber(salary.salary) then - if addSalary(members[salary.playerIdentifiers] , tonumber(salary.salary)) then - gradeSalary[salary.gangId] = gradeSalary[salary.gangId] - tonumber(salary.salary) - TriggerClientEvent('Erfan:gang:sendNotfication',members[salary.playerIdentifiers],'[Gang System]', '' , _U('calary_recived' , salary.salary) , 'CHAR_BANK_MAZE' , 9 ) + if members[salary.playerIdentifiers] ~= nil then + if not gradeSalary[salary.gangId] then + gradeSalary[salary.gangId] = tonumber(salary.accountMoney) + end + if gradeSalary[salary.gangId] >= tonumber(salary.salary) then + if addSalary(members[salary.playerIdentifiers] , tonumber(salary.salary)) then + gradeSalary[salary.gangId] = gradeSalary[salary.gangId] - tonumber(salary.salary) + TriggerClientEvent('Erfan:gang:sendNotfication',members[salary.playerIdentifiers],'[Gang System]', '' , _U('calary_recived' , salary.salary) , 'CHAR_BANK_MAZE' , 9 ) + end + else + TriggerClientEvent('Erfan:gang:sendNotfication',members[salary.playerIdentifiers],'[Gang System]', '' , _U('your_gang_is_poor') , 'CHAR_BANK_MAZE' , 1 ) end - else - TriggerClientEvent('Erfan:gang:sendNotfication',members[salary.playerIdentifiers],'[Gang System]', '' , _U('your_gang_is_poor') , 'CHAR_BANK_MAZE' , 1 ) end end for gangId,accountMoney in pairs(gradeSalary) do @@ -44,7 +46,9 @@ function payCheck() }, function(e) if activeGangMember['g_'..gangId] then for k,v in ipairs(activeGangMember['g_'..gangId]) do - TriggerClientEvent('Erfan:gang:setGangAccountMoney',v,gangId,'set',accountMoney) + if v ~= nil then + TriggerClientEvent('Erfan:gang:setGangAccountMoney',v,gangId,'set',accountMoney) + end end end end)