Job show on HUD but little problem


#1

Hello I use this script for showing my job on the HUD of GTA it work great when i choose a job in my JOB-CHOOSING-GUI but when i logout/loggin it show a random job on the HUD.(but the job is been save on the db)

My Client.lua:

RegisterNetEvent('jobssystem:updateJob')
AddEventHandler('jobssystem:updateJob', function(nameJob)
  local id = PlayerId()
  local playerName = GetPlayerName

My server.lua:

RegisterServerEvent('jobssystem:jobs')
AddEventHandler('jobssystem:jobs', function(id)
  TriggerEvent('es:getPlayerFromId', source, function(user)
        local nameJob = nameJob(id)
        updatejob(player, id)
        TriggerClientEvent("es_freeroam:notify", source, "CHAR_MP_STRIPCLUB_PR", 1, "Mairie", false, "Votre métier est maintenant : ".. nameJob)
        TriggerClientEvent("jobssystem:updateJob", source, nameJob)
  end)
end)

AddEventHandler('es:playerLoaded', function(source)
  TriggerEvent('es:getPlayerFromId', source, function(user)
      local jobName = nameJob(source)
      TriggerClientEvent("jobssystem:updateJob", source, jobName)
    end)
end)

Any Idea ?


#2

I use job_system and paycheck please i just want to add the hud_job refresh when spawning player not only when Job is choosen.


#3

maybe add a timer to refresh something like

while true do
Citizen.Wait(500)
–CODE HERE –
end


#4

Up please i have exactly the same problem… Thank you


#5

no message

Appuyer sur H pour accéder au menu des métiers

Impossible to choose a job !

I use job_system_fr and paycheck_fr

I modified well client and server lua


#7

If I remove this part, the job hud doesnt show anymore.


#8

Ok, Just copy and past my script on server jobs:

require "resources/essentialmode/lib/MySQL"
MySQL:open("127.0.0.1", "gta5_gamemode_essential", "root", "force1")
 
function updatejob(player, id)
  local job = id
  getJobId(identifier)
  MySQL:executeQuery("UPDATE users SET `job`='@value' WHERE identifier = '@identifier'", {['@value'] = job, ['@identifier'] = player})
  TriggerClientEvent("recolt:updateJobs", source, job)
  TriggerClientEvent("jobssystem:getJobId", source, nameJob)
end
 
function nameJob(id)
  local executed_query = MySQL:executeQuery("SELECT * FROM jobs WHERE job_id = '@namejob'", {['@namejob'] = id})
  local result = MySQL:getResults(executed_query, {'job_name'}, "job_id")
  return result[1].job_name
end
 
RegisterServerEvent('jobssystem:jobs')
AddEventHandler('jobssystem:jobs', function(id)
TriggerEvent('es:getPlayerFromId', source, function(user)
local player = user.identifier
local nameJob = nameJob(id)
updatejob(player, id)
TriggerClientEvent("es_freeroam:notify", source, "CHAR_MP_STRIPCLUB_PR", 1, "Pole Emploie", false, "Vous voila maintenant: ".. nameJob)
TriggerClientEvent("jobssystem:updateJob", source, nameJob)
end)
end)

function getJobId(identifier)
	local executed_query = MySQL:executeQuery("SELECT * FROM users WHERE identifier = '@name'", {['@name'] = identifier})
	local result = MySQL:getResults(executed_query, {'job'})
		return tonumber(result[1].job)
end

AddEventHandler('es:playerLoaded', function(source)
  TriggerEvent('es:getPlayerFromId', source, function(user)
  local jobId = getJobId(user.identifier)
  local jobName = nameJob(jobId)
  TriggerClientEvent("jobssystem:updateJob", source, jobName)
  end)
end)

#9

Work ! THANKS Don’t know why maybe code missing somewhere, a big thanks you!


#10

I know I’m not part of the discussion but I wanted to thanks you for the hard work !


#11

After testing, work but I can’t change job anymore at the job spot.