Money Printer won't spawn..

Hey Facepunch dwellers,
recently I started working with entities, therefor I tried to edit the Money Printer in Dark Roleplay.
It won’t spawn for some reason. I’m still not the best at Lua coding, so it’s probably something really silly :rolleyes:
Thanks in Advance…

I have highlighted the stuff that I’ve changed to it.



AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include("shared.lua")

local PrintMore
function ENT:Initialize()
	self:SetModel("models/props_c17/consolebox01a.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 = 100
	self.IsMoneyPrinter = true
	timer.Simple(27, PrintMore, self)
end

function ENT:OnTakeDamage(dmg)
	if self.burningup then return end

	self.damage = (self.damage or 100) - 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: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

function ENT:Fireball()
	if not self:IsOnFire() then self.burningup = false return end
	local dist = math.random(20, 280) -- 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

***PrintMore = function(ent)
	if ValidEntity(ent) then
		ent.sparking = true
		timer.Simple(3, ent.GiveOwnerMoney, ent)
	end
end

function ENT:GiveOwnerMoney()
	if not ValidEntity(self) then return end
	if self:IsOnFire() then return end
	local owner = self.dt.owning_ent
	
	if math.random(1, 22) == 3 then self:BurstIntoFlames() end
	
	local amount = GetConVarNumber("mprintamount")
	if amount == 0 then
		amount = 450
	end
	
	owner:AddMoney(amount or 0)
	self.sparking = false
	timer.Simple(math.random(100, 350), 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

***function ENT:Use( activator, caller )
    if ( activator():Team() == TEAM_CHIEF or activator():Team() == TEAM_CHIEF ) then
    self:Remove()
	activator:AddMoney(150)
	Notify(activator, 0, 4, "You have destroyed a Money Printer, therefor you have recieved " .. CUR .. (150) .. "!")
    if not ( activator():Team() == TEAM_CHIEF or activator():Team() == TEAM_CHIEF ) then
    Notify(activator, 0, 4, "Nothing Interesting Happened...")
   end
end***


Why dont people read their code over before posting…

[lua]function ENT:Use( activator, caller )
if ( activator():Team() == TEAM_CHIEF or activator():Team() == TEAM_CHIEF ) then
self:Remove()
activator:AddMoney(150)
Notify(activator, 0, 4, "You have destroyed a Money Printer, therefor you have recieved " … CUR … (150) … “!”)
if not ( activator():Team() == TEAM_CHIEF or activator():Team() == TEAM_CHIEF ) then
Notify(activator, 0, 4, “Nothing Interesting Happened…”)
end
end[/lua] has a syntax error in it, your missing a end.


function ENT:Use( activator, caller )
    if ( activator():Team() == TEAM_CHIEF ) then
		self:Remove()
		activator:AddMoney(150)
		Notify(activator, 0, 4, "You have destroyed a Money Printer, therefor you have recieved " .. CUR .. (150) .. "!")
   else
		Notify(activator, 0, 4, "Nothing Interesting Happened...")
   end
end

Don’t know why you were checking the team twice, but yeah, this should be fine.

Thanks guys, but the last function still doesn’t work.
Nothing happens at all whenever I press use on it.



function ENT:Use( activator, caller )
    if ( activator():Team() == TEAM_CHIEF or activator():Team() == TEAM_POLICE ) then
		self:Remove()
		activator:AddMoney(150)
		Notify(activator, 0, 4, "You have destroyed a Money Printer, therefor you have recieved " .. CUR .. (150) .. "!")
   else
		Notify(activator, 0, 4, "Nothing Interesting Happened...")
   end
end


The double team was a mistake, I corrected it in the code above :slight_smile:

Edit:
I tried a varity of codes, this one seems to be working…



function ENT:Use( activator, caller )
    if ( activator:IsPlayer() ) then
		self:Remove()
		activator:AddMoney(150)
		Notify(activator, 0, 4, "You have destroyed a Money Printer, therefor you have recieved " .. CUR .. (150) .. "!")
   else
		Notify(activator, 0, 4, "Nothing Interesting Happened...")
   end
end


I still can’t make it work with teams though

Change


 if ( activator():Team() == TEAM_CHIEF or activator():Team() == TEAM_POLICE ) then

To


 if ( activator:Team() == TEAM_CHIEF or activator:Team() == TEAM_POLICE ) then

No parentheses after activator, didn’t see that the last time.

Thank you a very fucking much,
it worked… :smiley: