Files
VnUtest/garrysmod/lua/autorun/server/sv_hostname_force.lua
2026-03-31 11:51:03 +03:00

43 lines
1.3 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
local ForceHostname = "FT 4.0 | ТЕСТ СЕРВЕР"
local function EnforceHostname()
local hostnameCVar = GetConVar("hostname")
if not hostnameCVar then return end
local current = hostnameCVar:GetString()
if current ~= ForceHostname then
print("[HOSTNAME FORCE] Detected name mismatch!")
print(" Current: '" .. current .. "'")
print(" Target: '" .. ForceHostname .. "'")
-- Try to set it directly and via command
hostnameCVar:SetString(ForceHostname)
RunConsoleCommand("hostname", ForceHostname)
end
end
-- Monitor for external changes
cvars.AddChangeCallback("hostname", function(convar, old, new)
if new ~= ForceHostname then
print("[HOSTNAME FORCE] WRAPPER: Hostname was changed by an external source!")
print(" From: '" .. old .. "'")
print(" To: '" .. new .. "'")
timer.Simple(0.1, EnforceHostname)
end
end, "ForceHostnameTracker")
hook.Add("Initialize", "ForceHostnameInit", function()
print("[HOSTNAME FORCE] Script initialized.")
EnforceHostname()
end)
-- Keep it forced every 5 seconds (Think is overkill if we use callbacks)
timer.Create("ForceHostnameTimer", 5, 0, function()
EnforceHostname()
end)
-- Run once on load
EnforceHostname()