My money printers are un-spawnable after I destroy them.
0 replies, posted
So, we aren't sure if this has been an issue forever, because we recently discovered it. You can spawn money printers in fine, but after you destroy them, It still says that the limit has been reached. I don't think this is a problem with our code, because the default money printer that comes with DarkRP doesn't work either. Please help me figure out this issue. Thanks in advance. Here is the money printer code:
[B]cl_init.lua[/B]
[code]include("shared.lua")
function ENT:Initialize()
end
function ENT:Draw()
self:DrawModel()
local Pos = self:GetPos()
local Ang = self:GetAngles()
local owner = self:Getowning_ent()
owner = (IsValid(owner) and owner:Nick()) or "Disconnected"
local MoneyInP = "$" ..self:GetNWInt("MoneyInP")
surface.SetFont("HUDNumber5")
local TextWidth = surface.GetTextSize("Radioactive Money Printer")
local TextWidth2 = surface.GetTextSize(owner)
local TextWidth3 = surface.GetTextSize(MoneyInP)
Ang:RotateAroundAxis(Ang:Up(), 90)
cam.Start3D2D(Pos + Ang:Up() * 11.5, Ang, 0.11)
draw.WordBox(2, -TextWidth*0.5, -30, "Radioactive Printer", "HUDNumber5", Color(140, 0, 24, 100), Color(255,255,255,255))
draw.WordBox(2, -TextWidth2*0.5, 18, owner, "HUDNumber5", Color(140, 0, 0, 100), Color(255,255,255,255))
draw.WordBox(2, -TextWidth3*0.5, 104, MoneyInP, "HUDNumber5", Color(0, 0, 0, 100), Color(0,255,0,255))
cam.End3D2D()
end
function ENT:Think()
end [/code]
[B]init.lua[/B]
[code]-- RRPX Money Printer reworked for DarkRP by philxyz
AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include("shared.lua")
ENT.SeizeReward = 750
local PrintMore
function ENT:Initialize()
self:SetModel("models/props_c17/consolebox01a.mdl")
self:PhysicsInit(SOLID_VPHYSICS)
self:SetMoveType(MOVETYPE_VPHYSICS)
self:SetSolid(SOLID_VPHYSICS)
self:SetColor(Color(186,255,0,0))
local phys = self:GetPhysicsObject()
phys:Wake()
self.sparking = false
self.damage = 250
self.IsMoneyPrinter = true
timer.Simple(1, function() PrintMore(self) end)
self:SetNWInt("MoneyInP",0)
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)
end
function ENT:BurstIntoFlames()
self.burningup = true
local burntime = math.random(8, 18)
self:Ignite(burntime, 0)
timer.Simple(burntime, function() self:Fireball() end)
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:IsWeapon() and v:GetClass() ~= "predicted_viewmodel" and not v.IsMoneyPrinter then
v:Ignite(math.random(5, 22), 0)
elseif v:IsPlayer() then
local distance = v:GetPos():Distance(self:GetPos())
v:TakeDamage(distance / dist * 100, self, self)
end
end
self:Remove()
end
PrintMore = function(ent)
if not IsValid(ent) then return end
ent.sparking = true
timer.Simple(3, function()
if not IsValid(ent) then return end
ent:CreateMoneybag()
end)
end
function ENT:Use(activator)
if(activator:IsPlayer()) and self:GetNWInt("MoneyInP") >= 1 then
activator:AddMoney(self:GetNWInt("MoneyInP"));
GAMEMODE:Notify(activator, 1, 4, "You have collected $"..self:GetNWInt("MoneyInP").." From a Radioactive Printer")
self:SetNWInt("MoneyInP",0)
end
end
function ENT:CreateMoneybag()
if not IsValid(self) or self:IsOnFire() then return end
local MoneyPos = self:GetPos()
if math.random(1000, 6000) == 3 then self:BurstIntoFlames() end
local PrintMoney = 4
local amount = self:GetNWInt("MoneyInP") + PrintMoney
self:SetNWInt("MoneyInP",amount)
--DarkRPCreateMoneyBag(Vector(MoneyPos.x + 15, MoneyPos.y, MoneyPos.z + 15), PrintMoney)
self.sparking = false
timer.Simple(1, function() PrintMore(self) end)
end
function ENT:Think()
if self:WaterLevel() > 0 then
self:Destruct()
self:Remove()
return
end
if not self.sparking then return end
local effectdata = EffectData()
effectdata:SetOrigin(self:GetPos())
effectdata:SetMagnitude(1)
effectdata:SetScale(1)
effectdata:SetRadius(2)
end [/code]
[B]shared.lua[/B]
[code]ENT.Type = "anim"
ENT.Base = "base_gmodentity"
ENT.PrintName = "Radioactive"
ENT.Author = "BinaryBandit"
ENT.Spawnable = false
ENT.AdminSpawnable = false
function ENT:SetupDataTables()
self:NetworkVar("Int",0,"price")
self:NetworkVar("Entity",1,"owning_ent")
end [/code]
Sorry, you need to Log In to post a reply to this thread.