for _, v in pairs(ESX.GetPlayers()) do
local xPlayer = ESX.GetPlayerFromId(v)
if xPlayer.getGroup() == "admin" then
-- xPlayer.name is an admin!
end
end
but I get this error attempt to call a nil value (field ‘GetPlayers’)
If you’re trying to check if the person that’s using this server event is an admin then skip the ESX.GetPlayers() part and just check it like this:
if ESX.GetPlayerFromId(source).group == 'admin' then
You will still need to make sure you’re getting the ESX object properly though, that seems like your issue since it’s not recognizing the GetPlayers() function.
Is this part of the code in a server side file or are you still trying to use it in the client side?
Both the ESX.Players and ESX.GetPlayerFromId functions are server side only. The only thing you should have in your client side file is the menu, the permission check and the drop are both done by the server when the client menu asks to use it.
I was using the permissions check client-side
I don’t know why I thought that would work
anyway I put it in server-side and now it works
Thank you very much @anders
is there a way to let people with higher groups like super admin be able to use it without basically duplicating the code and changing the required group?