Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local GOAT = {} --classes are cool
- GOAT.Len = 300 -- Change to 300
- util.AddNetworkString( "scapegoat_round_start" )
- util.AddNetworkString( "scapegoat_death" )
- util.AddNetworkString( "scapegoat_survive" )
- util.AddNetworkString( "scapegoat_found" )
- util.AddNetworkString( "scapegoat_leave" )
- gameevent.Listen( "player_disconnect" )
- hook.Add( "TTTBeginRound", "scapegoat", function()
- local innos = {}
- for _, ply in ipairs( player.GetAll() ) do
- if not ply:IsSpec() and ply:GetRole() == ROLE_INNOCENT then
- innos[#innos+ 1] = ply
- end
- end
- if #innos >= 4 then
- GOAT.ply = innos[math.random( 1, #innos)]
- net.Start( "scapegoat_round_start" )
- net.WriteEntity( GOAT.ply )
- net.Broadcast()
- timer.Create( "scapegoat_survive", GOAT.Len, 1, GOAT.Survive )
- hook.Add( "PlayerDeath", "scapegoat_death", GOAT.Death )
- hook.Add( "player_disconnect", "scapegoat_leave", GOAT.Leave )
- hook.Add( "TTTBodyFound", "scapegoat_found", GOAT.Found )
- end
- end )
- function GOAT.Survive()
- if GOAT.ply:IsActive() then
- net.Start( "scapegoat_survive" )
- net.Broadcast()
- GOAT.RewardSurvive()
- end
- end
- function GOAT.Death( vict )
- if vict == GOAT.ply then
- local targs = {}
- for _, ply in ipairs( player.GetAll() ) do
- if ply:GetRole() == ROLE_TRAITOR or not ply:IsActive() then
- targs[#targs+1] = ply
- end
- end
- net.Start( "scapegoat_death" ) --tell relevent players that the scapegoat has died
- net.Send( targs )
- GOAT.RewardDeath()
- end
- end
- function GOAT.Found( _, vict )
- if vict == GOAT.ply then
- net.Start( "scapegoat_found" )
- net.Broadcast()
- GOAT.Destruct()
- end
- end
- function GOAT.Leave( data )
- if Player( data.userid ) == GOAT.ply then
- net.Start( "scapegoat_leave" )
- net.Broadcast()
- GOAT.Destruct()
- end
- end
- function GOAT.Destruct()
- hook.Remove( "TTTBodyFound", "scapegoat_found" )
- hook.Remove( "player_disconnect", "scapegoat_leave" )
- hook.Remove( "PlayerDeath", "scapegoat_death" )
- timer.Destroy( "scapegoat_survive" )
- GOAT.ply = nil
- end
- function GOAT.RewardDeath()
- for _, ply in ipairs( player.GetAll() ) do
- if ply:GetRole() == ROLE_TRAITOR then
- ply:AddCredits( 1 )
- end
- end
- end
- function GOAT.RewardSurvive()
- for _, ply in ipairs( player.GetAll() ) do
- if ply:GetRole() == ROLE_DETECTIVE then
- ply:AddCredits( 1 )
- ply:SetHealth(ply:Health() + 25)
- end
- end
- GOAT.ply:SetHealth( GOAT.ply:Health() + 25 )
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement