-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsv_propkill.lua
113 lines (106 loc) · 3.38 KB
/
sv_propkill.lua
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
local sfc2 = sfc2
local print_target = sfc2.print_target
local print_all = sfc2.print_all
local default_pos = Vector(0, 0, -1337)
sfc2.propkill_default_pos = default_pos
local default_ang = Angle()
sfc2.propkill_default_ang = default_ang
local ent = prop.create(default_pos, default_ang, 'models/props_junk/PopCan01a.mdl', true)
sfc2.propkill_ent = ent
ent:setColor(Color(0, 0, 0, 0))
ent:setNoDraw(true)
ent:setMass(math.huge)
local queue = {}
sfc2.propkill_queue = queue
local at_home = false
local function home()
ent:setPos(default_pos)
ent:setAngles(default_ang)
ent:setFrozen(true)
at_home = true
end
sfc2.propkill_home = home
local zo = -math.min(
ent:obbMins().z,
ent:obbMaxs().z
)
local vel = Vector(0, 0, -1000)
sfc2.propkill_vel = vel
local function kill(target)
at_home = false
local pos = target:getPos()
pos.z = math.max(
(pos+target:obbMins()).z,
(pos+target:obbMaxs()).z
)+zo+1
ent:setFrozen(false)
ent:setPos(pos)
ent:addVelocity(vel)
end
sfc2.propkill_kill = kill
timer.create(sfc2.TIMER_NAME..'_propkill_queue', 1/30, 0, function()
local target = table.remove(queue, 1)
if not isValid(target) then
if not at_home then
home()
end
return
else
kill(target)
end
end)
sfc2.commands.propkill = function(executor, parameters)
if executor ~= owner() then
print_target(executor, sfc2.color_feedback, "sfc2: not allowed")
return
end
local target = sfc2.get_target(parameters, true)
if type(target) ~= 'Player' then
print_target(executor, sfc2.color_feedback, "sfc2: no such target")
return
end
table.insert(queue, target)
print_all(team.getColor(executor:getTeam()), executor:getName(), sfc2.color_feedback, " propkilled ", team.getColor(target:getTeam()), target:getName(), sfc2.color_feedback, ".")
end
local damned = {}
sfc2.propkill_damned = damned
sfc2.commands.spawnkill = function(executor, parameters)
if executor ~= owner() then
print_target(executor, sfc2.color_feedback, "sfc2: not allowed")
return
end
local target = sfc2.get_target(parameters, true)
if type(target) ~= 'Player' then
print_target(executor, sfc2.color_feedback, "sfc2: no such target")
return
end
if damned[target:getSteamID()] then
print_target(executor, sfc2.color_feedback, "sfc2: target already being spawnkilled")
return
end
table.insert(queue, target)
damned[target:getSteamID()] = true
print_all(team.getColor(executor:getTeam()), executor:getName(), sfc2.color_feedback, " damned ", team.getColor(target:getTeam()), target:getName(), sfc2.color_feedback, " to endless spawnkilling.")
end
sfc2.commands.unspawnkill = function(executor, parameters)
if executor ~= owner() then
print_target(executor, sfc2.color_feedback, "sfc2: not allowed")
return
end
local target = sfc2.get_target(parameters, true)
if type(target) ~= 'Player' then
print_target(executor, sfc2.color_feedback, "sfc2: no such target")
return
end
if not damned[target:getSteamID()] then
print_target(executor, sfc2.color_feedback, "sfc2: target not being spawnkilled")
return
end
damned[target:getSteamID()] = nil
print_all(team.getColor(executor:getTeam()), executor:getName(), sfc2.color_feedback, " saved ", team.getColor(target:getTeam()), target:getName(), sfc2.color_feedback, " from endless spawnkilling.")
end
hook.add('PlayerSpawn', sfc2.HOOK_NAME..'_propkill_damned', function(target)
if damned[target:getSteamID()] and queue[#queue] ~= target then
table.insert(queue, target)
end
end)