[Release][WIP] GUI menu for /loadouts

Hi, this script is far from over but i wanted to share it with you,
it loads the “/loadouts help” available jobs with permission level
i use GUI from [Release] GUI Script - v0.8
and also loadout from there [Release] Loadout System

i modded the two to get the game to do what i want and merged them into one github but there are two scripts, allow them two on you autostart
i’m new to lua so it’s not finished and may look like crazy copypasta with a bit of luck in it,
i still don’t know how to prevent the menu from loading when we are in a car, but i will get it soon,

loadout is renamed jobs because, next step is to make use of the blue zone to start a job
how are those called? green in this case [Release] Simple enters/exits system [UPDATED v.0.2],
and maybe to use the mission events from missiontext like in truckerjob
[Release] TruckerJob v0.3 [UPDATE 29th January]
final step will be to display like if it’s online’s cellphone :wink:

if anybody can help me to improve this code, you are welcome

/loadouts help is supposed to display the same than the menu but it seems to be limited at 8 and i will need to implemant left rights keys to do so, still not sure how to do it

i hope you will like it it took me ages to get it work

ho, i forgot, press H to open close
------> create a job column varchar(20) in your user table

7 Likes
JOBS = {}

marker = { r = 0, g = 155, b = 255, a = 200, type = 1 },

local commands = {}
TriggerServerEvent("loadout:joblist")

local ply_locations = {
{entering = {-33.803,-1102.322,25.422}, inside = {-46.56327,-1097.382,25.99875, 120.1953}, outside = {-31.849,-1090.648,25.998,322.345}}, -- A MODIF
}

function giveJob(arg)
	RegisterNetEvent("loadout:doJob")
	TriggerServerEvent("loadout:doJob", arg, source)
	currentjob = arg
	Menu.hidden = not Menu.hidden;
end

RegisterNetEvent("gui:getjobs")
AddEventHandler("gui:getjobs", function(THEJOBS)
	JOBS=THEJOBS
end)

function NameOfMenu()
	ped = GetPlayerPed(-1);
	MenuTitle = "Metier:"
	ClearMenu()
	--for command, _ in pairs(JOBS) do
	for command in pairs(JOBS) do
		local job = JOBS[command]
		Menu.addButton(job,"giveJob",job,ped)
	end
	
end

Citizen.CreateThread(function()
	while true do
		Citizen.Wait(0)
		if IsPlayerWantedLevelGreater(GetPlayerIndex(),0) == false and IsPedInAnyVehicle(LocalPed(), true) == false and  GetDistanceBetweenCoords(b.pos.entering[1],b.pos.entering[2],b.pos.entering[3],GetEntityCoords(LocalPed())) < 5 then
			DrawMarker(1,b.pos.entering[1],b.pos.entering[2],b.pos.entering[3],0,0,0,0,0,0,2.001,2.0001,0.5001,0,155,255,200,0,0,0,0)
			drawTxt('Appuie sur ~g~ENTRER~s~ pour ouvrir le ~b~menu',0,1,0.5,0.8,0.6,255,255,255,255)
		
			NameOfMenu()                     -- Menu to draw
			Menu.hidden = not Menu.hidden    -- Hide/Show the menu

		end
		Menu.renderGUI()     -- Draw menu on each tick if Menu.hidden = false
	end
end)

I didn’t understand your problem.
You want to disable the UI when you are in a car ?
You could set a condition, if the player is in the car then not openGUI

Guys please enter a english translation below if you’re writing in a different language. :corn:

3 Likes

Error with client.lua

https://gyazo.com/9741fc7e8fdaa20c82d260b845b61004

AddEventHandler(“loadout:missiontext”, function(text, time)
ClearPrints()
SetTextEntry_2(“STRING”)
AddTextComponentString(text)
DrawSubtitleTimed(time, 1)
end)

Install missiontext i dont know why ^^

That shouldn’t be causing an error… Can you check that it’s being passed a string (Citizen.Trace(text .. "\n"))

That code is literally taken from MissonText :stuck_out_tongue:

told ya it looks like a crazy copypasta ^^

i think i know why, in the gui, i rebuild the loadout table to only pass what is allowed to wear in the drawmenu, but i pass only loadout.command and not loadout.name, i’ll work on it this afternoon

Check your pull requests on Github :slight_smile:

i’m not very used to github but i’ll check that

if user.permission_level >= (permission or 0) then – Need to have or 0 in case the loadout doesn’t have permission_level defined

that’s why i defined a level for each class, event for civils

i’m trying your code but it’s not working yet for me, gotta move thinks in and out i think ^^

Yes but, not everyone will have the same configuration as you… You need to plan ahead of this and make sure they don’t get errors because of it.

Ah, that’s my bad. I didn’t test my changes fully :blush:

nice to you to help me :wink:

hey i forgot to say that this make use of database, you should create a varchar(atleast20) named job in your user table (see in server.lua, the part name getCurrentJob and setCurrentJob)

good question pal, we are working on it, don’t worry as soon as it’s working we’ll update the github and i’ll change the title to [operational] or something like that

2 Likes

Ok thank you :slight_smile:

1 Like

listen, i’m not at the best place to help anyone for now, but when i’ll be i think i’ll rent servers ready to go and customizable via web interface, this way, not everybody will have to put their hands in code to create their vision of the game, but first i need to understand better the lua code

I’ve updated the pull request, it should fix any errors you were having :smile:

i was doing the same, i pulled for the missiontext error it seems to work but i dont know if i did the pull right with github