Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[Respawn]------------------------------------------------------------------------------------
- --[[ulx.respawn][Respawns <target(s)>]
- @param {[PlayerObject]} calling_ply [The player who used the command.]
- @param {[PlayerObject]} target_plys [The player(s) who will have the effects of the command applied to them.]
- @param {[Boolean]} should_silent [Hidden, determines weather the output will be silent or not.]
- --]]
- function ulx.respawn( calling_ply, target_plys, should_silent )
- if not GetConVarString("gamemode") == "terrortown" then ULib.tsayError( calling_ply, gamemode_error, true ) else
- local affected_plys = {}
- for i=1, #target_plys do
- local v = target_plys[ i ]
- if ulx.getExclusive( v, calling_ply ) then
- ULib.tsayError( calling_ply, ulx.getExclusive( v, calling_ply ), true )
- elseif GetRoundState() == 1 then
- ULib.tsayError( calling_ply, "Waiting for players!", true )
- elseif v:Alive() and v:IsSpec() then -- players arent really dead when they are spectating, we need to handle that correctly
- timer.Destroy("traitorcheck" .. v:SteamID())
- v:ConCommand("ttt_spectator_mode 0") -- just incase they are in spectator mode take them out of it
- timer.Create("respawndelay", 0.1, 0, function() --seems to be a slight delay from when you leave spec and when you can spawn this should get us around that
- local corpse = corpse_find(v) -- run the normal respawn code now
- if corpse then corpse_remove(corpse) end
- v:SpawnForRound( true )
- v:SetCredits( ( (v:GetRole() == ROLE_INNOCENT) and 0 ) or GetConVarNumber("ttt_credits_starting") )
- table.insert( affected_plys, v )
- ulx.fancyLogAdmin( calling_ply, should_silent ,"#A respawned #T!", affected_plys )
- send_messages(affected_plys, "You have been respawned.")
- if v:Alive() then timer.Destroy("respawndelay") return end
- end)
- elseif v:Alive() then
- ULib.tsayError( calling_ply, v:Nick() .. " is already alive!", true )
- else
- timer.Destroy("traitorcheck" .. v:SteamID())
- local corpse = corpse_find(v)
- if corpse then corpse_remove(corpse) end
- v:SpawnForRound( true )
- v:SetCredits( ( (v:GetRole() == ROLE_INNOCENT) and 0 ) or GetConVarNumber("ttt_credits_starting") )
- table.insert( affected_plys, v )
- end
- end
- ulx.fancyLogAdmin( calling_ply, should_silent ,"#A respawned #T!", affected_plys )
- send_messages(affected_plys, "You have been respawned.")
- end
- end
- local respawn = ulx.command( CATEGORY_NAME, "ulx respawn", ulx.respawn, "!respawn")
- respawn:addParam{ type=ULib.cmds.PlayersArg }
- respawn:addParam{ type=ULib.cmds.BoolArg, invisible=true }
- respawn:defaultAccess( ULib.ACCESS_SUPERADMIN )
- respawn:setOpposite( "ulx srespawn", {_, _, true}, "!srespawn", true )
- respawn:help( "Respawns <target(s)>." )
- --[End]----------------------------------------------------------------------------------------
- --[Respawn teleport]---------------------------------------------------------------------------
- --[[ulx.respawntp][Respawns <target(s)>]
- @param {[PlayerObject]} calling_ply [The player who used the command.]
- @param {[PlayerObject]} target_ply [The player who will have the effects of the command applied to them.]
- @param {[Boolean]} should_silent [Hidden, determines weather the output will be silent or not.]
- --]]
- function ulx.respawntp( calling_ply, target_ply, should_silent )
- if not GetConVarString("gamemode") == "terrortown" then ULib.tsayError( calling_ply, gamemode_error, true ) else
- local affected_ply = {}
- if not calling_ply:IsValid() then
- Msg( "You are the console, you can't teleport or teleport others since you can't see the world!\n" )
- return
- elseif ulx.getExclusive( target_ply, calling_ply ) then
- ULib.tsayError( calling_ply, ulx.getExclusive( target_ply, calling_ply ), true )
- elseif GetRoundState() == 1 then
- ULib.tsayError( calling_ply, "Waiting for players!", true )
- elseif target_ply:Alive() and target_ply:IsSpec() then
- timer.Destroy("traitorcheck" .. target_ply:SteamID())
- target_ply:ConCommand("ttt_spectator_mode 0")
- timer.Create("respawntpdelay", 0.1, 0, function() --have to wait for gamemode before doing this
- local t = {}
- t.start = calling_ply:GetPos() + Vector( 0, 0, 32 ) -- Move them up a bit so they can travel across the ground
- t.endpos = calling_ply:GetPos() + calling_ply:EyeAngles():Forward() * 16384
- t.filter = target_ply
- if target_ply ~= calling_ply then
- t.filter = { target_ply, calling_ply }
- end
- local tr = util.TraceEntity( t, target_ply )
- local pos = tr.HitPos
- local corpse = corpse_find(target_ply)
- if corpse then corpse_remove(corpse) end
- target_ply:SpawnForRound( true )
- target_ply:SetCredits( ((target_ply:GetRole() == ROLE_INNOCENT) and 0) or GetConVarNumber("ttt_credits_starting") )
- target_ply:SetPos( pos )
- table.insert( affected_ply, target_ply )
- ulx.fancyLogAdmin( calling_ply, should_silent ,"#A respawned and teleported #T!", affected_ply )
- send_messages(target_ply, "You have been respawned and teleported.")
- if target_ply:Alive() then timer.Destroy("respawntpdelay") return end
- end)
- elseif target_ply:Alive() then
- ULib.tsayError( calling_ply, target_ply:Nick() .. " is already alive!", true )
- else
- timer.Destroy("traitorcheck" .. target_ply:SteamID())
- local t = {}
- t.start = calling_ply:GetPos() + Vector( 0, 0, 32 ) -- Move them up a bit so they can travel across the ground
- t.endpos = calling_ply:GetPos() + calling_ply:EyeAngles():Forward() * 16384
- t.filter = target_ply
- if target_ply ~= calling_ply then
- t.filter = { target_ply, calling_ply }
- end
- local tr = util.TraceEntity( t, target_ply )
- local pos = tr.HitPos
- local corpse = corpse_find(target_ply)
- if corpse then corpse_remove(corpse) end
- target_ply:SpawnForRound( true )
- target_ply:SetCredits( ((target_ply:GetRole() == ROLE_INNOCENT) and 0) or GetConVarNumber("ttt_credits_starting") )
- target_ply:SetPos( pos )
- table.insert( affected_ply, target_ply )
- end
- ulx.fancyLogAdmin( calling_ply, should_silent ,"#A respawned and teleported #T!", affected_ply )
- send_messages(affected_plys, "You have been respawned and teleported.")
- end
- end
- local respawntp = ulx.command( CATEGORY_NAME, "ulx respawntp", ulx.respawntp, "!respawntp")
- respawntp:addParam{ type=ULib.cmds.PlayerArg }
- respawntp:addParam{ type=ULib.cmds.BoolArg, invisible=true }
- respawntp:defaultAccess( ULib.ACCESS_SUPERADMIN )
- respawntp:setOpposite( "ulx srespawntp", {_, _, true}, "!srespawntp", true )
- respawntp:help( "Respawns <target> to a specific location." )
- --[End]----------------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement