[ESX] [Modification] EUP for FiveM with ESX job restriction [Server Sided]

On Aug 2, 2018 @fendretti released a Server Sided EUP for FiveM. :clap: :raised_hands:

I have made an adjustment in eup-ui so that there is an ESX restriction on who can open and use EUP. This is now set for the police. You must be employed as an agent to do /eup.

Below the code and download.

eup-ui.lua

ESX = nil
local PlayerData = {}

Citizen.CreateThread(function()
	while ESX == nil do
		TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
		Citizen.Wait(0)
	end
end)

then you need to add a code above the part where the command is:

RegisterNetEvent("esx:setJob")
AddEventHandler("esx:setJob", function(job)
PlayerData.job = job
end)

Then we will go into the heavy edit underneath the above-added part:

Go and find:

RegisterCommand('eup', function()
	mainMenu:Visible(not mainMenu:Visible())
end, false)

CreateThread(function()
    while true do
        Wait(0)

        menuPool:ProcessMenus()
    end
end)

and replace this with:

RegisterCommand('eup', function()
	if PlayerData.job ~= nil then
		if PlayerData.job.name == 'police' then
			mainMenu:Visible(not mainMenu:Visible())
		else
			ESX.ShowNotification("Sorry, but you aren't a cop, so you can't use this command!")
		end
	end
end, false)

CreateThread(function()
    while true do
        Wait(0)

        menuPool:ProcessMenus()
    end
end)

I’ve attached some screenshots with the correct code and place.
Remember to start EUP after es_extented, essentialmode etc because it needs ESX loaded in first!

For lazy people, here is the download:
eup-ui-for-esx.zip (5.5 KB)

You can download eup-stream (the needed EUP clothing) on the original topic, there’s also an installation-tutorial:

CREDITS:
Creator of EUP: @fendretti
Menu used: NativeLua

1 Like

Wouldn’t it make more sense to just PR this to the original repo?

The amount of code you edited is less than 15 lines, a lot less if you don’t include the ESX required stuff.

Do not re-release resources, instead make a pull request on the orginal resource