Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Workaround for localized texts in DarkRP not loading correctly #3262

Merged
merged 5 commits into from
Jul 25, 2024
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions gamemode/modules/language/sh_language.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ cvars.AddChangeCallback("gmod_language", function(cv, old, new)
selectedLanguage = new
end)

hook.Add("Think", "DarkRPSetLanguage", function()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be covered by the cvars.AddChangeCallback call above? After all, the moment the car goes from empty to set, that function should trigger.

Maybe the empty string check can be moved there instead. That would remove the need of the separate hook.

Copy link
Contributor Author

@jjyao88 jjyao88 Jul 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the cvars.AddChangeCallback above doesn't work at all no matter what language codes I changed from dedicated server-side. This could be the bug directly from Facepunch...
However, I could make it work by starting the server from the main game.

Copy link
Contributor Author

@jjyao88 jjyao88 Jul 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems gmod_language only works for client side by design.

I haven't managed to make cvars.AddChangeCallback("gmod_language", ...) work on server side.

gmodLanguage = GetConVar("gmod_language"):GetString()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that this introduces a new global variable, by the way.

if gmodLanguage != "" then
selectedLanguage = gmodLanguage
end
hook.Remove("Think", "DarkRPSetLanguage")
end)

function DarkRP.addLanguage(name, tbl)
local old = rp_languages[name] or {}
rp_languages[name] = tbl
Expand Down