-- RRPX Money Printer by philxyz edited by Ninjarudo
AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include("shared.lua")
local printAmount = CreateConVar( "DARKRP_GOLDEN_PRINTER_AMOUNT", 1000, FCVAR_NOTIFY )
local printAmount = CreateConVar( "DARKRP_GOLDEN_PRINTER_AMOUNT", 1000, FCVAR_NOTIFY )
function ENT:Initialize()
self:SetModel("models/props_lab/reciever01a.mdl")
self:SetColor(100,100,0, 255)
self:SetNWInt("Vaulted", 0 )
self:PhysicsInit(SOLID_VPHYSICS)
self:SetMoveType(MOVETYPE_VPHYSICS)
self:SetSolid(SOLID_VPHYSICS)
local phys = self:GetPhysicsObject()
if phys:IsValid() then phys:Wake() end
self.sparking = false
self.damage = 200
self.IsMoneyPrinter = true
timer.Simple(5, self.CreateMoneybag, self)
end
function ENT:Use(activator,caller)
local amount = self:GetNWInt("Vaulted") or 0
if amount > 0 then
Notify(activator, 0, 4, "You have recieved " .. CUR ..( amount or 0 ) .. "!")
if activator != self.dt.owning_ent then
Notify(self.dt.owning_ent, 1, 4, "Your Golden Money Printer has been cleaned out!")
end
activator:AddMoney(amount or 0)
self:SetNWInt("Vaulted", 0)
end
end
function ENT:OnTakeDamage(dmg)
if self.burningup then return end
self.damage = self.damage - dmg:GetDamage()
if self.damage <= 0 then
local rnd = math.random(1, 10)
if rnd < 3 then
self:BurstIntoFlames()
else
self:Destruct()
self:Remove()
end
end
end
function ENT:Destruct()
local vPoint = self:GetPos()
local effectdata = EffectData()
effectdata:SetStart(vPoint)
effectdata:SetOrigin(vPoint)
effectdata:SetScale(1)
util.Effect("Explosion", effectdata)
Notify(self.dt.owning_ent, 1, 4, "Your Golden Money Printer has exploded!")
end
function ENT:Fireball()
if not self:IsOnFire() then return end
local dist = math.random(30, 300) -- Explosion radius
self:Destruct()
for k, v in pairs(ents.FindInSphere(self:GetPos(), dist)) do
if not v:IsPlayer() and not v.IsMoneyPrinter then v:Ignite(math.random(5, 22), 0) end
end
self:Remove()
end
local function PrintMore(ent)
if ValidEntity(ent) then
ent.sparking = true
timer.Simple(1, ent.CreateMoneybag, ent)
end
end
function ENT:CreateMoneybag()
if not ValidEntity(self) then return end
if self:IsOnFire() then return end
-- if math.random(1, 22) == 3 then self:BurstIntoFlames() end
if printAmount == 0 then
printAmount = 1000
end
-- self.dt.amount = self.dt.amount + amount
self:SetNWInt("Vaulted", self:GetNWInt("Vaulted") + printAmount)
self.sparking = false
-- timer.Simple(math.random(100, 150), PrintMore, self)
timer.Simple( 10, PrintMore, self)
end
function ENT:Think()
if not self.sparking then return end
local effectdata = EffectData()
effectdata:SetOrigin(self:GetPos())
effectdata:SetMagnitude(1)
effectdata:SetScale(1)
effectdata:SetRadius(2)
util.Effect("Sparks", effectdata)
end