Guest User

Untitled

a guest
Oct 23rd, 2014
174
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( "shared.lua" );
  4.  
  5. -- EDIT DEEZ & NOTHING ELSE --            -- if you want..
  6. local function SetValues( ent )
  7.     ent.printTime = 10; -- Default print time.
  8.     ent.minPrint = 73; -- Minimum print amount.
  9.     ent.maxPrint = 77; -- Maximum print amount.
  10.     ent.upgradedExtra = ent.maxPrint * 0.5; -- The additional income received on upgraded printers.
  11.     ent.printerColor = Color( 200, 100, 100, 255 ); -- The color of the printer prop.
  12.     ent.coolantSystem = true; -- Toggles the coolant system.
  13.     ent.coolantLoss = 0.5; -- The Percentage loss for each print of the coolant is enabled.
  14. end;
  15. ------------------------------
  16.  
  17. local PrintMore;
  18. function ENT:Initialize()
  19.     self:SetModel( "models/props_lab/reciever01a.mdl" );
  20.     self:PhysicsInit( SOLID_VPHYSICS );
  21.     self:SetMoveType( MOVETYPE_VPHYSICS );
  22.     self:SetSolid( SOLID_VPHYSICS );
  23.     local phys = self:GetPhysicsObject();
  24.     phys:Wake();
  25.  
  26.     SetValues( self );
  27.    
  28.     self:SetColor( self.printerColor );
  29.     self.damage = 500;
  30.     self.IsMoneyPrinter = true;
  31.     self:SetNWInt( "Amount", 0 );
  32.     self:SetNWInt( "Health", 500 );
  33.     self:SetNWBool( "Upgraded", false );
  34.     if self.coolantSystem then
  35.         self:SetNWInt( "Coolant", 100 );
  36.         self:SetNWBool( "CoolantToggle", true );
  37.     end;
  38.     timer.Simple( 0.1, function() PrintMore( self ) end );
  39. end;
  40.  
  41. function ENT:OnTakeDamage( dmg )
  42.     self.damage = ( self.damage or 500 ) - math.ceil( dmg:GetDamage() );
  43.     if self.damage < 0 then self.damage = 0 end;
  44.     self:SetNWInt( "Health", self.damage );
  45. end;
  46.  
  47. function ENT:StartTouch( hitEnt )
  48.     if self:GetNWBool( "CoolantToggle" ) then
  49.         if hitEnt.IsCoolant then
  50.             self.Coolant = hitEnt;
  51.             local amount = self:GetNWInt( "Coolant" ) + 100;
  52.             if amount > 100 then amount = 100 end;
  53.             self:SetNWInt( "Coolant", amount );
  54.             self.Coolant:Remove();
  55.         end;
  56.     end;
  57.     if ( hitEnt.IsUpgrade ) then
  58.         if ( !self:GetNWBool( "Upgraded" ) ) then
  59.             self:SetNWBool( "Upgraded", true );
  60.             hitEnt:Remove();
  61.         end;
  62.     end
  63. end
  64.  
  65. function ENT:Use( activator )
  66.     if ( activator:IsPlayer() and self:GetNWInt( "Amount" ) > 0 ) then
  67.         activator:addMoney( self:GetNWInt( "Amount" ) );
  68.         DarkRP.notify( activator, 0, 4, "You have collected $" .. self:GetNWInt( "Amount" ) .. " from a " .. self.PrintName );
  69.         self:SetNWInt( "Amount", 0 );
  70.     end;
  71. end;
  72.  
  73. function ENT:Destruct()
  74.     local vPoint = self:GetPos();
  75.     local effectdata = EffectData();
  76.     effectdata:SetStart( vPoint );
  77.     effectdata:SetOrigin( vPoint );
  78.     effectdata:SetScale( 1 );
  79.     util.Effect( "Explosion", effectdata );
  80.     DarkRP.notify( self:Getowning_ent(), 1, 4, "Your " .. self.PrintName .. " has exploded!" );
  81. end;
  82.  
  83. function ENT:BurstIntoFlames()
  84.     DarkRP.notify( self:Getowning_ent(), 0, 4, "Your " .. self.PrintName .. " has burst into flames!" );
  85.     self.burningup = true;
  86.     local burntime = math.random( 8, 18 );
  87.     self:Ignite( burntime, 0 );
  88.     timer.Simple( burntime, function() self:Fireball() end );
  89. end;
  90.  
  91. function ENT:Fireball()
  92.     if not self:IsOnFire() then self.burningup = false return end;
  93.     local dist = math.random( 20, 280 ); -- Explosion radius
  94.     self:Destruct();
  95.     for k, v in pairs( ents.FindInSphere( self:GetPos(), dist ) ) do
  96.         if not v:IsPlayer() and not v:IsWeapon() and v:GetClass() ~= "predicted_viewmodel" and not v.IsMoneyPrinter then
  97.             v:Ignite( math.random( 5, 22 ), 0 );
  98.         elseif v:IsPlayer() then
  99.             local distance = v:GetPos():Distance( self:GetPos() );
  100.             v:TakeDamage( distance / dist * 100, self, self );
  101.         end;
  102.     end;
  103.     self:Remove();
  104. end;
  105.  
  106. PrintMore = function( ent )
  107.     if not IsValid( ent ) then return end;
  108.     if ent.damage <= 0 then return end;
  109.    
  110.     timer.Simple( ent.printTime / 2, function()
  111.         if not IsValid( ent ) then return end;
  112.         ent:CreateMoney();
  113.     end );
  114. end;
  115.  
  116. function ENT:CreateMoney()
  117.     if not IsValid( self ) then return end;
  118.     if self:IsOnFire() then return end;
  119.    
  120.     if self:GetNWBool( "CoolantToggle" ) then
  121.         local coolantLeft = self:GetNWInt( "Coolant" ) - self.coolantLoss;
  122.         self:SetNWInt( "Coolant", coolantLeft );
  123.         if coolantLeft <= 0 then
  124.             self:SetNWInt( "Coolant", 0 );
  125.             self.damage = self.damage - 5;
  126.             self:SetNWInt( "Health", self.damage );
  127.             self.sparking = true;
  128.             timer.Simple( 0.3, function() self.sparking = false end );
  129.         end;
  130.     end;
  131.    
  132.     local PrintAmount = math.random( self.minPrint, self.maxPrint );
  133.     if self:GetNWBool( "Upgraded" ) then
  134.         PrintAmount = PrintAmount + math.ceil( self.upgradedExtra );
  135.     end;
  136.    
  137.     local TotalAmount = self:GetNWInt( "Amount" ) + PrintAmount;
  138.     self:SetNWInt( "Amount", TotalAmount );
  139.    
  140.     if self.damage < 500 then
  141.         self.damage = self.damage + 1;
  142.         self:SetNWInt( "Health", self.damage );
  143.     end;
  144.    
  145.     timer.Simple( self.printTime / 2, function() PrintMore( self ) end );
  146. end
  147.  
  148. function ENT:Think()
  149.     if self.damage then
  150.         if ( self.damage <= 0 ) then
  151.             if not self:IsOnFire() then
  152.                 self.damage = 0;
  153.                 self:SetNWInt( "Health", 0 );
  154.                
  155.                 self:BurstIntoFlames();
  156.             end;
  157.         end;
  158.     end;
  159.  
  160.     if self:WaterLevel() > 0 then
  161.         self:Destruct();
  162.         self:Remove();
  163.         return;
  164.     end;
  165.  
  166.     if not self.sparking then return end;
  167.  
  168.     local effectdata = EffectData();
  169.     effectdata:SetOrigin( self:GetPos() );
  170.     effectdata:SetMagnitude( 1 );
  171.     effectdata:SetScale( 1 );
  172.     effectdata:SetRadius( 2 );
  173.     util.Effect( "Sparks", effectdata );
  174. end;
  175.  
  176. function ENT:OnRemove()
  177.     if self.sound then
  178.         self.sound:Stop();
  179.     end;
  180. end;
RAW Paste Data