gamemode: Implement Scoreboard support

The game mode will now assign points to teams as well as increment frags and deaths. This paves the way for a proper scoreboard to be added.
This commit is contained in:
Michael Fabian 'Xaymar' Dirks
2017-11-26 12:54:57 +01:00
parent 73a587085c
commit 863f099f31
2 changed files with 16 additions and 0 deletions
@@ -61,6 +61,13 @@ function CLASS:DamageEntity(ent, attacker, dmginfo) end -- Damage Dealt To Entit
function CLASS:Death(inflictor, attacker) function CLASS:Death(inflictor, attacker)
self.Player.Data.Alive = false self.Player.Data.Alive = false
self.Player.Data.AliveTime = CurTime() self.Player.Data.AliveTime = CurTime()
-- Score support
if IsValid(attacker) then
if attacker:IsPlayer() then
attacker:AddFrags(1)
end
self.Player:AddDeaths(1)
end
end end
function CLASS:SilentDeath() function CLASS:SilentDeath()
self.Player.Data.Alive = false self.Player.Data.Alive = false
@@ -86,10 +86,19 @@ function StateSeek:OnLeave(NewState)
if GAMEMODE.Config:DebugLog() then print("StateSeek: OnLeave") end if GAMEMODE.Config:DebugLog() then print("StateSeek: OnLeave") end
if GAMEMODE:GetRoundWinner() == GAMEMODE.Teams.Seekers then if GAMEMODE:GetRoundWinner() == GAMEMODE.Teams.Seekers then
-- Run external Hooks
hook.Run("RoundVictorySeeker") hook.Run("RoundVictorySeeker")
-- Assign Team Points
team.SetScore(GAMEMODE.Teams.Seekers, team.GetScore(GAMEMODE.Teams.Seekers) + 1)
elseif GAMEMODE:GetRoundWinner() == GAMEMODE.Teams.Hiders then elseif GAMEMODE:GetRoundWinner() == GAMEMODE.Teams.Hiders then
-- Run external Hooks
hook.Run("RoundVictoryHider") hook.Run("RoundVictoryHider")
-- Assign Team Points
team.SetScore(GAMEMODE.Teams.Hiders, team.GetScore(GAMEMODE.Teams.Hiders) + 1)
else else
-- Run external Hooks
hook.Run("RoundVictoryDraw") hook.Run("RoundVictoryDraw")
end end
end end