Regarding Ace Permissions

Hello, So i was wondering this code is working.

RegisterCommand('admin.onduty', function(source, args, rawCommand)

	if source == 0 or IsPlayerAceAllowed(source, "admin.onduty") then
			admin = not admin
			local str = nil
			if admin then
				ExecuteCommand('ToggleAdminMenu')
				str = "^2 Staff On-Duty"
			else
				ExecuteCommand('UnToggleAdminMenu')
				str = "^1 Off-Duty Staff"
			end
		TriggerEvent('chatMessage', "^1[SYSTEM]:^0 You're Now"..str.."^0.")
		else
			TriggerEvent("chatMessage", "", {255,255,255}, "^1You're Not Authorised To Use This Command!")
		end
	
end, true)

But for some reason i have removed my permissions for this command in my server.cfg but the server still thinks i have permission for the command.

Anyone who can point me into the right direction?

I could be wrong here, as I’m not too familiar with Ace, but I don’t believe you need the true in your RegisterCommand(), and IsPlayerAceAllowed(), as you’re running the same check twice, which is kinda pointless.

As for your issue, have you restarted the server? Because I believe once you execute an Ace permission, unless you deny it, it stays for the rest of the session.

Yeah i have tried restarting the server as well, no success.

I had added end, true) to see if i needed to add that for it to work which had not worked.

I’ve now removed the end, true) since i’m running the if source == 0 or blah blah, i’m kinda confused on why it wouldn’t be fetching the permissions, it’s running the script as if no permissions are needed to run the command

Is this code in a client script or a server script? Because IsPlayerAceAllowed() is a server only native.

it’s in a server sideed script

How were you adding permissions in the first place?

Through my server.cfg.

I have just done

RegisterCommand('admin.onduty', function(source, args, rawCommand)

	if isAdmin then
			admin = not admin
			local str = nil
			if admin then
				ExecuteCommand('ToggleAdminMenu')
				str = "^2 Staff On-Duty"
			else
				ExecuteCommand('UnToggleAdminMenu')
				str = "^1 Off-Duty Staff"
			end
		TriggerEvent('chatMessage', "^1[SYSTEM]:^0 You're Now"..str.."^0.")
		else
			TriggerEvent("chatMessage", "", {255,255,255}, "^1You're Not Authorised To Use This Command!")
		end
	
end)

Now and have it running the checks in client.lua and server.lua.

Seeing if it works now

Right, so the restriction is working now.

My Server.lua

RegisterServerEvent("Roleplay-Menu.getIsAllowed2")
AddEventHandler("Roleplay-Menu.getIsAllowed2", function()
    if IsPlayerAceAllowed(source, "admin") then
        TriggerClientEvent("Roleplay-Menu.returnIsAllowed2", source, true)
    else
        TriggerClientEvent("Roleplay-Menu.returnIsAllowed2", source, false)
    end
end)

My Client.lua

RegisterNetEvent("Roleplay-Menu.returnIsAllowed2")
AddEventHandler("Roleplay-Menu.returnIsAllowed2", function(isAllowed)
    isAdmin = isAllowed2
end)

But still isn’t fetching my permissions?, i renamed it to isAllowed2, because i have a Police menu that is using isAllowed.

Can i not rename isAllowed?

You should be able to…

Try taking a look here (at the Ace section), might not help, but it provides a working example at the bottom that might:

Didn’t work for me, bloody ACE perms, i’m going to try to stick to ACE Perms so i don’t have a thousand scripts for different commands, however thank you anyway sir.

Here is how i fixed my Issue, for those that may come upon this issue.

My server.lua

RegisterServerEvent("Roleplay-Menu.getIsAllowedAdmin")
AddEventHandler("Roleplay-Menu.getIsAllowedAdmin", function()
    if IsPlayerAceAllowed(source, "police") then
        TriggerClientEvent("Roleplay-Menu.returnIsAllowedAdmin", source, true)
    else
        TriggerClientEvent("Roleplay-Menu.returnIsAllowedAdmin", source, false)
    end
end)

my client.lua

-- Administration

Citizen.CreateThread(function()
    TriggerServerEvent("Roleplay-Menu.getIsAllowedAdmin")
end)

RegisterNetEvent("Roleplay-Menu.returnIsAllowedAdmin")
AddEventHandler("Roleplay-Menu.returnIsAllowedAdmin", function(IsAllowedAdmin)
    allowedToUse2 = IsAllowedAdmin
end)

my server.lua

add_ace Ree admin allow

add_principal identifier.discord:244305780478574593 Ree

The Menu that requests the code

-- Admin Menu Stuff

RegisterCommand('admin.onduty', function(source, args, rawCommand)

	if allowedToUse2 then
			admin = not admin
			local str = nil
			if admin then
				ExecuteCommand('ToggleAdminMenu')
				str = "^2 Staff On-Duty"
			else
				ExecuteCommand('UnToggleAdminMenu')
				str = "^1 Off-Duty Staff"
			end
		TriggerEvent('chatMessage', "^1[SYSTEM]:^0 You're Now"..str.."^0.")
		else
			TriggerEvent("chatMessage", "", {255,255,255}, "^1You're Not Authorised To Use This Command!")
		end
	
end)

I guess it’s FiveM for ya. works sometimes then doesn’t.