Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
fix nil value of add salary to player
Browse files Browse the repository at this point in the history
  • Loading branch information
yeganehha committed Mar 9, 2021
1 parent bd28f24 commit 4851c61
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions server/salary.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 4851c61

Please sign in to comment.