Advertisement
boynedmaster

Untitled

Aug 28th, 2015
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.59 KB | None | 0 0
  1. c_tKillsD = CreateConVar("ttt_rewards_tkillsd", "20", FCVAR_NOTIFY, "The amount of points a player gets when they kill a Detective as Traitor.")
  2. c_tKillsT = CreateConVar("ttt_rewards_tkillst", "-10", FCVAR_NOTIFY, "The amount of points a player gets when they kill their Traitor friend.")
  3. c_tKillsI = CreateConVar("ttt_rewards_tkillsi", "10", FCVAR_NOTIFY, "The amount of points a player gets when they kill an Innocent as Traitor.")
  4.  
  5. c_iKillsT = CreateConVar("ttt_rewards_ikillst", "10", FCVAR_NOTIFY, "The amount of points a player gets when they kill a Traitor as an Innocent.")
  6. c_iKillsI = CreateConVar("ttt_rewards_ikillsi", "-10", FCVAR_NOTIFY, "The amount of points a player gets when they kill an Innocent as an Innocent.")
  7. c_iKillsD = CreateConVar("ttt_rewards_ikillsd", "-20", FCVAR_NOTIFY, "The amount of points a player gets when they kill a Detective as an Innocent.")
  8.  
  9. c_dKillsT = CreateConVar("ttt_rewards_dkillst", "10", FCVAR_NOTIFY, "The amount of points a player gets when they kill a Traitor as a Detective.")
  10. c_dKillsI = CreateConVar("ttt_rewards_dkillsi", "-10", FCVAR_NOTIFY, "The amount of points a player gets when they kill an Innocent as a Detective.")
  11. c_dKillsD = CreateConVar("ttt_rewards_dkillsd", "-20", FCVAR_NOTIFY, "The amount of points a player gets when they kill a Detective as a Detective.")
  12.  
  13. c_tStaysAlive = CreateConVar("ttt_rewards_tstaysalive", "10", FCVAR_NOTIFY, "The amount of points a player gets when they stay alive the whole round as a Traitor.")
  14. c_iStaysAlive = CreateConVar("ttt_rewards_istaysalive", "10", FCVAR_NOTIFY, "The amount of points a player gets when they stay alive the whole round as an Innocent.")
  15. c_dStaysAlive = CreateConVar("ttt_rewards_dstaysalive", "10", FCVAR_NOTIFY, "The amount of points a player gets when they stay alive the whole round as a Detective.")
  16.  
  17. c_iWinsRound = CreateConVar("ttt_rewards_iwinsround", "10", FCVAR_NOTIFY, "The amount of points a player gets when they win a round as an Innocent.")
  18. c_tWinsRound = CreateConVar("ttt_rewards_twinsround", "10", FCVAR_NOTIFY, "The amount of points a player gets when they win a round as an Traitor.")
  19. c_dWinsRound = CreateConVar("ttt_rewards_dwinsround", "10", FCVAR_NOTIFY, "The amount of points a player gets when they win a round as an Detective.")
  20.  
  21. c_bodyIdentified = CreateConVar("ttt_rewards_bodyidentified", "10", FCVAR_NOTIFY, "The amount of points a player gets when they identify a body as an Innocent or Detective.")
  22.  
  23. c_amountNeededToActivate = CreateConVar("ttt_rewards_playersneeded", "4", FCVAR_NOTIFY, "The amount of players needed at the start of a round for the players to get their points.")
  24.  
  25. local playerM = FindMetaTable("Player")
  26. local pointsCount = false
  27.  
  28. function playerM:TTTRewards_GivePoints(points)
  29. if not pointsCount then return end
  30.  
  31. if(self.points == nil) then
  32. self.points = points
  33. else
  34. self.points = self.points + points
  35. end
  36. end
  37.  
  38. function playerM:TTTRewards_GetPoints()
  39. if self.points == nil then
  40. self.points = 0
  41. end
  42.  
  43. return self.points
  44. end
  45.  
  46. function playerM:TTTRewards_ResetPoints()
  47. self.points = 0
  48. end
  49.  
  50. function PrintToChat(msg)
  51. for i,v in pairs(player.GetAll()) do
  52. v:PrintMessage(HUD_PRINTTALK, msg)
  53. end
  54. end
  55.  
  56. hook.Add("TTTBeginRound", "TTTRewards_TTTBeginFound", function()
  57. pointsCount = (#player.GetAll() >= c_amountNeededToActivate:GetInt())
  58.  
  59. if not pointsCount then
  60. PrintToChat("[TTT REWARDS] You will not get points for this round.")
  61. end
  62. end)
  63.  
  64. hook.Add("TTTBodyFound", "TTTRewards_TTTBodyFound", function(ply)
  65. if(ply:GetRole() == ROLE_INNOCENT or ply:GetRole() == ROLE_TRAITOR) then
  66. ply:TTTRewards_GivePoints(c_bodyIdentified:GetInt())
  67. end
  68. end)
  69.  
  70. hook.Add("PlayerDeath", "TTTRewards_PlayerDeath", function(victim, inflictor, attacker)
  71. if(victim:IsPlayer() and attacker:IsPlayer()) then
  72. if(attacker:GetRole() == ROLE_TRAITOR) then
  73. if(victim:GetRole() == ROLE_INNOCENT) then
  74. attacker:TTTRewards_GivePoints(c_tKillsI:GetInt())
  75. elseif(victim:GetRole() == ROLE_DETECTIVE) then
  76. attacker:TTTRewards_GivePoints(c_tKillsD:GetInt())
  77. elseif(victim:GetRole() == ROLE_TRAITOR) then
  78. attacker:TTTRewards_GivePoints(c_tKillsD:GetInt())
  79. end
  80. elseif(attacker:GetRole() == ROLE_INNOCENT) then
  81. if(victim:GetRole() == ROLE_TRAITOR) then
  82. attacker:TTTRewards_GivePoints(c_iKillsT:GetInt())
  83. elseif(victim:GetRole() == ROLE_INNOCENT) then
  84. attacker:TTTRewards_GivePoints(c_iKillsI:GetInt())
  85. elseif(victim:GetRole() == ROLE_DETECTIVE) then
  86. attacker:TTTRewards_GivePoints(c_iKillsD:GetInt())
  87. end
  88. elseif(attacker:GetRole() == ROLE_DETECTIVE) then
  89. if(victim:GetRole() == ROLE_TRAITOR) then
  90. attacker:TTTRewards_GivePoints(c_dKillsD:GetInt())
  91. elseif(victim:GetRole() == ROLE_INNOCENT) then
  92. attacker:TTTRewards_GivePoints(c_dKillsI:GetInt())
  93. elseif(victim:GetRole() == ROLE_DETECTIVE) then
  94. attacker:TTTRewards_GivePoints(c_dKillsD:GetInt())
  95. end
  96. end
  97. end
  98. end)
  99.  
  100. hook.Add("TTTEndRound", "TTTRewards_RoundEnd", function(result)
  101. if not pointsCount then
  102. PrintToChat("[TTT REWARDS] Nobody got points for this round.")
  103. return
  104. end
  105.  
  106. for i,v in pairs(player.GetAll()) do
  107. points = v:TTTRewards_GetPoints()
  108. v:TTTRewards_ResetPoints()
  109.  
  110. if(v:GetRole() == ROLE_INNOCENT and v:Alive()) then
  111. v:TTTRewards_GivePoints(c_iStaysAlive:GetInt())
  112.  
  113. if(result == WIN_INNOCENT) then
  114. v:TTTRewards_GivePoints(c_iWinsRound:GetInt())
  115. end
  116. elseif(v:GetRole() == ROLE_TRAITOR and v:Alive()) then
  117. v:TTTRewards_GivePoints(c_tStaysAlive:GetInt())
  118.  
  119. if(result == WIN_TRAITOR) then
  120. v:TTTRewards_GivePoints(c_tWinsRound:GetInt())
  121. end
  122. elseif(v:GetRole() == ROLE_DETECTIVE and v:Alive()) then
  123. v:TTTRewards_GivePoints(c_dStaysAlive:GetInt())
  124.  
  125. if(result == WIN_INNOCENT) then
  126. v:TTTRewards_GivePoints(c_dWinsRound:GetInt())
  127. end
  128. end
  129.  
  130. local notification = "notification.AddLegacy('You "
  131.  
  132. if(points > 0) then
  133. notification = notification.."earned "..tostring(points)
  134. else
  135. notification = notification.."lost "..string.sub(tostring(points), 1)
  136. end
  137.  
  138. notification = notification.." points for your actions during this round!', NOTIFY_GENERIC, 5)"
  139.  
  140. print(notification)
  141. v:SendLua(notification)
  142. v:PS_GivePoints(points)
  143. end
  144. end)
  145.  
  146. hook.Add("PlayerDisconnected", "TTTRewards_PlayerDisconnect", function(ply)
  147. ply:PS_Save()
  148. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement