`
local sprayCanPrice = 50
local sprayCanTerm = 30
local paintRange = 100
local paintSize = 10
local paintColor = Color(255, 255, 255)
local paintBlob = {}
paintBlob.__index = paintBlob
function paintBlob:new(pos, color)
local ent = ents.Create("spraycan_paint")
ent:SetPos(pos)
ent:SetColor(color)
ent:Spawn()
return setmetatable(ent, paintBlob)
end
function paintBlob:Remove()
self:Remove()
end
hook.Add("KeyPress", "SprayCan", function(pl, k)
if not pl:HasPurchase("spraycan") then return end
if k ~= IN_ATTACK then return end
local tr = util.TraceLine(pl:GetShootPos(), pl:GetShootPos() + pl:GetAimVector() * paintRange, pl)
if tr.Hit then
local pos = tr.HitPos
local color = paintColor
if pl.SprayCanColor then
color = pl.SprayCanColor
end
local paint = paintBlob:new(pos, color)
paint:SetParent(tr.Entity)
timer.Simple(0.5, function()
pl.SprayCanCooldown = nil
end)
pl.SprayCanCooldown = true
end
end)
hook.Add("ShowSpare2", "SprayCanColorMenu", function(pl)
if not pl:HasPurchase("spraycan") then return end
local menu = DermaMenu()
menu:SetPos(100, 100)
local colors = {
{text = "Red", color = Color(255, 0, 0)},
{text = "Blue", color = Color(0, 0, 255)},
{text = "Green", color = Color(0, 255, 0)},
{text = "Yellow", color = Color(255, 255, 0)},
{text = "Black", color = Color(0, 0, 0)},
{text = "White", color = Color(255, 255, 255)},
}
for _, color in ipairs(colors) do
local button = menu:AddOption(color.text)
button:SetColor(color.color)
button.DoClick = function()
pl.SprayCanColor = color.color
menu:Close()
end
end
menu:Open()
end)
ENT.Type = "point"
ENT.Base = "base_point"
function ENT:Initialize()
self:SetSolid(SOLID_NONE)
self:SetCollisionGroup(COLLISION_GROUP_WORLD)
self:SetColor(self:GetColor())
end
function ENT: Draw()
local pos = self:GetPos()
local size = paintSize
local color = self:GetColor()
render.SetMaterial(Material("sprites/light_ignorez.vmt"))
render.DrawSprite(pos, size, size, color)
end`