From 8e420794e8a77e560677615323a9564c90da28fb Mon Sep 17 00:00:00 2001 From: Luke Fleck <33231394+Flek26@users.noreply.github.com> Date: Wed, 8 Jun 2022 11:23:34 -0500 Subject: [PATCH 1/3] v1.0.1 (add send job name to qbmenu) --- README.MD | 6 ++++++ config.lua | 8 ++++++-- data/client.lua | 54 ++++++++++++++++++++++++++++++++++++++++--------- data/server.lua | 27 ++++++++++++++++++++++++- 4 files changed, 83 insertions(+), 12 deletions(-) diff --git a/README.MD b/README.MD index 2721432..5897bd5 100644 --- a/README.MD +++ b/README.MD @@ -10,3 +10,9 @@ ALTER TABLE `players` ## Dependancies - QBCore - Qb-menu or Renzucontextmenu + +## Updates: +### v1.0.1: +- Added a callback to grab the label of job_two allowing you to put that on the menu +- Added support for old qbcore +![image](https://media.discordapp.net/attachments/854913681669095454/984098654858117190/unknown.png?width=211&height=107) diff --git a/config.lua b/config.lua index 0fc599a..0c06e52 100644 --- a/config.lua +++ b/config.lua @@ -1,7 +1,11 @@ Config = {} -- ONLY HAVE ONE OF THESE SET TO TRUE! Config.usingQBmenu = false -- If you want to use the QB Menu, set this to true. -Config.usingRenzuContext = true --- If you want to use the Renzu Context Menu, set this to true. https://github.com/renzuzu/renzu_contextmenu +Config.usingRenzuContext = false --- If you want to use the Renzu Context Menu, set this to true. https://github.com/renzuzu/renzu_contextmenu -- ^^^^^^ ONLY HAVE ONE OF THESE SET TO TRUE! -Config.OpenKey = 'NUMPAD9' -- The key to open the menu. \ No newline at end of file +Config.Core = 'new' -- what qbcore are you using | options allowed: 'old', 'new' +Cofnig.Open = 'command' -- how do you want to open the multijob menu | options allowed: 'command', 'key' +Config.OpenKey = 'NUMPAD9' -- The key to open the menu. - only used if Cofnig.Open is set to key +Config.Command = 'multijob' -- The command to open the menu. - only used if Cofnig.Open is set to command +Config.MenuHeader = 'Multi Job' -- Header for menu (qb-menu only for this version) \ No newline at end of file diff --git a/data/client.lua b/data/client.lua index 3bd8d75..fdacd49 100644 --- a/data/client.lua +++ b/data/client.lua @@ -1,22 +1,58 @@ -local QBCore = exports['qb-core']:GetCoreObject() +-- Variables -RegisterKeyMapping('+changejob', 'Toggle MultiJob Menu', 'keyboard', Config.OpenKey) +local QBCore = nil +local job2label = "Unknown" + +-- Grab core object + +if Config.Core == 'new' then --new core + QBCore = exports['qb-core']:GetCoreObject() +else --old core + Citizen.CreateThread(function() + while QBCore == nil do + TriggerEvent("QBCore:GetObject", function(obj) QBCore = obj end) + Citizen.Wait(10) + end + end) +end + +-- Register keybind or command + +if Cofnig.Open == "key" then + RegisterKeyMapping('+changejob', 'Toggle MultiJob Menu', 'keyboard', Config.OpenKey) + + RegisterCommand('+changejob', function() + TriggerEvent('710-multiJob:Client:OpenMenu') + end) +else + RegisterCommand(Config.Command, function() + TriggerEvent('710-multiJob:Client:OpenMenu') + end) +end + +-- Events -RegisterCommand('+changejob', function() - TriggerEvent('710-multiJob:Client:OpenMenu') -end) if Config.usingQBmenu then RegisterNetEvent('710-multiJob:Client:OpenMenu', function() + QBCore.Functions.TriggerCallback('710-multiJob:Server:checkjob2', function(results) + if not results then + TriggerEvent("QBCore:Notify", "Error Fetching Job ", "error") + job2label = "Unknown" + else + job2label = results + end + end) + Wait(1000) local Player = QBCore.Functions.GetPlayerData() local citizenid = Player.citizenid local Menu = { { - header = "

Job Changer
", + header = Config.MenuHeader, isMenuHeader = true }, { - header = "Change Jobs".."
You are currently working as "..Player.job.label..".
", - txt = '', + header = "Current Job: "..Player.job.label, + txt = "Click to change to "..job2label, params = { isServer = true, event = "710-multiJob:Server:ChangeJob", @@ -55,4 +91,4 @@ if Config.usingRenzuContext then TriggerEvent('renzu_contextmenu:insertmulti',multimenu,"Switch Job", false," Change Jobs
") TriggerEvent('renzu_contextmenu:show') end) -end \ No newline at end of file +end diff --git a/data/server.lua b/data/server.lua index c3c4145..4cec322 100644 --- a/data/server.lua +++ b/data/server.lua @@ -1,5 +1,16 @@ -local QBCore = exports['qb-core']:GetCoreObject() +-- Variables +local QBCore = nil + +-- Grab core object + +if Config.Core == 'new' then --new core + QBCore = exports['qb-core']:GetCoreObject() +else --old core + TriggerEvent('QBCore:GetObject', function(obj) QBCore = obj end) +end + +-- Events RegisterNetEvent('710-multiJob:Server:ChangeJob', function(args) local source = source @@ -23,3 +34,17 @@ RegisterNetEvent('710-multiJob:Server:ChangeJob', function(args) TriggerClientEvent('QBCore:Notify', source, "You have changed to your 2nd job "..Job2.label, 'primary', 5000) end end) + +-- Callbacks +QBCore.Functions.CreateCallback("710-multiJob:Server:checkjob2", function(source, cb) + local src = source + local Player = QBCore.Functions.GetPlayer(src) + local citizenid = Player.PlayerData.citizenid + local result = MySQL.query.await('SELECT job_two FROM players WHERE citizenid = ?',{citizenid}) + if result[1] then + local secondJobData = json.decode(result[1].job_two) + cb(secondJobData.label) + else + cb(false) + end +end) \ No newline at end of file From 92c9eccc96ed04c0883361c46cb667bf190edeb7 Mon Sep 17 00:00:00 2001 From: Luke Fleck <33231394+Flek26@users.noreply.github.com> Date: Wed, 8 Jun 2022 11:24:07 -0500 Subject: [PATCH 2/3] Update README.MD --- README.MD | 1 + 1 file changed, 1 insertion(+) diff --git a/README.MD b/README.MD index 5897bd5..652eb47 100644 --- a/README.MD +++ b/README.MD @@ -15,4 +15,5 @@ ALTER TABLE `players` ### v1.0.1: - Added a callback to grab the label of job_two allowing you to put that on the menu - Added support for old qbcore +## ![image](https://media.discordapp.net/attachments/854913681669095454/984098654858117190/unknown.png?width=211&height=107) From 2ddc59fdc77d4a2f4e8cd357414afe41c3ba8606 Mon Sep 17 00:00:00 2001 From: Luke Fleck <33231394+Flek26@users.noreply.github.com> Date: Wed, 8 Jun 2022 12:44:51 -0500 Subject: [PATCH 3/3] Update README.MD --- README.MD | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.MD b/README.MD index 652eb47..fe4736e 100644 --- a/README.MD +++ b/README.MD @@ -1,6 +1,6 @@ ## This is a simple Multijob script I made cause too many people were charging $15+ for something so simple. ![image](https://i.imgur.com/pwxro0E.png) - +Credit: https://github.com/Kmack710/710-multiJob ## Add this to your Database! Without this it wont work! Be sure to change payment amount below to the amount of your unemployeed Paycheque ```sql ALTER TABLE `players` @@ -11,7 +11,7 @@ ALTER TABLE `players` - QBCore - Qb-menu or Renzucontextmenu -## Updates: +## Flek's Updates: ### v1.0.1: - Added a callback to grab the label of job_two allowing you to put that on the menu - Added support for old qbcore