[HELP] enable scripts

Hi,

I am looking for a script that is when no whitlisted job like a police ambulance or mechanic is online that people can used a command that is in a script like ai_mechanic but when there is one online that it wil be disabeld.

Let me know if u can help i have olso a reward for it

What framework are you using?
If ESX Legacy, I can help you as I have done exactly this before.
I am at work, so I don’t have the exact code, but it wouldn’t matter anyway, as I use a highly modified version of ESX that I did myself. So here is something I just whipped up to at least show the concept.

client.lua:

RegisterCommand("repair", function(source, args, rawCommand)
	ESX.TriggerServerCallback("checkForWhitelistedEmployees", function(employeesOnDuty)
		if employeesOnDuty then
			ESX.ShowNotification("Call someone, you lazy shit")
		else
			-- Call repair function from ai_mechanic, etc.
		end
	end)
end, false)

server.lua:

ESX.RegisterServerCallback("checkForWhitelistedEmployees", function(source, cb)
	local employeesOnDuty = false
	local xPlayers = ESX.GetPlayers()
	for i = 1, #xPlayers, 1 do
		local xPlayer = ESX.GetPlayerFromId(xPlayers[i])
		if xPlayer.job.name == "mechanic" or xPlayer.job.name == "police" or xPlayer.job.name == "ambulance" then
			employeesOnDuty = true
			break
		end
	end
	cb(employeesOnDuty)
end)

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