View difference between Paste ID: DSMqz6CX and KESCzbWh
SHOW: | | - or go back to the newest paste.
1
AddCSLuaFile("cl_init.lua")
2
AddCSLuaFile("shared.lua")
3
include("shared.lua")
4
/*_________________________________________________
5
Configs!
6
_________________________________________________*/
7
MethSystemCookingTime = 10 -- How long time it takes for the meth to finish cooking [DEFAULT : 300]
8
MethSystemHealth = 50 -- How long much the health the meth has. [DEFAULT : 50]
9
10
//OverCooking
11
MethSystemOverCookLowSeconds = 90 -- The lowest amount of seconds there has to go by, before it can explode by over cooking. [DEFAULT : 90]
12
MethSystemOverCookMaxSeconds = 180 -- The highest amount of seconds there has to go by before it can explode by over cooking. [DEFAULT : 180]
13
// Amount of money it drops
14-
MethSystemMoneyDropLowAmount = 500 -- Lowest amount of money it can drop when you cooked your meth. [DEFAULT : 500]
14+
MethSystemMoneyDropLowAmount = 200 -- Lowest amount of money it can drop when you cooked your meth. [DEFAULT : 500]
15-
MethSystemMoneyDropMaxAmount = 2000 -- Highest amount of money it can drop, when you cooked your meth. [DEFAULT : 2000]
15+
MethSystemMoneyDropMaxAmount = 500 -- Highest amount of money it can drop, when you cooked your meth. [DEFAULT : 2000]
16
MethSystemMinRadius = 150 -- The minimum radius of the explosion of the meth. [DEFUALT : 150]
17
MethSystemMaxRadius = 350 -- The maximum radius of the explosion of the meth. [DEFAULT : 350]
18
19-
ENT.SeizeReward = 1000 -- The reward police will get for destroying this meth. [DEFAULT 1000]
19+
ENT.SeizeReward = 200 -- The reward police will get for destroying this meth. [DEFAULT 1000]
20
function ENT:Initialize()
21
	self:SetModel("models/props_c17/oildrum001.mdl")
22
	self:PhysicsInit(SOLID_VPHYSICS)
23
	self:SetMaterial("models/debug/debugwhite")
24
	self:SetColor(Color(150,150,150))
25
	self:SetMoveType(MOVETYPE_VPHYSICS)
26
	self:SetSolid(SOLID_VPHYSICS)
27
	self:SetUseType(SIMPLE_USE)
28
	self.damage = MethSystemHealth
29
	self:SetMethTimer(MethSystemCookingTime)
30
		
31
	local phys = self:GetPhysicsObject()
32
	phys:Wake()
33
end
34
35
function ENT:OnTakeDamage(dmg)
36
37
	self.damage = (self.damage) - dmg:GetDamage()
38
	if self.damage < 1 then
39
	self:Explode()
40
	end
41
end
42
43
function ENT:StartTouch(ent)
44
	if ent:IsValid() and ent:GetClass() == "meth_stove" then
45
		self.IsCooking = true
46
		if !self.TimeOn then
47
		self:StartTimer()
48
		end
49
	end
50
end
51
52
function ENT:OverCook()
53
		if self.IsDone and self.IsCooking then
54
		timer.Create("Explode"..tostring(self:EntIndex()),math.random(MethSystemOverCookLowSeconds,MethSystemOverCookMaxSeconds), 1, function()
55
		self:Explode()
56
		end)
57
	end
58
end
59
60
function ENT:EndTouch(entt)
61
62
	if entt:IsValid() and entt:GetClass() == "meth_stove" then
63
	self.TimeOn = false
64
	self.Cooking = false
65
	timer.Pause("countdown"..tostring(self:EntIndex()))
66
	timer.Pause("Explode"..tostring(self:EntIndex()))
67
	end
68
end
69
70
function ENT:StartTimer()
71
	self.TimeOn = true
72
	
73
	if self:GetMethTimer() < 1 then 
74
	self.IsDone = true
75
	self:OverCook()
76
	return end
77
	
78
	timer.Create("countdown"..tostring(self:EntIndex()), 1, 1, function()
79
	if self.IsDone then
80
	self:SetMethTimer(0)
81
	return end
82
	
83
	self:SetMethTimer(self:GetMethTimer() - 1)
84
	self:StartTimer()
85
	end)
86
87
end
88
89
function ENT:Use(ply)
90
	local moneyrnd = math.random(MethSystemMoneyDropLowAmount,MethSystemMoneyDropMaxAmount)
91
	if self.IsDone then
92
	self:Remove()
93
	
94
	ply:SendLua(
95
	[[
96
	chat.AddText( Color(255,0,0), "[Meth System]", Color(255,255,255), " You have sold your meth for $]] .. moneyrnd .. [[.")]])
97
	
98
	money = ents.Create("spawned_money")
99
	money:SetPos(self:GetPos())
100
	money:Setamount(moneyrnd)
101
	money:Spawn()
102
	else
103
	ply:SendLua(
104
	[[
105
	chat.AddText( Color(255,0,0), "[Meth System]", Color(255,255,255), " The meth has not been cooked, place the meth on a stove to cook it.")]])
106
	
107
	
108
	end
109
end
110
111
function ENT:Destruct()
112
	local vPoint = self:GetPos()
113
	local effectdata = EffectData()
114
	effectdata:SetStart(vPoint)
115
	effectdata:SetOrigin(vPoint)
116
	effectdata:SetScale(1000000000)
117
	util.Effect("Explosion", effectdata)
118
	
119
	local effectdata1 = EffectData()
120
	effectdata1:SetStart(vPoint)
121
	effectdata1:SetOrigin(vPoint)
122
	effectdata1:SetScale(1000000000)
123
	util.Effect("HelicopterMegaBomb", effectdata)
124
	
125
	local effectdata2 = EffectData()
126
	effectdata2:SetStart(self:GetPos() + self:GetAngles():Up() * 600)
127
	effectdata2:SetOrigin(self:GetPos() + self:GetAngles():Up() * 600)
128
	effectdata2:SetScale(1000000000)
129
	util.Effect("HelicopterMegaBomb", effectdata)
130
end
131
132
133
function ENT:Explode()
134
	local dist = math.random(MethSystemMinRadius, MethSystemMaxRadius) -- Explosion radius
135
	self:Destruct()
136
	for k, v in pairs(ents.FindInSphere(self:GetPos(), dist)) do
137
	if not v:IsPlayer() and not v:IsWeapon() and v:GetClass() ~= "predicted_viewmodel" then
138
		v:Ignite(math.random(15, 30), 0)
139
	elseif v:IsPlayer() then
140
	local distance = v:GetPos():Distance(self:GetPos())
141
	v:TakeDamage(distance / dist * 150, self, self)
142
	v:Ignite(math.random(8, 25), 0)
143
	end
144
end
145
self:Remove()
146
end
147
	
148
function ENT:OnRemove()
149
	timer.Stop("countdown"..tostring(self:EntIndex()))
150
	timer.Stop("Explode"..tostring(self:EntIndex()))
151
	self:SetMethTimer(0)
152
end