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 + 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 = "

Change Jobs