diff --git a/docs/dev_notes.md b/docs/dev_notes.md index 9916ecc1c..455ba3f29 100644 --- a/docs/dev_notes.md +++ b/docs/dev_notes.md @@ -146,7 +146,7 @@ Legend: - [x] check the noLookAlikesAlphabet vs nanoid-dictionary/nolookalikes situation - the nanoid version is 49 chars long, and yet it's referenced as dict51 - [x] healthmonitor: write to logger.fxserver the internal reason as marker -- [!] check compatibility with `sv_enableNetEventReassembly false` +- [x] check compatibility with `sv_enableNetEventReassembly false` - [!] check tx on node 22 - [!] update packages - [!] check cicd stuff on testing repo before release diff --git a/resource/menu/server/sv_webpipe.lua b/resource/menu/server/sv_webpipe.lua index f8d38836f..021903b30 100644 --- a/resource/menu/server/sv_webpipe.lua +++ b/resource/menu/server/sv_webpipe.lua @@ -21,6 +21,12 @@ end local _pipeLastReject local _pipeFastCache = {} +-- Check if we should use latent events +local useLatentEvents = GetConvarBool('sv_enableNetEventReassembly', true); +if not useLatentEvents then + txPrint('^3WARNING: Latent events are disabled. If you have issues using the txAdmin in-game menu, please enable them by setting sv_enableNetEventReassembly to true in your server.cfg.') +end + ---@param src string ---@param callbackId number ---@param statusCode number @@ -35,10 +41,13 @@ local function sendResponse(src, callbackId, statusCode, path, body, headers, ca debugPrint(("^3WebPipe[^5%d^0:^1%d^3]^0 %s<< %s ^4%s%s^0"):format( src, callbackId, resultColor, statusCode, path, cachedStr)) if errorCode then - debugPrint(("^3WebPipe[^5%d^0:^1%d^3]^0 %s<< Headers: %s^0"):format( - src, callbackId, resultColor, json.encode(headers))) + debugPrint(("^3WebPipe[^5%d^0:^1%d^3]^0 %s<< Headers: %s^0"):format(src, callbackId, resultColor, json.encode(headers))) + end + if useLatentEvents then + TriggerLatentClientEvent('txcl:webpipe:resp', src, 125000, callbackId, statusCode, body, headers) + else + TriggerClientEvent('txcl:webpipe:resp', src, callbackId, statusCode, body, headers) end - TriggerLatentClientEvent('txcl:webpipe:resp', src, 125000, callbackId, statusCode, body, headers) end RegisterNetEvent('txsv:webpipe:req', function(callbackId, method, path, headers, body) diff --git a/resource/shared.lua b/resource/shared.lua index 8564f6692..83f0a734c 100644 --- a/resource/shared.lua +++ b/resource/shared.lua @@ -2,10 +2,35 @@ -- Truly global -- ============================================= -function GetConvarBool(cvName) - return (GetConvar(cvName, 'false') == 'true') +function GetConvarBool(cvName, defaultConvarValue) + if not cvName then + return false + elseif defaultConvarValue then + return (GetConvar(cvName, 'true') == 'true') + else + return (GetConvar(cvName, 'false') == 'true') + end end +-- -- Tests for GetConvarBool +-- print("==========================") +-- print('unknown convar') +-- print(GetConvarBool2('xxx', true)) -- true +-- print(GetConvarBool2('xxx', false)) -- false +-- print(GetConvarBool2('xxx')) -- false +-- print('known convar') +-- SetConvar('yyy', 'true') +-- print(GetConvarBool2('yyy', true)) -- true +-- print(GetConvarBool2('yyy', false)) -- true +-- print(GetConvarBool2('yyy')) -- true +-- print('known convar, but with a false value') +-- SetConvar('yyy', 'false') +-- print(GetConvarBool2('yyy', false)) -- false +-- print(GetConvarBool2('yyy', true)) -- false +-- print(GetConvarBool2('yyy')) -- false +-- print("==========================") + + -- Setting game-specific global vars local envName = GetGameName() if envName == 'fxserver' then