This commit is contained in:
lifestorm
2024-08-04 22:55:00 +03:00
parent 8064ba84d8
commit 73479cff9e
7338 changed files with 1718883 additions and 14 deletions

102
lua/sam/modules/ttt.lua Normal file
View File

@@ -0,0 +1,102 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
if SAM_LOADED then return end
local run = function(fn)
if not GAMEMODE then
timer.Simple(0, fn)
else
fn()
end
end
run(function()
if engine.ActiveGamemode() ~= "terrortown" then return end
local sam, command, language = sam, sam.command, sam.language
command.set_category("TTT")
command.new("setslays")
:SetPermission("setslays", "admin")
:AddArg("player", {single_target = true})
:AddArg("number", {hint = "amount", optional = true, min = 1, default = 1, round = true})
:Help("setslays_help")
:OnExecute(function(ply, targets, amount)
targets[1]:sam_set_pdata("slays_amount", amount)
sam.player.send_message(nil, "setslays", {
A = ply, T = targets, V = amount
})
end)
:End()
command.new("removeslays")
:SetPermission("removeslays", "admin")
:AddArg("player", {single_target = true})
:Help("removeslays_help")
:OnExecute(function(ply, targets, amount)
local target = targets[1]
target:sam_set_pdata("slays_amount", nil)
target:SetForceSpec(false)
sam.player.send_message(nil, "removeslays", {
A = ply, T = targets
})
end)
:End()
OldBeginRound = OldBeginRound or BeginRound
function BeginRound(...)
local players = player.GetAll()
for i = 1, #players do
local ply = players[i]
local slays = ply:sam_get_pdata("slays_amount")
if not slays then continue end
if not ply:IsSpec() then
ply:Kill()
end
GAMEMODE:PlayerSpawnAsSpectator(ply)
ply:SetTeam(TEAM_SPEC)
ply:SetForceSpec(true)
ply:Spawn()
ply:SetRagdollSpec(false) -- dying will enable this, we don't want it here
slays = slays - 1
if slays == 0 then
timer.Simple(0, function()
ply:SetForceSpec(false)
end)
ply:sam_set_pdata("slays_amount", nil)
else
ply:sam_set_pdata("slays_amount", slays)
end
sam.player.send_message(nil, "setslays_slayed", {
T = {ply}, V = slays
})
end
return OldBeginRound(...)
end
end)