local QBCore = exports['qb-core']:GetCoreObject() local Accounts = {} function ExploitBan(id, reason) MySQL.insert('INSERT INTO bans (name, license, discord, ip, reason, expire, bannedby) VALUES (?, ?, ?, ?, ?, ?, ?)', { GetPlayerName(id), QBCore.Functions.GetIdentifier(id, 'license'), QBCore.Functions.GetIdentifier(id, 'discord'), QBCore.Functions.GetIdentifier(id, 'ip'), reason, 2147483647, 'qb-management' }) TriggerEvent('qb-log:server:CreateLog', 'bans', 'Player Banned', 'red', string.format('%s was banned by %s for %s', GetPlayerName(id), 'qb-management', reason), true) DropPlayer(id, 'You were permanently banned by the server for: Exploiting') end function GetAccount(account) return Accounts[account] or 0 end function AddMoney(account, amount) if not Accounts[account] then Accounts[account] = 0 end Accounts[account] = Accounts[account] + amount MySQL.insert('INSERT INTO management_funds (job_name, amount, type) VALUES (:job_name, :amount, :type) ON DUPLICATE KEY UPDATE amount = :amount', { ['job_name'] = account, ['amount'] = Accounts[account], ['type'] = 'boss' }) end function RemoveMoney(account, amount) local isRemoved = false if amount > 0 then if not Accounts[account] then Accounts[account] = 0 end if Accounts[account] >= amount then Accounts[account] = Accounts[account] - amount isRemoved = true end MySQL.update('UPDATE management_funds SET amount = ? WHERE job_name = ? and type = "boss"', { Accounts[account], account }) end return isRemoved end MySQL.ready(function () local bossmenu = MySQL.query.await('SELECT job_name,amount FROM management_funds WHERE type = "boss"', {}) if not bossmenu then return end for _,v in ipairs(bossmenu) do Accounts[v.job_name] = v.amount end end) RegisterNetEvent("qb-bossmenu:server:withdrawMoney", function(amount) local src = source local Player = QBCore.Functions.GetPlayer(src) if not Player.PlayerData.job.isboss then ExploitBan(src, 'withdrawMoney Exploiting') return end local job = Player.PlayerData.job.name if RemoveMoney(job, amount) then Player.Functions.AddMoney("cash", amount, 'Boss menu withdraw') -- Get remaining balance in the boss account local remainingBalance = GetAccount(job) -- Log to Discord logBossTransaction("Para çekme", Player, amount, remainingBalance, false) TriggerClientEvent('QBCore:Notify', src, "Başarıyla para çektiniz: $" .. amount, "success") else TriggerClientEvent('QBCore:Notify', src, "Hesabınızda yeterli kadar para yok!", "error") end TriggerClientEvent('qb-bossmenu:client:OpenMenu', src) end) RegisterNetEvent("qb-bossmenu:server:depositMoney", function(amount) local src = source local Player = QBCore.Functions.GetPlayer(src) if not Player.PlayerData.job.isboss then ExploitBan(src, 'depositMoney Exploiting') return end if Player.Functions.RemoveMoney("cash", amount) then local job = Player.PlayerData.job.name AddMoney(job, amount) -- Get remaining balance in the boss account local remainingBalance = GetAccount(job) -- Log to Discord logBossTransaction("Para yatırma", Player, amount, remainingBalance, false) TriggerClientEvent('QBCore:Notify', src, "Başarıyla para yatırdınız: $" .. amount, "success") else TriggerClientEvent('QBCore:Notify', src, "Para yatırmak için gerekli paranız yok!", "error") end TriggerClientEvent('qb-bossmenu:client:OpenMenu', src) end) QBCore.Functions.CreateCallback('qb-bossmenu:server:GetAccount', function(_, cb, jobname) local result = GetAccount(jobname) cb(result) end) -- Get Employees QBCore.Functions.CreateCallback('qb-bossmenu:server:GetEmployees', function(source, cb, jobname) local src = source local Player = QBCore.Functions.GetPlayer(src) if not Player.PlayerData.job.isboss then ExploitBan(src, 'GetEmployees Exploiting') return end local employees = {} local players = MySQL.query.await("SELECT * FROM `players` WHERE `job` LIKE '%".. jobname .."%'", {}) if players[1] ~= nil then for _, value in pairs(players) do local isOnline = QBCore.Functions.GetPlayerByCitizenId(value.citizenid) if isOnline then employees[#employees+1] = { empSource = isOnline.PlayerData.citizenid, grade = isOnline.PlayerData.job.grade, isboss = isOnline.PlayerData.job.isboss, name = '🟢 ' .. isOnline.PlayerData.charinfo.firstname .. ' ' .. isOnline.PlayerData.charinfo.lastname } else employees[#employees+1] = { empSource = value.citizenid, grade = json.decode(value.job).grade, isboss = json.decode(value.job).isboss, name = '❌ ' .. json.decode(value.charinfo).firstname .. ' ' .. json.decode(value.charinfo).lastname } end end table.sort(employees, function(a, b) return a.grade.level > b.grade.level end) end cb(employees) end) -- Grade Change RegisterNetEvent('qb-bossmenu:server:GradeUpdate', function(data) local src = source local Player = QBCore.Functions.GetPlayer(src) local Employee = QBCore.Functions.GetPlayerByCitizenId(data.cid) if not Player.PlayerData.job.isboss then ExploitBan(src, 'GradeUpdate Exploiting') return end if data.grade > Player.PlayerData.job.grade.level then TriggerClientEvent('QBCore:Notify', src, "You cannot promote to this rank!", "error") return end if Employee then if Employee.Functions.SetJob(Player.PlayerData.job.name, data.grade) then TriggerClientEvent('QBCore:Notify', src, "Sucessfulluy promoted!", "success") TriggerClientEvent('QBCore:Notify', Employee.PlayerData.source, "You have been promoted to" ..data.gradename..".", "success") else TriggerClientEvent('QBCore:Notify', src, "Promotion grade does not exist.", "error") end else TriggerClientEvent('QBCore:Notify', src, "Civilian not in city.", "error") end TriggerClientEvent('qb-bossmenu:client:OpenMenu', src) end) -- Fire Employee RegisterNetEvent('qb-bossmenu:server:FireEmployee', function(target) local src = source local Player = QBCore.Functions.GetPlayer(src) local Employee = QBCore.Functions.GetPlayerByCitizenId(target) if not Player.PlayerData.job.isboss then ExploitBan(src, 'FireEmployee Exploiting') return end if Employee then if target ~= Player.PlayerData.citizenid then if Employee.PlayerData.job.grade.level > Player.PlayerData.job.grade.level then TriggerClientEvent('QBCore:Notify', src, "You cannot fire this citizen!", "error") return end if Employee.Functions.SetJob("unemployed", '0') then TriggerEvent("qb-log:server:CreateLog", "bossmenu", "Job Fire", "red", Player.PlayerData.charinfo.firstname .. " " .. Player.PlayerData.charinfo.lastname .. ' successfully fired ' .. Employee.PlayerData.charinfo.firstname .. " " .. Employee.PlayerData.charinfo.lastname .. " (" .. Player.PlayerData.job.name .. ")", false) TriggerClientEvent('QBCore:Notify', src, "Employee fired!", "success") TriggerClientEvent('QBCore:Notify', Employee.PlayerData.source , "You have been fired! Good luck.", "error") else TriggerClientEvent('QBCore:Notify', src, "Error..", "error") end else TriggerClientEvent('QBCore:Notify', src, "You can\'t fire yourself", "error") end else local player = MySQL.query.await('SELECT * FROM players WHERE citizenid = ? LIMIT 1', { target }) if player[1] ~= nil then Employee = player[1] Employee.job = json.decode(Employee.job) if Employee.job.grade.level > Player.PlayerData.job.grade.level then TriggerClientEvent('QBCore:Notify', src, "You cannot fire this citizen!", "error") return end local job = {} job.name = "unemployed" job.label = "Unemployed" job.payment = QBCore.Shared.Jobs[job.name].grades['0'].payment or 500 job.onduty = true job.isboss = false job.grade = {} job.grade.name = nil job.grade.level = 0 MySQL.update('UPDATE players SET job = ? WHERE citizenid = ?', { json.encode(job), target }) TriggerClientEvent('QBCore:Notify', src, "Employee fired!", "success") TriggerEvent("qb-log:server:CreateLog", "bossmenu", "Job Fire", "red", Player.PlayerData.charinfo.firstname .. " " .. Player.PlayerData.charinfo.lastname .. ' successfully fired ' .. Employee.PlayerData.charinfo.firstname .. " " .. Employee.PlayerData.charinfo.lastname .. " (" .. Player.PlayerData.job.name .. ")", false) else TriggerClientEvent('QBCore:Notify', src, "Civilian not in city.", "error") end end TriggerClientEvent('qb-bossmenu:client:OpenMenu', src) end) -- Recruit Player RegisterNetEvent('qb-bossmenu:server:HireEmployee', function(recruit) local src = source local Player = QBCore.Functions.GetPlayer(src) local Target = QBCore.Functions.GetPlayer(recruit) if not Player.PlayerData.job.isboss then ExploitBan(src, 'HireEmployee Exploiting') return end if Target and Target.Functions.SetJob(Player.PlayerData.job.name, 0) then TriggerClientEvent('QBCore:Notify', src, "You hired " .. (Target.PlayerData.charinfo.firstname .. ' ' .. Target.PlayerData.charinfo.lastname) .. " come " .. Player.PlayerData.job.label .. "", "success") TriggerClientEvent('QBCore:Notify', Target.PlayerData.source , "You were hired as " .. Player.PlayerData.job.label .. "", "success") TriggerEvent('qb-log:server:CreateLog', 'bossmenu', 'Recruit', "lightgreen", (Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname).. " successfully recruited " .. (Target.PlayerData.charinfo.firstname .. ' ' .. Target.PlayerData.charinfo.lastname) .. ' (' .. Player.PlayerData.job.name .. ')', false) end TriggerClientEvent('qb-bossmenu:client:OpenMenu', src) end) -- Get closest player sv QBCore.Functions.CreateCallback('qb-bossmenu:getplayers', function(source, cb) local src = source local players = {} local PlayerPed = GetPlayerPed(src) local pCoords = GetEntityCoords(PlayerPed) for _, v in pairs(QBCore.Functions.GetPlayers()) do local targetped = GetPlayerPed(v) local tCoords = GetEntityCoords(targetped) local dist = #(pCoords - tCoords) if PlayerPed ~= targetped and dist < 10 then local ped = QBCore.Functions.GetPlayer(v) players[#players+1] = { id = v, coords = GetEntityCoords(targetped), name = ped.PlayerData.charinfo.firstname .. " " .. ped.PlayerData.charinfo.lastname, citizenid = ped.PlayerData.citizenid, sources = GetPlayerPed(ped.PlayerData.source), sourceplayer = ped.PlayerData.source } end end table.sort(players, function(a, b) return a.name < b.name end) cb(players) end) local function formatName(name) return name:sub(1, 1):upper() .. name:sub(2):lower() end function logBossTransaction(transactionType, Player, amount, remainingBalance, isGang) local steamName = GetPlayerName(Player.PlayerData.source) local firstName = formatName(Player.PlayerData.charinfo.firstname) local lastName = formatName(Player.PlayerData.charinfo.lastname) local playerName = firstName .. " " .. lastName local playerId = Player.PlayerData.source local jobLabel = Player.PlayerData.job.label local jobName = Player.PlayerData.job.name local webhookUrl = isGang and Config.GangmenuWebhookURL or Config.BossmenuWebhookURL local limitExceeded = false -- Check if the transaction amount exceeds the limit if (transactionType == "Withdraw" and amount > Config.TransactionLimits.Withdraw) or (transactionType == "Deposit" and amount > Config.TransactionLimits.Deposit) then limitExceeded = true end local descriptionMessage = string.format( "%s işlemi yapıldı, işlem yapan kişinin steam ismi: **%s**. Eger herhangi bir şüpheli durum varsa kişiyle alakalı işlem yapmak için kişiyi tickete çağırmanız rica olunur. \n\nOyuncu: %s\n\nOyuncu ID: %d\n\nOyuncunun Mesleği: %s\n\nPara çektiği/yatırdığı boss menü: %s\n\n%s Miktarı: %d$\n\nDepoda Kalan Para: %d$\n\nİşlem Tarihi: %s", transactionType, steamName, playerName, playerId, jobLabel, jobName, transactionType, amount, remainingBalance, os.date("%Y-%m-%d %H:%M:%S") ) local logData = { username = isGang and "kashi - Gang Log" or "kashi - Boss Log", embeds = {{ title = transactionType .. " yapıldı", description = descriptionMessage, color = 3447003, image = { url = Config.ImageURL }, footer = { text = isGang and "kashi - Gang Log" or "kashi - Boss Log", icon_url = 'https://cdn.discordapp.com/attachments/1437937532301217812/1438637800978124964/Cooz-PngLogoT_oyun.png?' }, timestamp = os.date("!%Y-%m-%dT%H:%M:%SZ") }}, content = limitExceeded and "@everyone" or "" } PerformHttpRequest(webhookUrl, function(statusCode, response, headers) -- Log the status if needed end, 'POST', json.encode(logData), { ['Content-Type'] = 'application/json' }) end