Setjob for mechanic

How to redo “setjob [id] [grade]” so that by writing “setmechanic [id]” it automatically broadcasts a mechanic with a grade of 0.

Example:
“setmechanic 1” - immediately gets a job as a mechanic with a grade of 0
In the script, the work is called - “mechanik2”

To be reworked:

ESX.RegisterCommand('setjob', {'best', 'superadmin', 'admin', 'mod'}, function(xPlayer, args, showError)
	if xPlayer then
		if ESX.DoesJobExist(args.job, args.grade) then
			args.playerId.setJob(args.job, args.grade)
			exports['huracan_logs']:SendLog(xPlayer.source, "Użyto komendy /setjob " .. args.playerId.source .. " " .. args.job .. " " .. args.grade, "job")
		else
			showError(_U('command_setjob_invalid'))
		end
	else
		args.playerId.setJob(args.job, args.grade)
		showError(_U('command_setjob_invalid'))
	end
end, true, {help = _U('command_setjob'), validate = true, arguments = {
    {name = 'playerId', help = _U('commandgeneric_playerid'), type = 'player'},
    {name = 'job', help = _U('command_setjob_job'), type = 'string'},
    {name = 'grade', help = _U('command_setjob_grade'), type = 'number'}
}})
local setmechanicJob, setmechanicGrade = 'mechanic', 0
ESX.RegisterCommand('setmechanic', {'best', 'superadmin', 'admin', 'mod'}, function(xPlayer, args, showError)
	if xPlayer then
		if ESX.DoesJobExist(setmechanicJob, setmechanicGrade) then
			args.playerId.setJob(args.job, args.grade)
			exports['huracan_logs']:SendLog(xPlayer.source, "Użyto komendy /setjob " .. args.playerId.source .. " " .. setmechanicJob .. " " .. setmechanicGrade , "job")
		else
			showError(_U('command_setjob_invalid'))
		end
	else
		args.playerId.setJob(setmechanicJob, setmechanicGrade )
		showError(_U('command_setjob_invalid'))
	end
end, true, {help = _U('command_setjob'), validate = true, arguments = {
    {name = 'playerId', help = _U('commandgeneric_playerid'), type = 'player'}
}})
1 Like

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