Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Reset player states when the round ends and begins
- hook.Add("TTTEndRound", "weapon_ttt_deputy", function(result)
- for k, v in pairs(player.GetAll()) do
- v.DeputyFakeDetective = false
- v.DeputyActive = false
- end
- end)
- hook.Add("TTTBeginRound", "weapon_ttt_deputy", function()
- for k, v in pairs(player.GetAll()) do
- v.DeputyFakeDetective = false
- v.DeputyActive = false
- end
- end)
- -- Actually override the functions
- hook.Add("InitPostEntity", "TTTDeputyInitPostEntity", function()
- local Player = FindMetaTable("Player")
- if Player then
- if !isfunction(Player.GetDetectiveOld) then
- Player.GetDetectiveOld = Player.GetDetective
- end
- function Player:GetDetective()
- if self:GetRole() == ROLE_DETECTIVE then return self:GetDetectiveOld() end
- return self.DeputyActive && self.DeputyFakeDetective
- end
- Player.IsDetective = Player.GetDetective
- end
- end)
- -- For testing
- concommand.Add("ttt_deputy_forceall", function(ply, cmd, args)
- for k, v in pairs(player.GetAll()) do
- v.DeputyActive = true
- if v:IsActiveTraitor() then
- v.DeputyFakeDetective = true
- end
- end
- end)
- concommand.Add("ttt_deputy_resetall", function(ply, cmd, args)
- for k, v in pairs(player.GetAll()) do
- v.DeputyActive = false
- if v:IsActiveTraitor() then
- v.DeputyFakeDetective = false
- end
- end
- end)
- --- Test 1 (Bot03 is Traitor):
- -- ttt_deputy_forceall
- -- lua_run for k, v in pairs(player.GetAll()) do print(v:Nick(), v:GetDetective()) end
- -- Bot01 false
- -- Bot02 false
- -- Bot03 true -- This is correct! But the HUD isn't updating!
- -- Doctor Jew false
- --- Test 2 (Bot03 is Traitor):
- -- ttt_deputy_forceall
- -- lua_run for k, v in pairs(player.GetAll()) do print(v:Nick(), v:IsDetective()) end
- -- Bot01 false
- -- Bot02 false
- -- Bot03 true -- This is correct! But the HUD isn't updating!
- -- Doctor Jew false
Add Comment
Please, Sign In to add comment