From 4cee3c55c9bb35f863910fcc3054e96c289062ac Mon Sep 17 00:00:00 2001 From: Falco Peijnenburg Date: Thu, 25 Jul 2024 14:10:31 +0200 Subject: [PATCH] Fix introducing a local, and use a timer instead of Think --- gamemode/modules/language/sh_language.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gamemode/modules/language/sh_language.lua b/gamemode/modules/language/sh_language.lua index 6cbfdab77..b0097cae5 100644 --- a/gamemode/modules/language/sh_language.lua +++ b/gamemode/modules/language/sh_language.lua @@ -5,12 +5,13 @@ cvars.AddChangeCallback("gmod_language", function(cv, old, new) selectedLanguage = new end) -hook.Add("Think", "DarkRPSetLanguage", function() - gmodLanguage = GetConVar("gmod_language"):GetString() - if gmodLanguage != "" then +-- Some server owners experience that the language is not set correctly on +-- startup. This provides a failsafe in case that happens. +timer.Simple(0, function() + local gmodLanguage = GetConVar("gmod_language"):GetString() + if gmodLanguage ~= "" and selectedLanguage ~= gmodLanguage then selectedLanguage = gmodLanguage end - hook.Remove("Think", "DarkRPSetLanguage") end) function DarkRP.addLanguage(name, tbl)