Hey, does anyone happen to know how to give a resource permissions so that it can execute crosshair commands on the client?
I have already tried to allow all commands for the resource on the server side (see code). However, the resource is not allowed to edit its own perms. Does anyone have any ideas?
local CrosshairCommands = {
"cl_customCrosshair",
"cl_crosshairdot",
"cl_crosshairsize",
"cl_crosshairstyle",
"cl_crosshairthickness",
"cl_crosshairgap",
"cl_crosshair_drawoutline",
"cl_crosshair_outlinethickness",
"cl_crosshaircolor_r",
"cl_crosshaircolor_g",
"cl_crosshaircolor_b",
"cl_crosshaircolor_a",
"cl_crosshair_dynamic_splitdist",
"cl_crosshair_dynamic_splitalpha_innermod",
"cl_crosshair_dynamic_maxdist_splitratio",
}
-- give resource command perms --
-- add_ace resource.crosshair command.add_ace allow --
-- givve resource permissions to use the crosshair commands --
Citizen.CreateThread(function()
for _, command in pairs(CrosshairCommands) do
ExecuteCommand(('add_ace resource.%s command.%s allow'):format(GetCurrentResourceName(), string.lower(command)))
end
end)
Also tried add_ace resource.crosshair command allow but in the server.cfg, but the resource still had no permissions to execute the crosshair commands on the client-side.
Comment
@nta why are the crosshair commands blocked for resources by default? I don’t think they pose any real “danger” to the client or the server, unlike other commands. Or are all commands locked by default for all resources?
If I make progress with this problem I will update the post and ping a solution if necessary.
Server-Console: (You can see the executed command above the security error message, but I have already assigned the command rights in the server.cfg for the crosshair-resource)
Hmm… I’m actually unsure why this happens to you, as I don’t even have to allow my resource at all, it just works. Are these commands supposed to be ACL protected anyway? And are you sure that you haven’t disabled the crosshairs?
This is really annoying, I just discovered a very funny bug.
The first log part is from the function called in the thread.
The 2nd log part came from the log of the command below (“load_crosshair_values”).
The code part it underneath
MainThrd/ Access denied for command cl_customcrosshair.
MainThrd/ Access denied for command cl_crosshairdot.
MainThrd/ Access denied for command cl_crosshairsize.
MainThrd/ Access denied for command cl_crosshairstyle.
MainThrd/ Access denied for command cl_crosshairthickness.
MainThrd/ Access denied for command cl_crosshairgap.
MainThrd/ Access denied for command cl_crosshair_drawoutline.
MainThrd/ Access denied for command cl_crosshair_outlinethickness.
MainThrd/ Access denied for command cl_crosshaircolor_r.
MainThrd/ Access denied for command cl_crosshaircolor_g.
MainThrd/ Access denied for command cl_crosshaircolor_b.
MainThrd/ Access denied for command cl_crosshair_dynamic_splitdist.
MainThrd/ Access denied for command cl_crosshair_dynamic_splitalpha_innermod.
MainThrd/ Access denied for command cl_crosshair_dynamic_maxdist_splitratio.
MainThrd/
MainThrd/
MainThrd/ cl_customcrosshair true
MainThrd/ cl_crosshairdot false
MainThrd/ cl_crosshairsize 0.0
MainThrd/ cl_crosshairstyle 0
MainThrd/ cl_crosshairthickness 0.0
MainThrd/ cl_crosshairgap 0.0
MainThrd/ cl_crosshair_drawoutline false
MainThrd/ cl_crosshair_outlinethickness 0.0
MainThrd/ cl_crosshaircolor_r 0
MainThrd/ cl_crosshaircolor_g 0
MainThrd/ cl_crosshaircolor_b 0
MainThrd/ cl_crosshaircolor_a 0
MainThrd/ cl_crosshair_dynamic_splitdist 0.0
MainThrd/ cl_crosshair_dynamic_splitalpha_innermod 0.0
MainThrd/ cl_crosshair_dynamic_maxdist_splitratio 0.0
CODE
function sheesh()
for k, v in ipairs(CacheRegistries) do
local cacheVal = Utils.GetValue(v.name)
if cacheVal ~= nil then
-- print(v.commandName .. " " .. tostring(cacheVal))
ExecuteCommand(v.commandName .. " " .. tostring(cacheVal))
end
end
end
Citizen.CreateThread(function()
-- Execute Commands --
sheesh()
end)
RegisterCommand('load_crosshair_values', function()
for k, v in ipairs(CacheRegistries) do
local cacheVal = Utils.GetValue(v.name)
if cacheVal ~= nil then
print(v.commandName .. " " .. tostring(cacheVal))
ExecuteCommand(v.commandName .. " " .. tostring(cacheVal))
end
end
end, false)
UPDATE
I also tried calling the “load_crosshair_values” command in the thread, but that didn’t work either.
@nta, why does the rights system deny the command by code but not when a player calls the command?
I believe only some commands fall into ace permissions scope. For example you wouldn’t want a server dictating profile settings like graphics quality, resolution, etc.
Wow I wasted 2 hours coding a full menu to customize your crosshair and then when I went to test it I realize the resource doesn’t have the permission to change those values. Not to mention the FiveM crosshair has been bugged for like a month now, as the bottom line is not drawn properly, and the fix won’t get merged.
At this point, the real solution is simply to drawn your own crosshair using NUI, but it’s gonna take a long time to implement something like that.