From b5190f98e9e820cdd5289052c705d83142769e43 Mon Sep 17 00:00:00 2001 From: Linden <65407488+thelindat@users.noreply.github.com> Date: Mon, 7 Nov 2022 16:58:56 +1100 Subject: [PATCH] refactor(src/config): poll convars --- src/config/index.ts | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/config/index.ts b/src/config/index.ts index dc2656b..a08c4da 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -1,16 +1,26 @@ export const resourceName = GetCurrentResourceName(); -export const mysql_ui = GetConvar('mysql_ui', 'false') === 'true'; -export const mysql_slow_query_warning = GetConvarInt('mysql_slow_query_warning', 200); export const mysql_connection_string = GetConvar('mysql_connection_string', ''); +export let mysql_ui = GetConvar('mysql_ui', 'false') === 'true'; +export let mysql_slow_query_warning = GetConvarInt('mysql_slow_query_warning', 200); export let mysql_debug: boolean | string[]; -try { - const debug = GetConvar('mysql_debug', 'false'); - mysql_debug = debug === 'false' ? false : JSON.parse(debug); -} catch (e) { - mysql_debug = true; +function setDebug() { + try { + const debug = GetConvar('mysql_debug', 'false'); + mysql_debug = debug === 'false' ? false : JSON.parse(debug); + } catch (e) { + mysql_debug = true; + } } +setDebug(); + +setInterval(() => { + setDebug(); + mysql_ui = GetConvar('mysql_ui', 'false') === 'true'; + mysql_slow_query_warning = GetConvarInt('mysql_slow_query_warning', 200); +}, 1000); + export const mysql_transaction_isolation_level = (() => { const query = 'SET TRANSACTION ISOLATION LEVEL'; switch (GetConvarInt('mysql_transaction_isolation_level', 2)) {