forked from Simnation/Main
fix
This commit is contained in:
parent
755cf22c53
commit
2c2060cdc6
1 changed files with 98 additions and 54 deletions
|
@ -73,30 +73,74 @@ function openBank()
|
||||||
QBCore.Functions.TriggerCallback("okokBanking:GetPlayerInfo", function(data)
|
QBCore.Functions.TriggerCallback("okokBanking:GetPlayerInfo", function(data)
|
||||||
QBCore.Functions.TriggerCallback("okokBanking:GetOverviewTransactions", function(cb, identifier, allDays)
|
QBCore.Functions.TriggerCallback("okokBanking:GetOverviewTransactions", function(cb, identifier, allDays)
|
||||||
for k,v in pairs(Config.Societies) do
|
for k,v in pairs(Config.Societies) do
|
||||||
if playerJobName == v then
|
if playerJobName == v then
|
||||||
-- Get all job grades for this job
|
-- Check if job has configuration in JobBossRanks
|
||||||
local jobGrades = QBCore.Shared.Jobs[playerJobName].grades
|
if Config.JobBossRanks and Config.JobBossRanks[playerJobName] then
|
||||||
local highestRank = -1
|
-- Check for specific ranks first
|
||||||
|
if Config.JobBossRanks[playerJobName].specificRanks and #Config.JobBossRanks[playerJobName].specificRanks > 0 then
|
||||||
|
for _, rank in ipairs(Config.JobBossRanks[playerJobName].specificRanks) do
|
||||||
|
if playeJob.grade.level == rank then
|
||||||
|
canAccessSociety = true
|
||||||
|
print("Boss access granted for " .. playerJobName .. " with specific rank " .. rank)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Find the highest rank number
|
-- If not already granted access and maxRank is enabled, check for highest rank
|
||||||
for grade, _ in pairs(jobGrades) do
|
if not canAccessSociety and Config.JobBossRanks[playerJobName].maxRank then
|
||||||
local gradeNum = tonumber(grade)
|
-- Get all job grades for this job
|
||||||
if gradeNum and gradeNum > highestRank then
|
if QBCore.Shared.Jobs[playerJobName] and QBCore.Shared.Jobs[playerJobName].grades then
|
||||||
highestRank = gradeNum
|
local jobGrades = QBCore.Shared.Jobs[playerJobName].grades
|
||||||
end
|
local highestRank = -1
|
||||||
end
|
|
||||||
|
|
||||||
-- Check if player has the highest rank
|
-- Find the highest rank number
|
||||||
if playeJob.grade.level == highestRank then
|
for grade, _ in pairs(jobGrades) do
|
||||||
canAccessSociety = true
|
local gradeNum = tonumber(grade)
|
||||||
print("Boss access granted for " .. playerJobName .. " with highest rank " .. highestRank)
|
if gradeNum and gradeNum > highestRank then
|
||||||
else
|
highestRank = gradeNum
|
||||||
print("Not highest rank for " .. playerJobName .. ", current rank: " .. playeJob.grade.level .. ", highest: " .. highestRank)
|
end
|
||||||
end
|
end
|
||||||
elseif playerGangName == v then
|
|
||||||
-- Similar logic for gangs if needed
|
|
||||||
end
|
|
||||||
|
|
||||||
|
-- Check if player has the highest rank
|
||||||
|
if playeJob.grade.level == highestRank then
|
||||||
|
canAccessSociety = true
|
||||||
|
print("Boss access granted for " .. playerJobName .. " with highest rank " .. highestRank)
|
||||||
|
else
|
||||||
|
print("Not highest rank for " .. playerJobName .. ", current rank: " .. playeJob.grade.level .. ", highest: " .. highestRank)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
-- Fallback to original highest rank check if no configuration exists
|
||||||
|
if QBCore.Shared.Jobs[playerJobName] and QBCore.Shared.Jobs[playerJobName].grades then
|
||||||
|
local jobGrades = QBCore.Shared.Jobs[playerJobName].grades
|
||||||
|
local highestRank = -1
|
||||||
|
|
||||||
|
-- Find the highest rank number
|
||||||
|
for grade, _ in pairs(jobGrades) do
|
||||||
|
local gradeNum = tonumber(grade)
|
||||||
|
if gradeNum and gradeNum > highestRank then
|
||||||
|
highestRank = gradeNum
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Check if player has the highest rank
|
||||||
|
if playeJob.grade.level == highestRank then
|
||||||
|
canAccessSociety = true
|
||||||
|
print("Boss access granted for " .. playerJobName .. " with highest rank " .. highestRank)
|
||||||
|
else
|
||||||
|
print("Not highest rank for " .. playerJobName .. ", current rank: " .. playeJob.grade.level .. ", highest: " .. highestRank)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
elseif playerGangName == v then
|
||||||
|
if data.isBossGang == true then
|
||||||
|
jobLabel = playerGangName
|
||||||
|
society = playerGangName
|
||||||
|
canAccessSociety = true
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if canAccessSociety then
|
if canAccessSociety then
|
||||||
|
@ -137,29 +181,29 @@ end
|
||||||
if data.playerIBAN ~= nil then
|
if data.playerIBAN ~= nil then
|
||||||
if string.starts(data.playerIBAN, Config.IBANPrefix) then
|
if string.starts(data.playerIBAN, Config.IBANPrefix) then
|
||||||
if isBankOpened then
|
if isBankOpened then
|
||||||
SetNuiFocus(true, true)
|
SetNuiFocus(true, true)
|
||||||
end
|
end
|
||||||
SendNUIMessage({
|
SendNUIMessage({
|
||||||
action = 'bankmenu',
|
action = 'bankmenu',
|
||||||
playerName = data.playerName,
|
playerName = data.playerName,
|
||||||
playerSex = data.sex,
|
playerSex = data.sex,
|
||||||
playerBankMoney = data.playerBankMoney,
|
playerBankMoney = data.playerBankMoney,
|
||||||
walletMoney = walletMoney,
|
walletMoney = walletMoney,
|
||||||
playerIBAN = data.playerIBAN,
|
playerIBAN = data.playerIBAN,
|
||||||
db = trans,
|
db = trans,
|
||||||
identifier = trsIdentifier,
|
identifier = trsIdentifier,
|
||||||
graphDays = allDaysValues,
|
graphDays = allDaysValues,
|
||||||
isInSociety = canAccessSociety,
|
isInSociety = canAccessSociety,
|
||||||
RequireCC = Config.RequireCreditCardForATM,
|
RequireCC = Config.RequireCreditCardForATM,
|
||||||
UseSound = Config.UseOkOkBankingSounds,
|
UseSound = Config.UseOkOkBankingSounds,
|
||||||
})
|
})
|
||||||
else
|
else
|
||||||
GenerateIBAN()
|
GenerateIBAN()
|
||||||
Wait(1000)
|
Wait(1000)
|
||||||
QBCore.Functions.TriggerCallback("okokBanking:GetPlayerInfo", function(data)
|
QBCore.Functions.TriggerCallback("okokBanking:GetPlayerInfo", function(data)
|
||||||
if isBankOpened then
|
if isBankOpened then
|
||||||
SetNuiFocus(true, true)
|
SetNuiFocus(true, true)
|
||||||
end
|
end
|
||||||
SendNUIMessage({
|
SendNUIMessage({
|
||||||
action = 'bankmenu',
|
action = 'bankmenu',
|
||||||
playerName = data.playerName,
|
playerName = data.playerName,
|
||||||
|
@ -289,8 +333,8 @@ else
|
||||||
|
|
||||||
if not isDead and not IsPedInAnyVehicle(playerped) then
|
if not isDead and not IsPedInAnyVehicle(playerped) then
|
||||||
if isBankOpened then
|
if isBankOpened then
|
||||||
SetNuiFocus(true, true)
|
SetNuiFocus(true, true)
|
||||||
end
|
end
|
||||||
SendNUIMessage({
|
SendNUIMessage({
|
||||||
action = 'loading_data'
|
action = 'loading_data'
|
||||||
})
|
})
|
||||||
|
@ -588,8 +632,8 @@ end
|
||||||
RegisterNetEvent("okokBanking:OpenATM")
|
RegisterNetEvent("okokBanking:OpenATM")
|
||||||
AddEventHandler("okokBanking:OpenATM", function(pin)
|
AddEventHandler("okokBanking:OpenATM", function(pin)
|
||||||
if isBankOpened then
|
if isBankOpened then
|
||||||
SetNuiFocus(true, true)
|
SetNuiFocus(true, true)
|
||||||
end
|
end
|
||||||
SendNUIMessage({
|
SendNUIMessage({
|
||||||
action = 'atm',
|
action = 'atm',
|
||||||
pin = pin,
|
pin = pin,
|
||||||
|
@ -597,8 +641,6 @@ AddEventHandler("okokBanking:OpenATM", function(pin)
|
||||||
})
|
})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RegisterNUICallback("action", function(data, cb)
|
RegisterNUICallback("action", function(data, cb)
|
||||||
if data.action == "close" then
|
if data.action == "close" then
|
||||||
isBankOpened = false
|
isBankOpened = false
|
||||||
|
@ -843,6 +885,7 @@ RegisterNUICallback("action", function(data, cb)
|
||||||
cb('ok')
|
cb('ok')
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
RegisterNetEvent("okokBanking:updateTransactions")
|
RegisterNetEvent("okokBanking:updateTransactions")
|
||||||
AddEventHandler("okokBanking:updateTransactions", function(money, wallet)
|
AddEventHandler("okokBanking:updateTransactions", function(money, wallet)
|
||||||
Wait(100)
|
Wait(100)
|
||||||
|
@ -851,8 +894,8 @@ AddEventHandler("okokBanking:updateTransactions", function(money, wallet)
|
||||||
trans = cb
|
trans = cb
|
||||||
allDaysValues = allDays
|
allDaysValues = allDays
|
||||||
if isBankOpened then
|
if isBankOpened then
|
||||||
SetNuiFocus(true, true)
|
SetNuiFocus(true, true)
|
||||||
end
|
end
|
||||||
SendNUIMessage({
|
SendNUIMessage({
|
||||||
action = 'overview_page',
|
action = 'overview_page',
|
||||||
playerBankMoney = playerBankMoney,
|
playerBankMoney = playerBankMoney,
|
||||||
|
@ -914,8 +957,8 @@ AddEventHandler("okokBanking:updateTransactionsSociety", function(wallet)
|
||||||
societyInfo = cb
|
societyInfo = cb
|
||||||
if cb ~= nil then
|
if cb ~= nil then
|
||||||
if isBankOpened then
|
if isBankOpened then
|
||||||
SetNuiFocus(true, true)
|
SetNuiFocus(true, true)
|
||||||
end
|
end
|
||||||
SendNUIMessage({
|
SendNUIMessage({
|
||||||
action = 'society_page',
|
action = 'society_page',
|
||||||
walletMoney = wallet,
|
walletMoney = wallet,
|
||||||
|
@ -931,3 +974,4 @@ AddEventHandler("okokBanking:updateTransactionsSociety", function(wallet)
|
||||||
end, society)
|
end, society)
|
||||||
end, society)
|
end, society)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue