Help, I create my money printer, and there is a system for storing and refilling the cartridge, but after the crop runs out and I run it over, he does not want to print.
init.lua
AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include("shared.lua")
ENT.SeizeReward = 950
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()
phys:Wake()
self.sparking = false
self.damage = 100
self.IsMoneyPrinter = true
timer.Simple(math.random(5, 10), function() PrintMore(self) end)
self.sound = CreateSound(self, Sound("ambient/levels/labs/equipment_printer_loop1.wav"))
self.sound:SetSoundLevel(52)
self.sound:PlayEx(1, 100)
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)
DarkRP.notify(self:Getowning_ent(), 1, 4, DarkRP.getPhrase("money_printer_exploded"))
end
function ENT:BurstIntoFlames()
DarkRP.notify(self:Getowning_ent(), 0, 4, DarkRP.getPhrase("money_printer_overheating"))
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
timer.Simple(1, function()
if not IsValid(ent) then return end
ent:CreateMoneybag()
end)
end
function ENT:CreateMoneybag()
if self:GetCatrig() > 0 or self:GetMoney() != 10000 then
if not IsValid(self) or self:IsOnFire() or then return end
local amount = 1000
if amount == 0 then
amount = 250
end
if self:GetCatrig() == 0 or self:GetMoney() == 10000 then end
self:SetMoney( self:GetMoney() + amount)
--DarkRP.createMoneyBag(Vector(MoneyPos.x + 15, MoneyPos.y, MoneyPos.z + 15), amount)
timer.Simple(math.random(1, 5), function() PrintMore(self) end)
self:SetCatrig(self:GetCatrig() - 1)
else
return
end
end
function ENT:Think()
if self:WaterLevel() > 0 then
self:Destruct()
self:Remove()
return
end
end
function ENT:StartTouch(ent)
if (ent:GetClass() == "catrige" and self:GetCatrig() < 10) then
self:SetCatrig(self:GetCatrig() + 1)
function() PrintMore(self) end
ent:Remove()
end
end
function ENT:Use(ply)
if self:GetMoney() > 0 then
ply:addMoney(self:GetMoney())
self:SetMoney(0)
end
end
function ENT:OnRemove()
if self.sound then
self.sound:Stop()
end
end
shared.lua
ENT.Type = "anim"
ENT.Base = "base_gmodentity"
ENT.PrintName = "Money Printer"
ENT.Category = "Money Printers"
ENT.Author = "DarkRP Developers and <enter name here>"
ENT.Spawnable = true
ENT.AdminSpawnable = false
function ENT:SetupDataTables()
self:NetworkVar("Int", 0, "price")
self:NetworkVar("Entity", 0, "owning_ent")
self:NetworkVar("Int", 1, "Money")
self:NetworkVar("Int", 2, "Catrig")
end
Sorry, you need to Log In to post a reply to this thread.