Guest User

Untitled

a guest
Jun 19th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.32 KB | None | 0 0
  1. AddCSLuaFile("cl_init.lua")
  2. AddCSLuaFile("shared.lua")
  3. include("shared.lua")
  4.  
  5. local PrintMore
  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.     self:SetColor(255,215,0,255)
  12.     local phys = self:GetPhysicsObject()
  13.     if phys:IsValid() then phys:Wake() end
  14.     self.sparking = false
  15.     self.damage = 100
  16.     self.IsMoneyPrinter = true
  17.     timer.Simple(0.5, PrintMore, self)
  18.     self:SetNWInt("PrintA",0)
  19. end
  20.  
  21. function ENT:OnTakeDamage(dmg)
  22.     if self.burningup then return end
  23.  
  24.     self.damage = (self.damage or 100) - dmg:GetDamage()
  25.     if self.damage <= 0 then
  26.         local rnd = math.random(1, 100)
  27.         if rnd < 25 then
  28.             self:BurstIntoFlames()
  29.         else
  30.             self:Destruct()
  31.             self:Remove()
  32.         end
  33.     end
  34. end
  35.  
  36. function ENT:Destruct()
  37.     local vPoint = self:GetPos()
  38.     local effectdata = EffectData()
  39.     effectdata:SetStart(vPoint)
  40.     effectdata:SetOrigin(vPoint)
  41.     effectdata:SetScale(1)
  42.     util.Effect("Explosion", effectdata)
  43.     Notify(self.dt.owning_ent, 1, 4, "Your money printer has exploded!")
  44. end
  45.  
  46. function ENT:BurstIntoFlames()
  47.     Notify(self.dt.owning_ent, 1, 4, "Your money printer is overheating!")
  48.     self.burningup = true
  49.     local burntime = math.random(8, 18)
  50.     self:Ignite(burntime, 0)
  51.     timer.Simple(burntime, self.Fireball, self)
  52. end
  53.  
  54. function ENT:Fireball()
  55.     if not self:IsOnFire() then return end
  56.     local dist = math.random(20, 280) -- Explosion radius
  57.     self:Destruct()
  58.     for k, v in pairs(ents.FindInSphere(self:GetPos(), dist)) do
  59.         if not v:IsPlayer() and not v.IsMoneyPrinter then v:Ignite(math.random(5, 22), 0) end
  60.     end
  61.     self:Remove()
  62. end
  63.  
  64. PrintMore = function(ent)
  65.     if ValidEntity(ent) then
  66.         ent.sparking = true
  67.         timer.Simple(0.5, ent.CreateMoneybag, ent)
  68.     end
  69. end
  70.  
  71.  
  72. function ENT:Use(activator)
  73.  
  74. if(activator:IsPlayer()) then
  75. activator:AddMoney(self:GetNWInt("PrintA"));
  76. self:SetNWInt("PrintA",0)
  77. end
  78.  
  79. end
  80.  
  81.  
  82.  
  83.  
  84. function ENT:CreateMoneybag()
  85.     if not ValidEntity(self) then return end
  86.     if self:IsOnFire() then return end
  87.     local MoneyPos = self:GetPos()
  88.     local X = 22
  89.     local Y = 7
  90.     if math.random(1, 2000) == 3 then self:BurstIntoFlames() end
  91.     local amount = self:GetNWInt("PrintA") + Y
  92.     self:SetNWInt("PrintA",amount)
  93.    
  94.     self.sparking = false
  95.     timer.Simple(0.5, PrintMore, self)
  96. end
Add Comment
Please, Sign In to add comment