-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathspray.txt
67 lines (57 loc) · 2.03 KB
/
spray.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
--@name Spray
--@author Sparky
--@shared
-- The spray should be a 1024x1024 image
local sprayUrl = "https://dl.dropboxusercontent.com/s/3hbtg2lt7sc1qxq/dove.png"
local sprayHolo
if SERVER then
sprayHolo = holograms.create(Vector(), Angle(), "models/holograms/plane.mdl", Vector(5))
sprayHolo:suppressEngineLighting(true)
net.receive("spray",function()
local orientation = net.readMatrix()
sprayHolo:setPos(orientation:getTranslation())
sprayHolo:setAngles(orientation:getAngles())
sprayHolo:setNoDraw(false)
sprayHolo:emitSound("player/sprayer.wav")
end)
net.receive("getholo",function(len,pl)
net.start("holo") net.writeEntity(sprayHolo) net.send(pl)
end)
else
if player()==owner() then
hook.add("inputPressed","",function(key)
if key==30 then
local tr = owner():getEyeTrace()
local pos = tr.HitPos
local normal = tr.HitNormal
local up
if normal==Vector(0,0,1) then
up = Vector(0,1,0)
else
up = (Vector(0,0,1) - normal*normal[3]):getNormalized()
end
local mat = Matrix()
mat:setForward(-up)
mat:setRight(normal:cross(up))
mat:setUp(normal)
mat:setTranslation(pos+normal)
net.start("spray")
net.writeMatrix(mat)
net.send()
end
end)
end
local sprayMat = material.create("VertexLitGeneric")
sprayMat:setInt("$flags", 256)
sprayMat:setTextureURL("$basetexture",sprayUrl)
net.receive("holo",function()
net.readEntity(function(holo)
if not holo then net.start("getholo") net.send() return end
sprayHolo = holo
hook.add("think","",function()
pcall(sprayHolo.setMaterial, sprayHolo, "!"..sprayMat:getName())
end)
end)
end)
net.start("getholo") net.send()
end