Jobs database help

My problem is the database saves everything except the job, for example, I create the character and everything and that is well preserved after taking the job. The database does not save the job. The character remains unemployedhttps://ibb.co/ssnCrtm

Hello, this is a friendly reminder because this is your first time creating a topic (or it has been a while since your last topic) in this category.

Please note that most of the support is provided by the Cfx.re community on a voluntary basis. We ask you to be patient; there is no guarantee we have a solution to your problem(s). To avoid unnecessary/duplicate topics, please browse the forums before creating a topic.

To improve your chances of your issue(s) being solved, please provide as much information as possible about the issue(s) you are having. Also —whenever possible— please use the template given to you when creating a topic.

Thanks for keeping these forums tidy!
:mascot:

Look in your server files (for the resource you’re using, e.g server.lua) for the SQL Query that inserts into that table and add the job as a value that’s getting sent.

If I give myself or others a job from the database, it will be saved, but inside the server. If I give them from the job center, do not save in this database that I was referring to.

I hope anyone can help

What this means is look in your job centre resource, look for the server.lua or look for a folder called ‘server’, it should have ‘main.lua’ inside it.
Once inside there you need to look for the line where you’re setting the job (saving the information in the table \ SQL Query).
Once you find it, modify it to add what you need to the table.

Where do I find this line please help me I am very tired looking for a solution

In the script you are using for your job center / setting jobs for players via menu.

look here plz

First you need a method of selecting the information of the character that’s setting the job, if you are using a character selection script there is probably a local value being set there for your characters first and last name.

That information is probably saved client side after setting your character.
You would need to find a way to get the characters first and last name either via client or via server.
If you can access first and last name already, open the client script where you execute the server event and add additional arguments ‘fistname’ and ‘lastname’.

local first = yourgetfirstnameMethod
local last = yourgetlastnameMethod
TriggerServerEvent('esx_joblisting:setJob, job, first, last)

On line 24 from the picture you posted edit:

AddEventHandler('esx_joblisting:setJob, function (source, job, first, last)

Then you edit the script below and paste it after line 34.

local playerids = GetPlayerIdentifiers(source)
MySQL.Async.execute("UPDATE `tablename` SET `job`='${job}' WHERE `firstname`='${first}' AND `lastname`='${last}' AND `nameofsteamidcolumn`='${playerids[0]'}'"

playerids[0] should be Steam ID, if not check between 0 and 5.
That SQL query might not work but I believe that’s how you’d insert variables into your SQL string.

https://dev.mysql.com/doc/refman/8.0/en/sql-data-manipulation-statements.html

Thank you I hope it work

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.