local banTime = 1440 -- Feel free to change this to any time. 0 = Permanent. In minutes
--[[
1440 = 1 day
10080 = 1 week
https://www.google.com/#q=how%20many%20minutes%20in%201%20day
]]
function ulx.nrslay( calling_ply, target_ply, rounds, reason )
print( rounds )
if reason == nil or "" then -- This is where the default reason goes. Change this to whatever you want.
reason = "RDM"
end
if rounds < 0 then
ULib.tsayError( calling_ply, "Invalid number of rounds. Must be 0 or higher." )
elseif rounds == 0 then
target_ply:RemovePData( "slays_left" )
ulx.fancyLogAdmin( "#A has removed all slays from #T.", calling_ply, target_ply )
elseif rounds == 1 then
target_ply:SetPData( "slays_left", 1 )
ulx.fancyLogAdmin( "#A will slay #T next round for #s.", calling_ply, target_ply, reason )
elseif rounds > 0 then
target_ply:SetPData( "slays_left", rounds )
ulx.fancyLogAdmin( "#A will slay #T for the next #i rounds for #s.", calling_ply, target_ply, rounds, reason )
else -- Just to catch something that isn't specified.
ULib.tsayError( calling_ply, "Unexpected error. Make sure you specified number of rounds." )
end
hook.Add( "PlayerDisconnected", "Warn Admins on slay leave/Auto ban on leave", function( ply )
if ply:GetPData( "slays_left" ) >= 1 then
ulx.fancyLogAdmin( ply:Nick() .. " has left with " .. tonumber( ply:GetPData( "slays_left" ) ) .. " slays left. They have been banned for (" .. banTime .. ") minutes.")
ULib.addBan( ply:SteamID(), banTime, "Leave with " .. tonumber( ply:GetPData( "slays_left" ) ) .. " slays left", ply:Nick(), "CONSOLE" ) -- This is what the ban will say on the menu's 'bans' menu, and in server logs. "CONSOLE" is the "admin" that banned them. Best to leave it console.
end
end )
hook.Add( "PlayerAuthed", "Tell player how many slays they have left", function( ply, steamid, uniqueid )
if not ply:GetPData( "slays_left" ) == nil or 0 then
ULib.tsayError( ply, "You have " .. ply:GetPData( "slays_left" ) .. " slays left." )
end
end )
hook.Add( "TTTBeginRound", "Actually Slay", function()
for k,v in pairs( player.GetAll() ) do
if v:GetPData( "slays_left" ) >= 1 then
v:Kill()
if IsValid( v.server_ragdoll ) then
local ply = player.GetByUniqueID( v.server_ragdoll.uqid )
if not IsValid( ply ) then return end
ply:SetNWBool( "body_found", true )
CORPSE.SetFound( v.server_ragdoll, true )
v.server_ragdoll:Remove()
end
v:SetPData( "slays_left", tonumber( v:GetPData( "slays_left" ) ) - 1 )
ulx.fancyLogAdmin( "#T was slain by #A for #s.", target_ply, calling_ply, reason )
end
end
end )
end
local nrslay = ulx.command( "TTT Admin", "ulx nrslay", ulx.nrslay, "!nrslay" )
nrslay:addParam{ type=ULib.cmds.PlayerArg }
nrslay:addParam{ type=ULib.cmds.NumArg, hint="rounds", ULib.cmds.round, ULib.cmds.optional, default = 1, min = 0 }
nrslay:addParam{ type=ULib.cmds.StringArg, hint="reason", ULib.cmds.optional, ULib.cmds.takeRestOfLine }nrslay:defaultAccess( ULib.ACCESS_OPERATOR )