View difference between Paste ID: dYHcAh3z and
SHOW: | | - or go back to the newest paste.
1-
1+
-- RRPX Money Printer by philxyz  edited by Ninjarudo
2
AddCSLuaFile("cl_init.lua")
3
AddCSLuaFile("shared.lua")
4
include("shared.lua")
5
6
local printAmount = CreateConVar( "DARKRP_GOLDEN_PRINTER_AMOUNT", 1000, FCVAR_NOTIFY )
7
local printAmount = CreateConVar( "DARKRP_GOLDEN_PRINTER_AMOUNT", 1000, FCVAR_NOTIFY )
8
 
9
function ENT:Initialize()
10
	self:SetModel("models/props_lab/reciever01a.mdl")
11
	self:SetColor(100,100,0, 255)
12
	self:SetNWInt("Vaulted", 0 )
13
	self:PhysicsInit(SOLID_VPHYSICS)
14
	self:SetMoveType(MOVETYPE_VPHYSICS)
15
	self:SetSolid(SOLID_VPHYSICS)
16
	local phys = self:GetPhysicsObject()
17
	if phys:IsValid() then phys:Wake() end
18
	self.sparking = false
19
	self.damage = 200
20
	self.IsMoneyPrinter = true
21
	timer.Simple(5, self.CreateMoneybag, self)
22
end
23
24
 function ENT:Use(activator,caller)
25
	local amount = self:GetNWInt("Vaulted") or 0
26
	if amount > 0 then
27
		Notify(activator, 0, 4, "You have recieved " .. CUR ..( amount or 0 ) .. "!")
28
		if activator != self.dt.owning_ent then 
29
			Notify(self.dt.owning_ent, 1, 4, "Your Golden Money Printer has been cleaned out!")
30
		end
31
		activator:AddMoney(amount or 0)
32
		self:SetNWInt("Vaulted", 0)
33
	end
34
end
35
36
function ENT:OnTakeDamage(dmg)
37
	if self.burningup then return end
38
 
39
	self.damage = self.damage - dmg:GetDamage()
40
	if self.damage <= 0 then
41
		local rnd = math.random(1, 10)
42
		if rnd < 3 then
43
			self:BurstIntoFlames()
44
		else
45
			self:Destruct()
46
			self:Remove()
47
		end
48
	end
49
end
50
 
51
function ENT:Destruct()
52
	local vPoint = self:GetPos()
53
	local effectdata = EffectData()
54
	effectdata:SetStart(vPoint)
55
	effectdata:SetOrigin(vPoint)
56
	effectdata:SetScale(1)
57
	util.Effect("Explosion", effectdata)
58
	Notify(self.dt.owning_ent, 1, 4, "Your Golden Money Printer has exploded!")
59
end
60
 
61
function ENT:Fireball()
62
	if not self:IsOnFire() then return end
63
	local dist = math.random(30, 300) -- Explosion radius
64
	self:Destruct()
65
	for k, v in pairs(ents.FindInSphere(self:GetPos(), dist)) do
66
		if not v:IsPlayer() and not v.IsMoneyPrinter then v:Ignite(math.random(5, 22), 0) end
67
	end
68
	self:Remove()
69
end
70
 
71
local function PrintMore(ent)
72
	if ValidEntity(ent) then
73
		ent.sparking = true
74
		timer.Simple(1, ent.CreateMoneybag, ent)
75
	end
76
end
77
 
78
function ENT:CreateMoneybag()
79
	if not ValidEntity(self) then return end
80
	if self:IsOnFire() then return end
81
	
82
	-- if math.random(1, 22) == 3 then self:BurstIntoFlames() end
83
84
	if printAmount == 0 then
85
		printAmount = 1000
86
	end
87
 
88
	-- self.dt.amount = self.dt.amount + amount
89
	self:SetNWInt("Vaulted", self:GetNWInt("Vaulted") + printAmount)
90
	
91
	self.sparking = false
92
	-- timer.Simple(math.random(100, 150), PrintMore, self)
93
	timer.Simple( 10, PrintMore, self)
94
end
95
 
96
function ENT:Think()
97
	if not self.sparking then return end
98
 
99
	local effectdata = EffectData()
100
	effectdata:SetOrigin(self:GetPos())
101
	effectdata:SetMagnitude(1)
102
	effectdata:SetScale(1)
103
	effectdata:SetRadius(2)
104
	util.Effect("Sparks", effectdata)
105
end