Advertisement
Guest User

Untitled

a guest
Jul 29th, 2014
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 KB | None | 0 0
  1. local GOAT = {} --classes are cool
  2. GOAT.Len = 300 -- Change to 300
  3.  
  4. util.AddNetworkString( "scapegoat_round_start" )
  5. util.AddNetworkString( "scapegoat_death" )
  6. util.AddNetworkString( "scapegoat_survive" )
  7. util.AddNetworkString( "scapegoat_found" )
  8. util.AddNetworkString( "scapegoat_leave" )
  9.  
  10. gameevent.Listen( "player_disconnect" )
  11.  
  12. hook.Add( "TTTBeginRound", "scapegoat", function()
  13.  
  14. local innos = {}
  15. for _, ply in ipairs( player.GetAll() ) do
  16.  
  17. if not ply:IsSpec() and ply:GetRole() == ROLE_INNOCENT then
  18.  
  19. innos[#innos+ 1] = ply
  20.  
  21. end
  22.  
  23. end
  24.  
  25. if #innos >= 4 then
  26.  
  27. GOAT.ply = innos[math.random( 1, #innos)]
  28.  
  29. net.Start( "scapegoat_round_start" )
  30. net.WriteEntity( GOAT.ply )
  31. net.Broadcast()
  32.  
  33. timer.Create( "scapegoat_survive", GOAT.Len, 1, GOAT.Survive )
  34. hook.Add( "PlayerDeath", "scapegoat_death", GOAT.Death )
  35. hook.Add( "player_disconnect", "scapegoat_leave", GOAT.Leave )
  36. hook.Add( "TTTBodyFound", "scapegoat_found", GOAT.Found )
  37.  
  38. end
  39.  
  40. end )
  41.  
  42. function GOAT.Survive()
  43.  
  44. if GOAT.ply:IsActive() then
  45.  
  46. net.Start( "scapegoat_survive" )
  47. net.Broadcast()
  48.  
  49. GOAT.RewardSurvive()
  50.  
  51. end
  52.  
  53. end
  54.  
  55. function GOAT.Death( vict )
  56.  
  57. if vict == GOAT.ply then
  58.  
  59. local targs = {}
  60. for _, ply in ipairs( player.GetAll() ) do
  61.  
  62. if ply:GetRole() == ROLE_TRAITOR or not ply:IsActive() then
  63.  
  64. targs[#targs+1] = ply
  65.  
  66. end
  67.  
  68. end
  69.  
  70. net.Start( "scapegoat_death" ) --tell relevent players that the scapegoat has died
  71. net.Send( targs )
  72.  
  73. GOAT.RewardDeath()
  74.  
  75. end
  76.  
  77. end
  78.  
  79. function GOAT.Found( _, vict )
  80. if vict == GOAT.ply then
  81. net.Start( "scapegoat_found" )
  82. net.Broadcast()
  83.  
  84. GOAT.Destruct()
  85. end
  86.  
  87. end
  88.  
  89. function GOAT.Leave( data )
  90.  
  91. if Player( data.userid ) == GOAT.ply then
  92.  
  93. net.Start( "scapegoat_leave" )
  94. net.Broadcast()
  95. GOAT.Destruct()
  96.  
  97. end
  98.  
  99. end
  100.  
  101. function GOAT.Destruct()
  102.  
  103. hook.Remove( "TTTBodyFound", "scapegoat_found" )
  104. hook.Remove( "player_disconnect", "scapegoat_leave" )
  105. hook.Remove( "PlayerDeath", "scapegoat_death" )
  106. timer.Destroy( "scapegoat_survive" )
  107. GOAT.ply = nil
  108.  
  109. end
  110.  
  111. function GOAT.RewardDeath()
  112.  
  113. for _, ply in ipairs( player.GetAll() ) do
  114.  
  115. if ply:GetRole() == ROLE_TRAITOR then
  116.  
  117. ply:AddCredits( 1 )
  118.  
  119. end
  120.  
  121. end
  122.  
  123. end
  124.  
  125. function GOAT.RewardSurvive()
  126.  
  127. for _, ply in ipairs( player.GetAll() ) do
  128.  
  129. if ply:GetRole() == ROLE_DETECTIVE then
  130.  
  131. ply:AddCredits( 1 )
  132. ply:SetHealth(ply:Health() + 25)
  133.  
  134. end
  135.  
  136. end
  137.  
  138. GOAT.ply:SetHealth( GOAT.ply:Health() + 25 )
  139.  
  140. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement