Advertisement
Guest User

Untitled

a guest
Sep 3rd, 2012
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.96 KB | None | 0 0
  1. The Init.Lua
  2. AddCSLuaFile("cl_init.lua")
  3. AddCSLuaFile("shared.lua")
  4. include("shared.lua")
  5.  
  6. local PrintMore
  7. function ENT:Initialize()
  8.     self:SetModel("models/props_c17/consolebox01a.mdl")
  9.     self:PhysicsInit(SOLID_VPHYSICS)
  10.     self:SetMoveType(MOVETYPE_VPHYSICS)
  11.     self:SetSolid(SOLID_VPHYSICS)
  12.     self:SetColor(200,100,30,255)
  13.     local phys = self:GetPhysicsObject()
  14.     if phys:IsValid() then phys:Wake() end
  15.     self.sparking = false
  16.     self.damage = 100
  17.     self.IsMoneyPrinter = true
  18.     timer.Simple(180, PrintMore, self)
  19.     self:SetNWInt("PrintA",0)
  20. end
  21.  
  22. function ENT:OnTakeDamage(dmg)
  23.     if self.burningup then return end
  24.  
  25.     self.damage = (self.damage or 100) - dmg:GetDamage()
  26.     if self.damage <= 0 then
  27.         local rnd = math.random(1, 10)
  28.         if rnd < 2 then
  29.             self:BurstIntoFlames()
  30.         else
  31.             self:Destruct()
  32.             self:Remove()
  33.         end
  34.     end
  35. end
  36.  
  37. function ENT:Destruct()
  38.     local vPoint = self:GetPos()
  39.     local effectdata = EffectData()
  40.     effectdata:SetStart(vPoint)
  41.     effectdata:SetOrigin(vPoint)
  42.     effectdata:SetScale(1)
  43.     util.Effect("Explosion", effectdata)
  44.     GAMEMODE:Notify(self.dt.owning_ent, 1, 4, "Your money printer has exploded!")
  45. end
  46.  
  47. function ENT:BurstIntoFlames()
  48.     GAMEMODE:Notify(self.dt.owning_ent, 1, 4, "Your money printer is overheating!")
  49.     self.burningup = true
  50.     local burntime = math.random(8, 18)
  51.     self:Ignite(burntime, 0)
  52.     timer.Simple(burntime, self.Fireball, self)
  53. end
  54.  
  55. function ENT:Fireball()
  56.     if not self:IsOnFire() then self.burningup = false return end
  57.     local dist = math.random(20, 280) -- Explosion radius
  58.     self:Destruct()
  59.     for k, v in pairs(ents.FindInSphere(self:GetPos(), dist)) do
  60.         if not v:IsPlayer() and not v:IsWeapon() and v:GetClass() ~= "predicted_viewmodel" and not v.IsMoneyPrinter then
  61.             v:Ignite(math.random(5, 22), 0)
  62.         elseif v:IsPlayer() then
  63.             local distance = v:GetPos():Distance(self:GetPos())
  64.             v:TakeDamage(distance / dist * 100, self, self)
  65.         end
  66.     end
  67.     self:Remove()
  68. end
  69.  
  70.  
  71. PrintMore = function(ent)
  72.     if ValidEntity(ent) then
  73.         ent.sparking = true
  74.         timer.Simple(5, ent.CreateMoneybag, ent)
  75.     end
  76. end
  77.  
  78.  
  79. function ENT:Use(activator)
  80.  
  81. if(activator:IsPlayer()) then
  82. activator:AddMoney(self:GetNWInt("PrintA"));
  83. self:SetNWInt("PrintA",0)
  84. end
  85.  
  86. end
  87.  
  88.  
  89.  
  90.  
  91. function ENT:CreateMoneybag()
  92.     if not ValidEntity(self) then return end
  93.     if self:IsOnFire() then return end
  94.     local MoneyPos = self:GetPos()
  95.     local X = 22
  96.     local Y = 250
  97.     // ---Removed Code ---   if math.random(1, 22) == 3 then self:BurstIntoFlames() end
  98.     //---------- Added code------
  99.     local count1 = 0
  100.     local mytable = ents.FindInSphere(self:GetPos(),100)
  101.     for key,value in ipairs(mytable) do
  102.         if string.find(value:GetClass(),"printer_cooler") then
  103.             count1 = count1 + 1
  104.         end
  105.     end
  106.    
  107.     if(count1 >= 1) then
  108.         if math.random(1,44) == 3 then self:BurstIntoFlames() end
  109.     elseif(count1 == 0) then
  110.         if math.random(1,22) == 3 then self:BurstIntoFlames() end
  111.     end
  112.     //---------------------------
  113.     local amount = self:GetNWInt("PrintA") + Y
  114.     self:SetNWInt("PrintA",amount)
  115.    
  116.     self.sparking = false
  117.     timer.Simple(60, PrintMore, self)
  118. end
  119.  
  120. function ENT:Think()
  121.     //--------------------------Added Code---------------------------------
  122.     local count2 = 0
  123.     local mytable = ents.FindInSphere(self:GetPos(),100)
  124.     for key,value in ipairs(mytable) do
  125.         if string.find(value:GetClass(),"printer_cooler") then
  126.             count2 = count2 + 1
  127.         end
  128.     end
  129.     if( count2 >= 1) then
  130.         self:SetColor(200,100,30,255)
  131.         if count2 = 1 then
  132.             self:SetNWInt("IsCooled",count2)
  133.     elseif( count2 == 0) then
  134.         self:SetColor(200,100,30,255)
  135.     end
  136.    
  137.     //if( count2 >= 1) then
  138.     //  self:SetColor(50,50,255,255)
  139.     //elseif( count2 == 0) then
  140.     //  self:SetColor(255,255,255,255)
  141.     //end
  142. //-----------------------------------------------------------------------
  143.  
  144.     if not self.sparking then return end
  145.  
  146.     local effectdata = EffectData()
  147.     effectdata:SetOrigin(self:GetPos())
  148.     effectdata:SetMagnitude(1)
  149.     effectdata:SetScale(1)
  150.     effectdata:SetRadius(2)
  151.     util.Effect("Sparks", effectdata)
  152. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement