Guest User

Untitled

a guest
Dec 9th, 2016
65
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. AddCSLuaFile("cl_init.lua")
  2. AddCSLuaFile("shared.lua")
  3. include("lua/entities/Custom_Money_Printer/shared.lua")
  4.  
  5.  
  6. function ENT:Initialize()
  7. self:SetModel("models/props_c17/consolebox01a.mdl")
  8. self:PhysicsInit(SOLID_VPHYSICS)
  9. self:SetMoveType(MOVETYPE_VPHYSICS)
  10. self:SetSolid(SOLID_VPHYSICS)
  11. local phys = self:GetPhysicsObject()
  12. if phys:IsValid() then phys:Wake() end
  13. self.sparking = false
  14. self.damage = 200
  15. self.IsMoneyPrinter = true
  16. timer.Simple(5, self.CreateMoneybag, self)
  17. end
  18.  
  19. function ENT:OnTakeDamage(dmg)
  20. if self.burningup then return end
  21.  
  22. self.damage = self.damage - dmg:GetDamage()
  23. if self.damage <= 0 then
  24. local rnd = math.random(1, 10)
  25. if rnd < 3 then
  26. self:BurstIntoFlames()
  27. else
  28. self:Destruct()
  29. self:Remove()
  30. end
  31. end
  32. end
  33.  
  34. function ENT:Destruct()
  35. local vPoint = self:GetPos()
  36. local effectdata = EffectData()
  37. effectdata:SetStart(vPoint)
  38. effectdata:SetOrigin(vPoint)
  39. effectdata:SetScale(1)
  40. util.Effect("Explosion", effectdata)
  41. Notify(self.dt.owning_ent, 1, 4, "Your Golden Money Printer has exploded!")
  42. end
  43.  
  44. function ENT:Fireball()
  45. if not self:IsOnFire() then return end
  46. local dist = math.random(30, 300) -- Explosion radius
  47. self:Destruct()
  48. for k, v in pairs(ents.FindInSphere(self:GetPos(), dist)) do
  49. if not v:IsPlayer() and not v.IsMoneyPrinter then v:Ignite(math.random(5, 22), 0) end
  50. end
  51. self:Remove()
  52. end
  53.  
  54. local function PrintMore(ent)
  55. if ValidEntity(ent) then
  56. ent.sparking = true
  57. timer.Simple(1, ent.CreateMoneybag, ent)
  58. end
  59. end
  60.  
  61. function ENT:CreateMoneybag()
  62. if not ValidEntity(self) then return end
  63. if self:IsOnFire() then return end
  64. local MoneyPos = self:GetPos()
  65.  
  66. local amount = 1000
  67. if amount == 0 then
  68. amount = 1000
  69. end
  70.  
  71. DarkRPCreateMoneyBag(Vector(MoneyPos.x + 15, MoneyPos.y, MoneyPos.z + 15), amount)
  72. self.sparking = false
  73. timer.Simple(math.random(100, 150), PrintMore, self)
  74. end
  75.  
  76. function ENT:Think()
  77. if not self.sparking then return end
  78.  
  79. local effectdata = EffectData()
  80. effectdata:SetOrigin(self:GetPos())
  81. effectdata:SetMagnitude(1)
  82. effectdata:SetScale(1)
  83. effectdata:SetRadius(2)
  84. util.Effect("Sparks", effectdata)
  85. end
RAW Paste Data