43 lines
1.3 KiB
Lua
43 lines
1.3 KiB
Lua
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()
|
||
|