Advertisement
Guest User

Untitled

a guest
Aug 19th, 2014
260
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. include("bank_shared.lua")
  2. AddCSLuaFile("bank_shared.lua")
  3.  
  4. local BANK_CUSTOM_MoneyTimer = 30 -- This is the time that defines when money is added to the bank. In seconds! [Default = 60]
  5. local BANK_CUSTOM_MoneyOnTime = 500 -- This is the amount of money to be added to the bank every x minutes/seconds. Defined by the setting above. [Default = 500]
  6. local BANK_Custom_Max = 30000 -- The maximum the bank can have. Set to 0 for no limit. [Default = 30000]
  7. local BANK_Custom_AliveTime = 5 -- The amount of MINUTES the player must stay alive before he will receive what the bank has. IN MINUTES! [Default = 5]
  8. local BANK_Custom_CooldownTime = 10 -- The amount of MINUTES the bank is on a cooldown after a robbery! (Doesn't matter if the robbery failed or not) [Default = 20]
  9. local BANK_Custom_RobberyDistance = 500 -- The amount of space the player can move away from the bank entity, before the bank robbery fails. [Default = 500]
  10. local BANK_Custom_PlayerLimit = 2 -- The amount of players there must be on the server before you can rob the bank. [Default = 5]
  11. local BANK_Custom_KillReward = 1000 -- The amount of money a person is rewarded for killing the bank robber. [Default = 1000]
  12. local BANK_Custom_PoliceRequired = 2 -- The amount of police officers there must be before a person can rob the bank. [Default = 3]
  13.  
  14. local RequiredTeams = { -- These are the names of the jobs that counts with the option above, the police required. The amount of players on these teams are calcuated together in the count.
  15. "Civil Protection",
  16. "Civil Protection Chief" -- THE LAST LINE SHOULD NOT HAVE A COMMA AT THE END. BE AWARE OF THIS WHEN EDITING THIS!
  17. }
  18.  
  19. local GovernmentTeams = { -- These are the teams that will receive a notify when a player is trying to rob a bank. Use the actual team name, as shown below.
  20. "Civil Protection",
  21. "Civil Protection Chief",
  22. "Mayor" -- THE LAST LINE SHOULD NOT HAVE A COMMA AT THE END. BE AWARE OF THIS WHEN EDITING THIS!
  23. }
  24.  
  25. local AllowedTeams = { -- These are the teams that are allowed to rob the bank.
  26. "Citizen",
  27. "Gangster",
  28. "Mob boss",
  29. "Gun Dealer",
  30. "Medic",
  31. "Hobo" -- THE LAST LINE SHOULD NOT HAVE A COMMA AT THE END. BE AWARE OF THIS WHEN EDITING THIS!
  32. }
  33.  
  34. function MapInit()
  35. BANK_AddMoneyTimer()
  36. SetGlobalInt( "BANK_VaultAmount", 0 )
  37. BankIsBeingRobbed = false
  38. end
  39. timer.Simple(1, function() MapInit() end)
  40.  
  41. function BANK_PlayerDeath( ply, inflictor, attacker )
  42. if ply.IsRobbingBank then
  43. GAMEMODE:Notify(ply, 1, 5, "You have failed to rob the bank!")
  44. ply:SetDarkRPVar("wanted", false)
  45. attacker:AddMoney(BANK_Custom_KillReward)
  46.  
  47. for k, v in pairs(player.GetAll()) do
  48. if table.HasValue( GovernmentTeams, team.GetName(v:Team()) ) then
  49. GAMEMODE:Notify(v, 1, 7, "The bank robbery has failed!")
  50. end
  51. end
  52.  
  53. umsg.Start("BANK_KillTimer")
  54. umsg.End()
  55.  
  56. BANK_StartCooldown()
  57.  
  58. ply.IsRobbingBank = false
  59. BankIsBeingRobbed = false
  60. end
  61. end
  62. hook.Add("PlayerDeath", "BANK_PlayerDeath", BANK_PlayerDeath)
  63.  
  64. function BANK_RobberyFailCheck()
  65. for k, v in pairs(player.GetAll()) do
  66. if v.IsRobbingBank then
  67. BankRobber = v
  68. break
  69. end
  70. end
  71.  
  72. if IsValid(BankRobber) then
  73. for _, ent in pairs(ents.FindByClass("bank_vault")) do
  74. if ent:IsValid() && BankRobber:GetPos():Distance(ent:GetPos()) >= BANK_Custom_RobberyDistance then
  75. if BankIsBeingRobbed then
  76. GAMEMODE:Notify(BankRobber, 1, 5, "You have moved to far away from the bank vault, and the robbery has failed!")
  77. BankRobber:SetDarkRPVar("wanted", false)
  78.  
  79. for k, v in pairs(player.GetAll()) do
  80. if table.HasValue( GovernmentTeams, team.GetName(v:Team()) ) then
  81. GAMEMODE:Notify(v, 1, 7, "The bank robbery has failed!")
  82. end
  83. end
  84.  
  85. umsg.Start("BANK_KillTimer")
  86. umsg.End()
  87.  
  88. BANK_StartCooldown()
  89.  
  90. BankRobber.IsRobbingBank = false
  91. BankIsBeingRobbed = false
  92. BankRobber = nil
  93. end
  94. end
  95. end
  96. end
  97. end
  98. hook.Add("Tick", "BANK_RobberyFailCheck", BANK_RobberyFailCheck)
  99.  
  100. function BANK_BeginRobbery( ply )
  101. local RequiredTeamsCount = 0
  102. local RequiredPlayersCounted = 0
  103.  
  104. for k, v in pairs(player.GetAll()) do
  105. RequiredPlayersCounted = RequiredPlayersCounted + 1
  106.  
  107. if table.HasValue( RequiredTeams, team.GetName(v:Team()) ) then
  108. RequiredTeamsCount = RequiredTeamsCount + 1
  109. end
  110.  
  111. if RequiredPlayersCounted == #player.GetAll() then
  112. if RequiredTeamsCount < BANK_Custom_PoliceRequired then
  113. GAMEMODE:Notify(ply, 1, 5, "There has to be "..BANK_Custom_PoliceRequired.." police officers before you can rob the bank.")
  114. return
  115. end
  116. end
  117. end
  118.  
  119. if BankCooldown then
  120. GAMEMODE:Notify(ply, 1, 5, "You cannot rob the bank yet!")
  121. return
  122. end
  123. if GetGlobalInt( "BANK_VaultAmount" ) <= 0 then
  124. GAMEMODE:Notify(ply, 1, 5, "There are no money in the bank!")
  125. return
  126. end
  127. if BankIsBeingRobbed then
  128. GAMEMODE:Notify(ply, 1, 5, "The bank is already being robbed!")
  129. return
  130. end
  131. if #player.GetAll() < BANK_Custom_PlayerLimit then
  132. GAMEMODE:Notify(ply, 1, 5, "There must be "..BANK_Custom_PlayerLimit.." players before you can rob the bank.")
  133. return
  134. end
  135. if not table.HasValue( AllowedTeams, team.GetName(ply:Team()) ) then
  136. GAMEMODE:Notify(ply, 1, 5, "You are not allowed to rob the bank with your current team!")
  137. return
  138. end
  139.  
  140.  
  141. for k, v in pairs(player.GetAll()) do
  142. if table.HasValue( GovernmentTeams, team.GetName(v:Team()) ) then
  143. GAMEMODE:Notify(v, 1, 7, "The bank is being robbed!")
  144. end
  145. end
  146.  
  147. BankIsBeingRobbed = true
  148. GAMEMODE:Notify(ply, 1, 5, "You have began a robbery on the bank!")
  149. GAMEMODE:Notify(ply, 1, 10, "You must stay alive for ".. BANK_Custom_AliveTime .." minutes to receive the banks money.")
  150. GAMEMODE:Notify(ply, 1, 13, "If you go to far away from the bank vault, the robbery will also fail!")
  151. ply.IsRobbingBank = true
  152. ply:SetDarkRPVar("wanted", true)
  153. ply:SetDarkRPVar("wantedReason", "Bank Robbery")
  154.  
  155. umsg.Start("BANK_RestartTimer")
  156. umsg.Long(BANK_Custom_AliveTime * 60)
  157. umsg.End()
  158.  
  159. timer.Simple( BANK_Custom_AliveTime * 60, function()
  160. if ply.IsRobbingBank then
  161. GAMEMODE:Notify(ply, 1, 5, "You have succesfully robbed the bank!")
  162. GAMEMODE:Notify(ply, 1, 5, "You have been given $"..util.RobberyFormatNumber(GetGlobalInt( "BANK_VaultAmount" )).." for succesfully robbing the bank.")
  163. for k, v in pairs(player.GetAll()) do
  164. if table.HasValue( GovernmentTeams, team.GetName(v:Team()) ) then
  165. GAMEMODE:Notify(v, 1, 7, "The bank robbery has succeseded and the money is now long gone!")
  166. end
  167. end
  168.  
  169. ply:SetDarkRPVar("wanted", false)
  170. umsg.Start("BANK_KillTimer")
  171. umsg.End()
  172.  
  173. BANK_StartCooldown()
  174.  
  175. ply.IsRobbingBank = false
  176. ply:AddMoney( GetGlobalInt( "BANK_VaultAmount" ) )
  177.  
  178. SetGlobalInt( "BANK_VaultAmount", 0 )
  179. BankIsBeingRobbed = false
  180. end
  181. end)
  182. end
  183.  
  184. function BANK_StartCooldown()
  185. BankCooldown = true
  186. umsg.Start("BANK_RestartCooldown")
  187. umsg.Long(BANK_Custom_CooldownTime * 60)
  188. umsg.End()
  189.  
  190. timer.Simple( BANK_Custom_CooldownTime * 60, function()
  191. BankCooldown = false
  192. umsg.Start("BANK_KillCooldown")
  193. umsg.End()
  194. end)
  195. end
  196.  
  197. function BANK_AddMoneyTimer()
  198. timer.Create("BANK_MoneyTimer", BANK_CUSTOM_MoneyTimer, 0, function()
  199. if not BankIsBeingRobbed then
  200. if BANK_Custom_Max > 0 then
  201. SetGlobalInt( "BANK_VaultAmount", math.Clamp( (GetGlobalInt( "BANK_VaultAmount" ) + BANK_CUSTOM_MoneyOnTime), 0, BANK_Custom_Max) )
  202. else
  203. SetGlobalInt( "BANK_VaultAmount", (GetGlobalInt( "BANK_VaultAmount" ) + BANK_CUSTOM_MoneyOnTime) )
  204. end
  205. end
  206. end)
  207. end
  208.  
  209. function BANK_Disconnect( ply )
  210. if ply.IsRobbingBank then
  211. ply:SetDarkRPVar("wanted", false)
  212.  
  213. for k, v in pairs(player.GetAll()) do
  214. if table.HasValue( GovernmentTeams, team.GetName(v:Team()) ) then
  215. GAMEMODE:Notify(v, 1, 7, "The bank robbery has failed!")
  216. end
  217. end
  218.  
  219. umsg.Start("BANK_KillTimer")
  220. umsg.End()
  221.  
  222. BANK_StartCooldown()
  223.  
  224. ply.IsRobbingBank = false
  225. BankIsBeingRobbed = false
  226. end
  227. end
  228. hook.Add( "PlayerDisconnected", "BANK_Disconnect", BANK_Disconnect )
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement