DarkRP - Money Printer cant be destroyed

Hi guys,

I had some trouble before with darkrp and a great guy got it fixed for me, but today I encountered another problem.
I tried to write some money printers but they got little bit bugged etc, so I decided to download a few.
But when I installed them to the server, I tried them out and I found out I couldnt destroy them, ill put the code of the init.lua here.
Thanks for reading this post.


-- RRPX Money Printer by philxyz  edited by Ninjarudo
AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include("shared.lua")
 
function ENT:Initialize()
	self:SetModel("models/props_lab/reciever01b.mdl")
	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: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 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
	local MoneyPos = self:GetPos()
 
	local amount = 100
	if amount == 0 then
		amount = 100
	end
 
	DarkRPCreateMoneyBag(Vector(MoneyPos.x + 15, MoneyPos.y, MoneyPos.z + 15), amount)
	self.sparking = false
	timer.Simple(math.random(100, 150), 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

Well in the removing code, i see you’re calling a function called BurstIntoFlames().

And i don’t see any code that is defining it.

Okay, that could be the problem.
How do I fix it? Do you know?

Create a function called BurstIntoFlames(). Add flames with self:Ignite()

Then self:Remove() once self:Ignite() is finished.

Edit:

Put this before fireball and after destruction:

[lua]
function ENT:BurstIntoFlames()
Notify(self.dt.owning_ent, 0, 4, “Your money printer is overheating!”)
self.burningup = true
local burntime = math.random(8, 18)
self:Ignite(burntime, 0)
timer.Simple(burntime, self.Fireball, self)
end
[/lua]

Taken from DarkRP

Unfortenaly, this didnt work :frowning:
Thanks for helping though!
Btw I think its missing a code that removes the money printer, it explodes but it still works and dont get removed.

That’s very odd. ENT:FireBall() contains self:Remove() which should remove it…

Can an other file cause it not to explode?

What version of DarkRP are you useing? As in the newer version its no longer uses Notify but instead uses GAMEMODE:Notify(). What I think is happening here, your useing a newer version of darkrp and older version of a money printer. When its gets to the line with Notify it just gives out a error and stops so it never gets to the self:Remove().

Ah okay, well I just made my own money printer and they work :smiley:
Thanks for helping though!