1
0
Fork 0
forked from Simnation/Main
This commit is contained in:
Nordi98 2025-06-29 06:49:57 +02:00
parent 755cf22c53
commit 2c2060cdc6

View file

@ -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
-- Find the highest rank number for _, rank in ipairs(Config.JobBossRanks[playerJobName].specificRanks) do
for grade, _ in pairs(jobGrades) do if playeJob.grade.level == rank then
local gradeNum = tonumber(grade) canAccessSociety = true
if gradeNum and gradeNum > highestRank then print("Boss access granted for " .. playerJobName .. " with specific rank " .. rank)
highestRank = gradeNum break
end end
end end
end
-- Check if player has the highest rank
if playeJob.grade.level == highestRank then -- If not already granted access and maxRank is enabled, check for highest rank
canAccessSociety = true if not canAccessSociety and Config.JobBossRanks[playerJobName].maxRank then
print("Boss access granted for " .. playerJobName .. " with highest rank " .. highestRank) -- Get all job grades for this job
else if QBCore.Shared.Jobs[playerJobName] and QBCore.Shared.Jobs[playerJobName].grades then
print("Not highest rank for " .. playerJobName .. ", current rank: " .. playeJob.grade.level .. ", highest: " .. highestRank) local jobGrades = QBCore.Shared.Jobs[playerJobName].grades
end local highestRank = -1
elseif playerGangName == v then
-- Similar logic for gangs if needed -- Find the highest rank number
end 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 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,
@ -930,4 +973,5 @@ AddEventHandler("okokBanking:updateTransactionsSociety", function(wallet)
end) end)
end, society) end, society)
end, society) end, society)
end) end)