Untitled


SUBMITTED BY: Guest

DATE: March 4, 2015, 7:13 a.m.

FORMAT: Text only

SIZE: 8.1 kB

HITS: 572

  1. function SelectGamemode()
  2. local chance = math.random(1,3)
  3. local FilePath = "REgmod/GameMode/GameMode.txt"
  4. local Gamemode = file.Read(FilePath)
  5. if Gamemode == "Survivor" then
  6. SetGlobalString( "Game", "Survivor" )
  7. elseif Gamemode == "Vip" then
  8. SetGlobalString( "Game", "VIP" )
  9. elseif Gamemode == "Mercenaries" then
  10. SetGlobalString( "Game", "Mercenaries" )
  11. elseif Gamemode == "Escape" then
  12. SetGlobalString( "Game", "Escape" )
  13. else
  14. if chance == 1 then
  15. SetGlobalString( "Game", "VIP" )
  16. else
  17. SetGlobalString( "Game", "Survivor" )
  18. end
  19. end
  20. end
  21. function ChooseVip()
  22. SetGlobalEntity( "Thevip", "" )
  23. local hunks = team.GetPlayers(TEAM_HUNK)
  24. local VIP = team.GetPlayers(TEAM_HUNK)[math.random(1,#hunks)]
  25. SetGlobalEntity( "Thevip", VIP )
  26. end
  27. function GameCheck()
  28. if GetGlobalString("Mode") == "End" then return end
  29. if GetGlobalString("Game") == "VIP" then
  30. if GetGlobalEntity("Thevip",player.GetByID(1)):Team() != TEAM_HUNK then
  31. EndGame()
  32. return
  33. end
  34. elseif GetGlobalString("Game") == "Survivor" then
  35. if team.NumPlayers(TEAM_HUNK) <= 0 then
  36. EndGame()
  37. return
  38. end
  39. elseif GetGlobalString("Game") == "Escape" then
  40. if team.NumPlayers(TEAM_HUNK) <= 0 then
  41. EndGame()
  42. return
  43. end
  44. elseif GetGlobalString("Game") == "Mercenaries" then
  45. if team.NumPlayers(TEAM_HUNK) <= 0 then
  46. timer.Destroy("Countdowntimer")
  47. EndGame()
  48. return
  49. end
  50. end
  51. end
  52. function GameModeStart()
  53. if GetGlobalString("Game") == "VIP" then
  54. ChooseVip()
  55. SetGlobalInt("countdown", 300 + (table.Count(team.GetPlayers(TEAM_HUNK)) * 60) )
  56. timer.Create("CountdownMercenaries",1,0, function() SetGlobalInt("GameTime", GetGlobalInt("GameTime") + 1) SetGlobalInt("countdown", GetGlobalInt("countdown") - 1) if GetGlobalInt("countdown") <= 0 then timer.Destroy("CountdownMercenaries") EndGame() end end)
  57. elseif GetGlobalString("Game") == "Mercenaries" then
  58. Zombies = {
  59. "snpc_zombie",
  60. "snpc_zombie_crimzon",
  61. "snpc_zombie_crimzon",
  62. "snpc_zombie_crimzon",
  63. "snpc_zombie_crimzon",
  64. "snpc_zombie_crimzon",
  65. "snpc_zombie_crimzon",
  66. "snpc_zombie_crimzon",
  67. }
  68. SetGlobalInt("countdown", 120)
  69. timer.Create("CountdownMercenaries",1,0, function() SetGlobalInt("GameTime", GetGlobalInt("GameTime") + 1) SetGlobalInt("countdown", GetGlobalInt("countdown") - 1) if GetGlobalInt("countdown") <= 0 then timer.Destroy("CountdownMercenaries") EndGame() end end)
  70. elseif GetGlobalString("Game") == "Survivor" then
  71. for k,v in pairs(player.GetAll()) do
  72. local modifier = math.random(30,100)
  73. SetGlobalInt("DeadZombieKillNumber", GetGlobalInt("DeadZombieKillNumber") + modifier)
  74. end
  75. timer.Create("TimeSurvivedTimer",1,0, function() SetGlobalInt("GameTime", GetGlobalInt("GameTime") + 1) for k,v in pairs(team.GetPlayers(TEAM_HUNK)) do v:SetNWInt("Time",v:GetNWInt("Time") + 1 ) if GetGlobalInt("DeadZombies") >= GetGlobalInt("DeadZombieKillNumber") && GetGlobalInt("Game") != "End" then timer.Destroy("TimeSurvivedTimer") EndGame() end end end)
  76. elseif GetGlobalString("Game") == "Escape" then
  77. timer.Create("TimeSurvivedTimer",1,0, function() SetGlobalInt("GameTime", GetGlobalInt("GameTime") + 1) for k,v in pairs(team.GetPlayers(TEAM_HUNK)) do v:SetNWInt("Time",v:GetNWInt("Time") + 1 ) end end)
  78. end
  79. SetGlobalInt("DeadZombies",0)
  80. end
  81. hook.Add("OnNPCKilled","ASD",function()
  82. SetGlobalInt("DeadZombies",GetGlobalInt("DeadZombies") + 1)
  83. end)
  84. function GameModeEnd()
  85. local leader = player.GetAll()[1]
  86. if GetGlobalString("Game") == "VIP" then
  87. if GetGlobalEntity( "Thevip", player.GetByID(1) ):Team() == TEAM_HUNK then
  88. local reward = (GetGlobalInt("DeadZombies") * table.Count(player.GetAll())) / 2
  89. PrintMessage( HUD_PRINTTALK, "The Vip has survived! All players won $"..reward.." . Fine Work!" )
  90. for k,v in pairs(player.GetAll()) do
  91. v:SetNWInt("Money",math.Round(v:GetNWInt("Money")+ reward))
  92. end
  93. else
  94. PrintMessage( HUD_PRINTTALK, "The Vip has died, nobody is rewarded a special bonus." )
  95. end
  96. for k,v in pairs(player.GetAll()) do
  97. if v:Team() == TEAM_HUNK then
  98. v:SetNWBool("Infected", false)
  99. v:SetNWInt("InfectedPercent", 0)
  100. if v.CanEarn then
  101. local money = v:GetNWInt("Time")/60*v:GetNWInt("killcount")
  102. if money >= 3000 then
  103. v:SetNWInt("Money",math.Round(v:GetNWInt("Money")+3000))
  104. v.CanEarn = false
  105. else
  106. v:SetNWInt("Money",math.Round(v:GetNWInt("Money")+(v:GetNWInt("Time")/60)*v:GetNWInt("killcount")))
  107. v.CanEarn = false
  108. end
  109. end
  110. end
  111. end
  112. timer.Destroy("Countdowntimer")
  113. elseif GetGlobalString("Game") == "Mercenaries" then
  114. for k,v in pairs(player.GetAll()) do
  115. if v:GetNWInt("killcount") >= leader:GetNWInt("killcount") && v != leader then
  116. leader = v
  117. end
  118. if v:Team() == TEAM_HUNK then
  119. v:SetNWBool("Infected", false)
  120. v:SetNWInt("InfectedPercent", 0)
  121. if v.CanEarn then
  122. local money = v:GetNWInt("Time")/60*v:GetNWInt("killcount")
  123. if money >= 3000 then
  124. v:SetNWInt("Money",math.Round(v:GetNWInt("Money")+3000))
  125. v.CanEarn = false
  126. else
  127. v:SetNWInt("Money",math.Round(v:GetNWInt("Money")+(v:GetNWInt("Time")/60)*v:GetNWInt("killcount")))
  128. v.CanEarn = false
  129. end
  130. end
  131. end
  132. end
  133. PrintMessage( HUD_PRINTTALK, leader:Nick().." won "..table.Count(player.GetAll())*150 .." for getting the most kills. Well done!" )
  134. leader:SetNWInt("Money", leader:GetNWInt("Money") + (math.Round(table.Count(player.GetAll())*150)))
  135. elseif GetGlobalString("Game") == "Survivor" then
  136. if GetGlobalInt("DeadZombies") >= GetGlobalInt("DeadZombieKillNumber") then
  137. if table.Count(team.GetPlayers(TEAM_HUNK)) > 0 then
  138. local reward = table.Count(team.GetPlayers(TEAM_HUNK)) * 100
  139. PrintMessage( HUD_PRINTTALK, "Surviving players won $"..reward.." for staying alive. Well done!" )
  140. for k,v in pairs(player.GetAll()) do
  141. if v:Team() == TEAM_HUNK then
  142. v:SetNWBool("Infected", false)
  143. v:SetNWInt("InfectedPercent", 0)
  144. if v.CanEarn then
  145. local money = v:GetNWInt("Time")/60*v:GetNWInt("killcount")
  146. if money >= 3000 then
  147. v:SetNWInt("Money",math.Round(v:GetNWInt("Money")+3000))
  148. v.CanEarn = false
  149. else
  150. v:SetNWInt("Money",math.Round(v:GetNWInt("Money")+((v:GetNWInt("Time")/60)*v:GetNWInt("killcount"))+ reward))
  151. v.CanEarn = false
  152. end
  153. end
  154. end
  155. end
  156. end
  157. end
  158. elseif GetGlobalString("Game") == "Escape" then
  159. if table.Count(team.GetPlayers(TEAM_HUNK)) > 0 then
  160. local reward = RewardTable[game.GetMap()]
  161. PrintMessage( HUD_PRINTTALK, "You Have Escaped! Surviving players won $"..reward.." for staying alive. Well done!" )
  162. for k,v in pairs(player.GetAll()) do
  163. if v:Team() == TEAM_HUNK then
  164. v:SetNWBool("Infected", false)
  165. v:SetNWInt("InfectedPercent", 0)
  166. if v.CanEarn then
  167. local money = v:GetNWInt("Time")/60*v:GetNWInt("killcount")
  168. if money >= 3000 then
  169. v:SetNWInt("Money",math.Round(v:GetNWInt("Money")+3000))
  170. v.CanEarn = false
  171. else
  172. v:SetNWInt("Money",math.Round(v:GetNWInt("Money")+((v:GetNWInt("Time")/60)*v:GetNWInt("killcount"))+ reward))
  173. v.CanEarn = false
  174. end
  175. end
  176. end
  177. end
  178. end
  179. end
  180. end

comments powered by Disqus