diff --git a/README.md b/README.md index 9c7273a..aa80b24 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,7 @@ All config variables are client-side and only computed on a client's machine. property | type | description -- | -- | -- `CommandAccessHandling` | function | handling used to verify if the client should be able to enable AB3 +`CommandAccessAce` | string\|nil | Use ACL to determine whether the client should be able to enable AB3 `CommandBinding ` | string\|nil | keybind to use for on/off command. can be nil for no keybind `ThirdPersonMode` | boolean | whether the axon overlay is also visible in third person diff --git a/client.lua b/client.lua index 89f3c62..a37ea5a 100644 --- a/client.lua +++ b/client.lua @@ -9,6 +9,27 @@ if GetConvar('tfnrp_framework_init', 'false') == 'true' then Config.CommandAccessHandling = function () return exports.framework:GetLocalClientDuty() > 0 end + +elseif Config.CommandAccessAce then + Config.CommandAccessAce = nil + local hasAce = false + local pass = false + local commandAccessHandling = Config.CommandAccessHandling + + RegisterNetEvent('AB3:ServerHasAce', function (bool) + hasAce = bool + end) + TriggerServerEvent('AB3:ClientHasAce') + + Config.CommandAccessHandling = function () + if not pass then + pass = true + Citizen.SetTimeout(2.5e3, function () pass = false end) + TriggerServerEvent('AB3:ClientHasAce') + end + + return hasAce and commandAccessHandling() + end end ---------------------------------------------------------- diff --git a/config.lua b/config.lua index 00ecc3b..9dbe058 100644 --- a/config.lua +++ b/config.lua @@ -2,12 +2,16 @@ --- @type table Config = { --- Handling used to verify if the client should be able to enable AB3. - --- @type function - --- @return boolean + --- @type function - a client-side implementation of custom framework logic, etc + --- @return boolean - whether client should have access CommandAccessHandling = function () -- Add custom framework access handling here. return true end, + --- Use ACL to determine whether the client should be able to enable AB3. + --- ACL will be checked befored CommandAccessHandling, if it exists. + --- @type string|nil - string representation of the "root" ace + CommandAccessAce = 'ab3', --- Keybind to use for on/off command. can be nil for no keybind. --- @type string CommandBinding = 'u', diff --git a/fxmanifest.lua b/fxmanifest.lua index 2d94b89..9156316 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -5,10 +5,8 @@ repository 'https://github.com/TFNRP/axonbody3' version '0.2.1' author 'Reece Stokes ' -client_script { - 'config.lua', - 'client.lua', -} +shared_script 'config.lua' +client_script 'client.lua' server_script 'server.lua' ui_page 'static/index.html' file 'static/*' \ No newline at end of file diff --git a/server.lua b/server.lua index 1eaa74f..2e1ab87 100644 --- a/server.lua +++ b/server.lua @@ -1,3 +1,12 @@ RegisterNetEvent('AB3:ClientBeep', function() TriggerClientEvent('AB3:ServerBeep', -1, source) -end) \ No newline at end of file +end) + +if Config.CommandAccessAce then + local ace = Config.CommandAccessAce + RegisterNetEvent('AB3:ClientHasAce', function() + TriggerClientEvent('AB3:ServerHasAce', source, IsPlayerAceAllowed(source, ace)) + end) +end + +Config = nil