π§ Multijob Integration
Overview
BIT-TreasureHunting can be easily integrated into any multijob system, allowing players to start the treasure hunting job without interacting with the NPC. This provides flexibility for servers that use centralized job management systems.
Server Trigger
Use this server-side trigger to open the job menu for any player:
TriggerClientEvent("bit-treasurehunting:open", playerID)
This shows the job menu and requests nearby players from the server to build a team.
Integration Examples
ESX Job Menu
If you're using an ESX-based job menu:
-- In your job menu script
RegisterServerEvent('esx_jobmenu:startTreasureHunting')
AddEventHandler('esx_jobmenu:startTreasureHunting', function()
local xPlayer = ESX.GetPlayerFromId(source)
-- Check if player meets requirements
if xPlayer then
TriggerClientEvent("bit-treasurehunting:open", source)
end
end)
QBCore Job System
For QBCore multijob integration:
-- In your QB job center
RegisterServerEvent('qb-jobcenter:server:startTreasureHunting')
AddEventHandler('qb-jobcenter:server:startTreasureHunting', function()
local src = source
local Player = QBCore.Functions.GetPlayer(src)
if Player then
TriggerClientEvent("bit-treasurehunting:open", src)
end
end)
Custom Multijob System
For any custom multijob system:
-- Example integration
function StartTreasureHuntingJob(playerId)
-- Your custom checks here (permissions, requirements, etc.)
-- Start the treasure hunting job
TriggerClientEvent("bit-treasurehunting:open", playerId)
end
-- Call this function from your multijob menu
RegisterServerEvent('yourscript:startJob')
AddEventHandler('yourscript:startJob', function(jobName)
if jobName == "treasurehunting" then
StartTreasureHuntingJob(source)
end
end)
Job Menu Button
ESX esx_jobs Example
Add this to your esx_jobs menu:
{
label = 'Treasure Hunter',
value = 'treasurehunting',
description = 'Hunt for underwater treasures with your team',
icon = 'fa-treasure-chest'
}
QBCore qb-jobselection Example
Add this to your job selection config:
['treasurehunting'] = {
label = 'Treasure Hunter',
description = 'Hunt for underwater treasures with your team',
icon = 'treasure-chest',
onduty = true,
coords = vector3(3858.78, 4459.14, 1.83) -- Optional, for display purposes
}
Custom Job Center Integration
Client-Side Menu
-- Add to your job center menu
{
header = "Treasure Hunter",
txt = "Hunt for underwater treasures with your team. Work together to maximize profits!",
params = {
event = "multijob:client:requestTreasureHunting",
isServer = false
}
}
-- Client event
RegisterNetEvent('multijob:client:requestTreasureHunting')
AddEventHandler('multijob:client:requestTreasureHunting', function()
TriggerServerEvent('multijob:server:startTreasureHunting')
end)
Server-Side Handler
-- Server handler
RegisterServerEvent('multijob:server:startTreasureHunting')
AddEventHandler('multijob:server:startTreasureHunting', function()
local src = source
-- Add your custom checks here
-- Examples: job requirements, cooldowns, permissions, etc.
TriggerClientEvent("bit-treasurehunting:open", src)
end)
Requirements System
Add custom requirements before starting the job:
RegisterServerEvent('jobcenter:server:startTreasureHunting')
AddEventHandler('jobcenter:server:startTreasureHunting', function()
local src = source
local Player = QBCore.Functions.GetPlayer(src) -- or ESX.GetPlayerFromId(src)
-- Check level requirement
local playerLevel = Player.PlayerData.metadata.level or 0
if playerLevel < 5 then
TriggerClientEvent('QBCore:Notify', src, 'You need to be level 5 or higher', 'error')
return
end
-- Check item requirement
local hasItem = Player.Functions.GetItemByName('diving_gear')
if not hasItem then
TriggerClientEvent('QBCore:Notify', src, 'You need diving gear to start this job', 'error')
return
end
-- Check cooldown (example using kvp or database)
-- Your cooldown logic here
-- All checks passed, start the job
TriggerClientEvent("bit-treasurehunting:open", src)
end)
Disabling NPC
If you're using a multijob system and don't want the NPC to spawn:
- Open
config/shared.lua - Comment out or remove the NPC spawn code in the client initialization
- Or set the NPC location to a hidden area
Boss Menu Integration
For servers with boss menu systems:
-- Add to boss menu options
{
header = "Start Treasure Hunting",
txt = "Assign your employees to hunt for treasures",
params = {
event = "bossmenu:server:assignTreasureHunting",
args = {
employee = employeeId
}
}
}
-- Server handler
RegisterServerEvent('bossmenu:server:assignTreasureHunting')
AddEventHandler('bossmenu:server:assignTreasureHunting', function(data)
local employeeId = data.employee
-- Your permission checks here
TriggerClientEvent("bit-treasurehunting:open", employeeId)
end)
Phone/Tablet Integration
For servers using phone or tablet job systems:
-- Phone job app integration
RegisterNUICallback('startTreasureHunting', function(data, cb)
TriggerServerEvent('phone:server:startTreasureHunting')
cb('ok')
end)
-- Server handler
RegisterServerEvent('phone:server:startTreasureHunting')
AddEventHandler('phone:server:startTreasureHunting', function()
local src = source
-- Your checks here
TriggerClientEvent("bit-treasurehunting:open", src)
end)
Discord Bot Integration
For advanced servers with Discord bot integration:
-- Discord command handler
RegisterServerEvent('discord:server:startJobCommand')
AddEventHandler('discord:server:startJobCommand', function(jobType, discordId)
if jobType ~= 'treasurehunting' then return end
-- Match Discord ID to player
local playerId = GetPlayerIdFromDiscord(discordId)
if playerId then
TriggerClientEvent("bit-treasurehunting:open", playerId)
end
end)
Important Notes
- The trigger only opens the job menu; team formation is handled by the script
- Players must be near each other to form teams (proximity check is built-in)
- The script handles all job logic, you only need to trigger the menu
- Consider adding cooldowns to prevent spam
- Add appropriate permission checks for your server
- The NPC can remain as a backup option even with multijob integration
Troubleshooting
Job Menu Doesn't Open
- Verify the event name is exactly:
bit-treasurehunting:open - Ensure you're triggering it client-side:
TriggerClientEvent - Check that the player ID is valid
Team Formation Issues
- Players must be within proximity range
- Ensure the script is started after framework
- Check for conflicting events in other scripts
Permission Problems
- Add your permission checks before triggering the event
- Use your framework's player object to verify requirements
- Log errors for debugging