Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion README.MD
Original file line number Diff line number Diff line change
@@ -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`
Expand All @@ -10,3 +10,10 @@ ALTER TABLE `players`
## Dependancies
- QBCore
- Qb-menu or Renzucontextmenu

## 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
##
![image](https://media.discordapp.net/attachments/854913681669095454/984098654858117190/unknown.png?width=211&height=107)
8 changes: 6 additions & 2 deletions config.lua
Original file line number Diff line number Diff line change
@@ -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.
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)
54 changes: 45 additions & 9 deletions data/client.lua
Original file line number Diff line number Diff line change
@@ -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 = "<center><img src=https://i.imgur.com/0SqHk1a.png width=50vh></center><br>Job Changer<br>",
header = Config.MenuHeader,
isMenuHeader = true
},
{
header = "Change Jobs".."<br>You are currently working as "..Player.job.label..".<br>",
txt = '',
header = "Current Job: "..Player.job.label,
txt = "Click to change to "..job2label,
params = {
isServer = true,
event = "710-multiJob:Server:ChangeJob",
Expand Down Expand Up @@ -55,4 +91,4 @@ if Config.usingRenzuContext then
TriggerEvent('renzu_contextmenu:insertmulti',multimenu,"Switch Job", false,"<left><img src=https://i.imgur.com/0SqHk1a.png width=35vh></center></i> Change Jobs<br>")
TriggerEvent('renzu_contextmenu:show')
end)
end
end
27 changes: 26 additions & 1 deletion data/server.lua
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)