Hello,
I’ve installed the eup-ui and am streaming eup uniforms to it… I’ve already configured it but just can’t change the ui menu to only work for police,ambulance and mechanic jobs. Using the latest esx jobs.
Appreciate all the help I can get
Hello,
I’ve installed the eup-ui and am streaming eup uniforms to it… I’ve already configured it but just can’t change the ui menu to only work for police,ambulance and mechanic jobs. Using the latest esx jobs.
Appreciate all the help I can get
You could do something like this. This will restrict eup-ui to only police, ambulance, and mechanic. If you wanted separate menu’s for each job, you should make separate configurations, or maybe store an “allowed job” attribute in each outfit config then check for that. Either way, it’s up to you.
-- Add this to server/main.lua for esx_jobs
ESX.RegisterServerCallback('esx_jobs:getJob', function(source, cb)
local xPlayer = ESX.GetPlayerFromId(source)
MySQL.Async.fetchAll('SELECT job FROM users WHERE identifier = @identifier', {
['@identifier'] = xPlayer.identifier
}, function(results)
if results[1] then
cb(results[1].job)
end
end)
end)
-- in eup_ui.lua replace the existing 'eup' command registration with this
RegisterCommand('eup', function()
TriggerServerCallback('esx_jobs:getJob', function(job)
if job == 'police' or job == 'ambulance' or job == 'mechanic' then
mainMenu:Visible(not mainMenu:Visible())
end
end)
end, false)
I haven’t tested this, but this is the general idea.
Hope this helps (and if it does hit that solution button ),
Henry
already got it working, thanks anyways
Citizen.CreateThread(function()
while ESX == nil do
TriggerEvent(‘esx:getSharedObject’, function(obj) ESX = obj end)
Citizen.Wait(0)
end
while ESX.GetPlayerData().job == nil do
Citizen.Wait(10)
end
PlayerData = ESX.GetPlayerData()
end)
RegisterNetEvent(“esx:setJob”)
AddEventHandler(“esx:setJob”, function(job)
PlayerData.job = job
end)
RegisterCommand(‘eup’, function()
if PlayerData.job ~= nil then
if PlayerData.job.name == ‘police’ then
mainMenu:Visible(not mainMenu:Visible())
else
ESX.ShowNotification(‘You are not permitted to use this command’)
end
end
end, false)
RegisterCommand(‘ems’, function()
if PlayerData.job ~= nil then
if PlayerData.job.name == ‘ambulance’ then
mainMenu:Visible(not mainMenu:Visible())
else
ESX.ShowNotification(‘You are not permitted to use this command’)
end
end
end, false)
RegisterCommand(‘fire’, function()
if PlayerData.job ~= nil then
if PlayerData.job.name == ‘fire’ then
mainMenu:Visible(not mainMenu:Visible())
else
ESX.ShowNotification(‘You are not permitted to use this command’)
end
end
end, false)
I have an error in f8 when i want to open the menu with /eup
whats the error?
Hey mate, is it possible, that you send me the code-snippet how you did it?
EUP Command to open the menu as f.e. police
Add this Snippet clientside.
ESX = exports["es_extended"]:getSharedObject()
RegisterNetEvent('esx:setJob')
AddEventHandler('esx:setJob', function(job)
ESX.PlayerData.job = job
end)
RegisterCommand('eup', function()
if not ESX.PlayerData.job then return end
if hasJob() then
mainMenu:Visible(not mainMenu:Visible())
else
ESX.ShowNotification('Du bist nicht berechtigt diesen Befehl auszuführen!')
end
end)
hasJob = function()
local allowedJobs = {'police', 'fib'}
for k, job in pairs(allowedJobs) do
if ESX.PlayerData.job.name == job then
return true
end
end
return false
end
QBCore = exports['qb-core']:GetCoreObject()
RegisterCommand('eup', function()
if not QBCore.Functions.GetPlayerData().job then return end
if hasJob() then
mainMenu:Visible(not mainMenu:Visible())
else
ESX.ShowNotification('Du bist nicht berechtigt diesen Befehl auszuführen!')
end
end)
hasJob = function()
local allowedJobs = {'police', 'fib'}
for k, job in pairs(allowedJobs) do
if QBCore.Functions.GetPlayerData().job.name == job then
return true
end
end
return false
end
Sorry für die späte Frage, aber wo genau muss das rein?
wo muss der code denn genau hin?
and for qbcore?
What about a way to do it with Ace permissions?
Put an ace on each department and those could be added to each user.
ESX = exports["es_extended"]:getSharedObject()
RegisterNetEvent('esx:setJob')
AddEventHandler('esx:setJob', function(job)
ESX.PlayerData.job = job
end)
RegisterCommand('eup', function()
if not ESX.PlayerData.job then return end
if hasJob() then
local ped = PlayerPedId()
if GetEntityModel(ped) == GetHashKey("mp_m_freemode_01") then
mainMenuM:Visible(not mainMenuM:Visible())
elseif GetEntityModel(ped) == GetHashKey("mp_f_freemode_01") then
mainMenuF:Visible(not mainMenuF:Visible())
else
ESX.ShowNotification("Jums ir jāizmanto izveidots tēls!")
end
else
ESX.ShowNotification('Jums nav piekļuves APD Roleplay EUP Menu!')
end
end, false)
hasJob = function()
local allowedJobs = {'police', 'ambulance', 'bcso', 'saspd', 'sahp'}
for k, job in pairs(allowedJobs) do
if ESX.PlayerData.job.name == job then
return true
end
end
return false
end
```*This is how it works for me, my eup menu checks if players ped is Female or Male, This is for ESX*
i actually found a mistake for your qbcore option, you used esx functions for has job and for notification
Hello, I was looking for something like this for QBcore, I do not code and figure this would be a good way to start. How would I implement something like this, I assume I would add this to another script/.lua but where? Thanks for the information.