From 2c2060cdc65e2ce041dc8aa6e594a8e995cb4259 Mon Sep 17 00:00:00 2001 From: Nordi98 Date: Sun, 29 Jun 2025 06:49:57 +0200 Subject: [PATCH] fix --- resources/[tools]/okokBanking/client.lua | 152 +++++++++++++++-------- 1 file changed, 98 insertions(+), 54 deletions(-) diff --git a/resources/[tools]/okokBanking/client.lua b/resources/[tools]/okokBanking/client.lua index 1b8e4dfe1..b982924ee 100644 --- a/resources/[tools]/okokBanking/client.lua +++ b/resources/[tools]/okokBanking/client.lua @@ -73,30 +73,74 @@ function openBank() QBCore.Functions.TriggerCallback("okokBanking:GetPlayerInfo", function(data) QBCore.Functions.TriggerCallback("okokBanking:GetOverviewTransactions", function(cb, identifier, allDays) for k,v in pairs(Config.Societies) do -if playerJobName == v then - -- Get all job grades for this job - 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 -elseif playerGangName == v then - -- Similar logic for gangs if needed -end - + if playerJobName == v then + -- Check if job has configuration in JobBossRanks + if Config.JobBossRanks and Config.JobBossRanks[playerJobName] then + -- 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 + + -- If not already granted access and maxRank is enabled, check for highest rank + if not canAccessSociety and Config.JobBossRanks[playerJobName].maxRank then + -- Get all job grades for this job + 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 + 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 if canAccessSociety then @@ -137,29 +181,29 @@ end if data.playerIBAN ~= nil then if string.starts(data.playerIBAN, Config.IBANPrefix) then if isBankOpened then - SetNuiFocus(true, true) - end - SendNUIMessage({ - action = 'bankmenu', - playerName = data.playerName, - playerSex = data.sex, - playerBankMoney = data.playerBankMoney, - walletMoney = walletMoney, - playerIBAN = data.playerIBAN, - db = trans, - identifier = trsIdentifier, - graphDays = allDaysValues, - isInSociety = canAccessSociety, - RequireCC = Config.RequireCreditCardForATM, - UseSound = Config.UseOkOkBankingSounds, - }) + SetNuiFocus(true, true) + end + SendNUIMessage({ + action = 'bankmenu', + playerName = data.playerName, + playerSex = data.sex, + playerBankMoney = data.playerBankMoney, + walletMoney = walletMoney, + playerIBAN = data.playerIBAN, + db = trans, + identifier = trsIdentifier, + graphDays = allDaysValues, + isInSociety = canAccessSociety, + RequireCC = Config.RequireCreditCardForATM, + UseSound = Config.UseOkOkBankingSounds, + }) else GenerateIBAN() Wait(1000) QBCore.Functions.TriggerCallback("okokBanking:GetPlayerInfo", function(data) - if isBankOpened then - SetNuiFocus(true, true) - end + if isBankOpened then + SetNuiFocus(true, true) + end SendNUIMessage({ action = 'bankmenu', playerName = data.playerName, @@ -289,8 +333,8 @@ else if not isDead and not IsPedInAnyVehicle(playerped) then if isBankOpened then - SetNuiFocus(true, true) - end + SetNuiFocus(true, true) + end SendNUIMessage({ action = 'loading_data' }) @@ -588,8 +632,8 @@ end RegisterNetEvent("okokBanking:OpenATM") AddEventHandler("okokBanking:OpenATM", function(pin) if isBankOpened then - SetNuiFocus(true, true) - end + SetNuiFocus(true, true) + end SendNUIMessage({ action = 'atm', pin = pin, @@ -597,8 +641,6 @@ AddEventHandler("okokBanking:OpenATM", function(pin) }) end) - - RegisterNUICallback("action", function(data, cb) if data.action == "close" then isBankOpened = false @@ -843,6 +885,7 @@ RegisterNUICallback("action", function(data, cb) cb('ok') end) + RegisterNetEvent("okokBanking:updateTransactions") AddEventHandler("okokBanking:updateTransactions", function(money, wallet) Wait(100) @@ -851,8 +894,8 @@ AddEventHandler("okokBanking:updateTransactions", function(money, wallet) trans = cb allDaysValues = allDays if isBankOpened then - SetNuiFocus(true, true) - end + SetNuiFocus(true, true) + end SendNUIMessage({ action = 'overview_page', playerBankMoney = playerBankMoney, @@ -914,8 +957,8 @@ AddEventHandler("okokBanking:updateTransactionsSociety", function(wallet) societyInfo = cb if cb ~= nil then if isBankOpened then - SetNuiFocus(true, true) - end + SetNuiFocus(true, true) + end SendNUIMessage({ action = 'society_page', walletMoney = wallet, @@ -930,4 +973,5 @@ AddEventHandler("okokBanking:updateTransactionsSociety", function(wallet) end) end, society) end, society) -end) \ No newline at end of file +end) +