Skip to content

Instantly share code, notes, and snippets.

@Alf21
Last active March 23, 2018 11:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Alf21/326b33823e039cb2700b42c5651d375d to your computer and use it in GitHub Desktop.
Save Alf21/326b33823e039cb2700b42c5651d375d to your computer and use it in GitHub Desktop.
Possible Fix for TTT TOT Addon (untested)
-- Put this into '[SERVER]/garrysmod/lua/autorun/'
-- to toggle the survivalist role, type in chat "!tot_toggle_surv" as admin or in console "tot_toggle_sur 0"
-- add lua file
AddCSLuaFile()
-- add own CONVAR to toggle this survivalist de- / activation
CreateConVar("tot_toggle_sur", 1, {FCVAR_ARCHIVE, FCVAR_NOTIFY}, "Toggle survivalist role in Town of Terror addon")
-- add a command to toggle ingame
concommand.Add("tot_toggle_survivalist", function(ply)
local b = not GetConVar("tot_toggle_sur"):GetBool()
ToggleSur(b)
RunConsoleCommand("tot_toggle_sur", tonumber(b))
local word = "enabled"
if not b then
word = "disabled"
end
ply:ChatPrint("You " .. word .. " the survivalist role!")
end)
-- hook role selection
hook.Add("TTTSelectRoles", "TTTTOTFixSur", function() -- or maybe 'PostGamemodeLoaded'
ToggleSur(GetConVar("tot_toggle_sur"):GetBool())
end)
function ToggleSur(b)
if not b then
RunConsoleCommand("ttt_survivalist_realmin_players", "999")
RunConsoleCommand("ttt_survivalist_min_players", "999")
else
RunConsoleCommand("ttt_survivalist_realmin_players", "2")
RunConsoleCommand("ttt_survivalist_min_players", "2")
end
end
if SERVER then
hook.Add("PlayerSay", "TOTFixChatHook", function(ply, text, public)
if ply:IsAdmin() then
if string.lower(text) == "!tot_toggle_surv" then
ply:ConCommand("tot_toggle_survivalist")
return ""
end
end
end)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment