[Problem] Menu for this job only

Hi, I have a problem I used this code to assign a job to a menu so that its only the job that can open it except my menu opens up more.

Code :

Client. lua

Citizen.CreateThread(function()
    while true do
        Citizen.Wait(0)
        if  IsControlJustPressed(1, 311) and IsPlayerInRangeOfDepanneurMenu() and nameJob == "Dépanneur" then
            DepanneurMenu() -- Menu to draw
            Menu.hidden = not Menu.hidden -- Hide/Show the menu
        end
		
        Menu.renderGUI(options) -- Draw menu on each tick if Menu.hidden = false
        if IsEntityDead(PlayerPedId()) then
            PlayerIsDead()
            -- prevent the death check from overloading the server
            playerdead = true
        end
    end
end)

Thanks You

server.lua

function nameJob(player)
  local executed_query = MySQL:executeQuery("SELECT identifier, job_id, job_name FROM users LEFT JOIN jobs ON jobs.job_id = users.job WHERE users.identifier = '@identifier'", {['@identifier'] = player})
  local result = MySQL:getResults(executed_query, {'job_name'}, "identifier")
  return tostring(result[1].job_name)
end

UP Help me please .

Thanks You

Can you help me

Please

Thanks You

how the client can know whats the name of the job my friend, explain me

I think you just have a problem about programming you should learn and understand algorithms

1 Like

@Lobix300

The client.lua I think detects the job thanks to this line which is false, at least its not walking.

Line code

IsControlJustPressed(1, 311) and IsPlayerInRangeOfDepanneurMenu() and nameJob == "Dépanneur" then

@Reevax
The menu without adding this line works well my code and good.

Thanks You men

u have to script a server file to check the namejob, u cant check it from the client

Yes i use this but dont work

function nameJob(player)
  local executed_query = MySQL:executeQuery("SELECT identifier, job_id, job_name FROM users LEFT JOIN jobs ON jobs.job_id = users.job WHERE users.identifier = '@identifier'", {['@identifier'] = player})
  local result = MySQL:getResults(executed_query, {'job_name'}, "identifier")
  return tostring(result[1].job_name)
end

UP help me, please .

Thanks You

UP, Help me please .

Thanks You .

Can You help me please, Thanks You

Spamming doesnt really help, its rather annoying, be patient and seek additional support on the discord channels.

Ok Sorry but it is important .
For my script

Thanks You