Untitled
unknown
lua
3 years ago
1.6 kB
16
Indexable
-- DarkRP has local chat and all sorts of who-sees-what chat modifiers
-- In order for chat hooks to abide by those rules, we have to make sure that
-- the DarkRP chat hook (which is the gamemode function) runs first and last
-- All other chat hooks must be run within DarkRP's function for it to play
-- nicely with its chat rules.
local function ReplaceChatHooks()
local hookTbl = hook.GetTable()
-- give warnings for undeclared chat commands
local warning = fn.Compose{ErrorNoHalt, fn.Curry(string.format, 2)("Chat command \"%s\" is defined but not declared!\n")}
fn.ForEach(warning, DarkRP.getIncompleteChatCommands())
if ULib then
local ulibTbl = hook.GetULibTable()
-- Make sure the PlayerSay hook table exists
hookTbl.PlayerSay = hookTbl.PlayerSay or {}
ulibTbl.PlayerSay = ulibTbl.PlayerSay or {[-2] = {}, [-1] = {}, [0] = {}, [1] = {}, [2] = {}}
for priority, hooks in pairs(ulibTbl.PlayerSay) do
GAMEMODE.OldChatHooks[priority] = GAMEMODE.OldChatHooks[priority] or {}
for hookName, v in pairs(hooks) do
hooks[hookName] = nil
GAMEMODE.OldChatHooks[priority][hookName] = v
end
applyHookTable(hooks, priority)
end
else
-- Make sure the PlayerSay hook table exists
hookTbl.PlayerSay = hookTbl.PlayerSay or {}
for k, v in pairs(hookTbl.PlayerSay) do
GAMEMODE.OldChatHooks[k] = v
hook.Remove("PlayerSay", k)
end
applyHookTable(hookTbl.PlayerSay)
end
end
hook.Add("InitPostEntity", "RemoveChatHooks", ReplaceChatHooks)Editor is loading...