/hire script help

So I am making a custom hire script for police and later ems and fire. What I want to happen is that someone who is high enough rank does /hire and then puts in the player id of who they want to hire. The only problem is, I don’t know how to reference the player id. As in, I don’t know how to make the args a player id. Please help!

RegisterCommand("command", function(source, args, raw) playerId = args[1] end)

And then what do I do? I have

RegisterCommand(“hire”, function(source, args, raw) playerId = args[1]

RegisterCommand(“hire”, function(source, args, raw) playerId = args[1]
if xPlayer.job.name == ‘police’ and xPlayer.job.grade == 5 then
end)

How do I make it so it sets whatever id is in the args to the right job?

Update: I no longer want it to teleport them but rather them be put on a list for police so they can just type /roster to see who’s in prison. The problem is, I don’t know how to convert their id to their name, unless their is a way to use their name from the beginning.

https://esx-org.github.io/
Use the documentation, remember to always use the xPlayer object.

i have been looking through this but I still cant find what I would use.

RegisterCommand("hire", function(source, args, raw) 
	if args[1] and args[2] then
		local playerId = args[1]
		local grade = args[2]
		local xPlayer1  = ESX.GetPlayerFromId(source)
		local xPlayer2  = ESX.GetPlayerFromId(playerId)
		if xPlayer1.job.name == 'police' and xPlayer1.job.grade == 5 then
			if xPlayer2.job.name ~= 'police' then
				if xPlayer2.job.name == 'police' and xPlayer2.job.grade == grade then
					print("already this rank.")
				elseif xPlayer2.job.name ~= 'police' and xPlayer2.job.grade ~= grade xPlayer1.job.grade >= grade then
					xPlayer2.setJob('police', grade)
				else
					print("You cant hire someone to that rank.")
				end
			else
				print("Already a cop.")
			end
		end
	end
end)

edit made it so someone cant set someone to a higher rank then them.

should work didnt test it tho

would also prolly wanna make it so its >= 5 then instead of just being rank 5.

command would look like

/hire id rank

ESX.GetPlayerFromId(playerId) looks like it would work about how would I implement this to the code?

You have a whole example right above your post, in case you didn’t see that.

i didnt

I altered the script a little bit so then they also have to put in a badge number, and it gets saved to the database. But now it keeps telling me it can’t load the __resource.lua aka fxmanifest file whenever I try to log on the server.

fxmanifest

-- Resource Metadata
fx_version 'bodacious'
games { 'gta5' }

author 'Nuggy'
description 'Hire/Fire System for Police'
version '1.0.0'

-- What to run
client_scripts {
    'client.lua',
}
server_scripts {
    'server.lua'
    '@mysql-async/lib/MySQL.lua'
}

client.lua

RegisterNetEvent("output")
AddEventHandler("output", function(argument)
    TriggerEvent("chatMessage", "[Success]", {0,128,0}, "Hired" .. xPlayer2 " to CCSO")
end)

server.lua

RegisterCommand("hire", function(source, args, raw) 
	if args[1] and args[2] and args[3] then
		local playerId = args[1]
        local grade = args[2]
        local number = args[3]
        local job = ccso
		local xPlayer1  = ESX.GetPlayerFromId(source)
		local xPlayer2  = ESX.GetPlayerFromId(playerId)
		if xPlayer1.job.name == 'ccso' and xPlayer1.job.grade >= 5 then
			if xPlayer2.job.name ~= 'ccso' then
				if xPlayer2.job.name == 'ccso' and xPlayer2.job.grade == grade then
					notify("Already this rank")
				elseif xPlayer2.job.name ~= 'ccso' and xPlayer2.job.grade ~= grade xPlayer1.job.grade >= grade then
					xPlayer2.setJob('ccso', grade)
				else
					notify("You cant hire someone to that rank.")
				end
			else
				notify("Already in CCSO")
			end
		end
    end
    MySQL.Async.fetchAll("INSERT INTO badge_numbers (id, number, job_name) VALUES(@xPlayer2, @args[3], @job)",
    {["@xPlayer2"] = xPlayer2, ["@args[3]"] = args[3], ["@job"] = job}
    function(result)
        TriggerClientEvent("@output", source, .. args[3])
    )
end)

remove comma after client script and add it into the server scripts

Ok thanks