Skip to content

Commit

Permalink
Fix introducing a local, and use a timer instead of Think
Browse files Browse the repository at this point in the history
  • Loading branch information
FPtje committed Jul 25, 2024
1 parent c5e0bd4 commit ae5ccfc
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions gamemode/modules/language/sh_language.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ae5ccfc

Please sign in to comment.