--[[
Copyright (C) <2012> <Kio Foxx (aka HeLLFox15)>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
]]
-- Made by HeLLFox15 @ http://steamcommunity.com/profiles/76561198000875949 --
function notify( ply, msg, cvar )
ply:SendLua("GAMEMODE:AddNotify(\"" .. msg .. "\", " .. tostring(cvar) .. ", 5)")
end
function FalseGodMode( ply, dmginfo )
if(ply:GetNetworkedVar("pSpawN") == 1) then
dmginfo:ScaleDamage( 0 )
end
end
hook.Add("EntityTakeDamage", "FalseGodMode", FalseGodMode)
function SpawNNoWeapons(ply)
if(ply:GetNetworkedVar("pSpawN") == 1) then return false end
end
hook.Add("PlayerCanPickupWeapon", "SpawN_SpawNNoWeapons", SpawNNoWeapons)
hook.Add("PlayerSpawnSWEP", "SpawN_SpawNNoWeaponsA", SpawNNoWeapons)
hook.Add("PlayerGiveSWEP", "SpawN_SpawNNoWeaponsB", SpawNNoWeapons)
function SpawNGetTime( v, _, args )
if( time < 0 or not time ) then time = 15 end
if( ( IsValid(v) and ( v:IsAdmin() or v:IsSuperAdmin() ) ) or ( not IsValid(v) ) ) then
time = tonumber(args[1])
end
return time
end
concommand.Add( "spawn_ptime", SpawNGetTime )
function SpawNGhostGetTime( v, _, args )
if( ghostTime < 0 or not ghostTime ) then ghostTime = 10 end
if( ( IsValid(v) and ( v:IsAdmin() or v:IsSuperAdmin() ) ) or ( not IsValid(v) ) ) then
ghostTime = tonumber(args[1])
end
if(ply:GetNetworkedVar("reSpawNing") == 1) then
return ghostTime
else
return 0
end
end
concommand.Add( "spawn_ghost_time", SpawNGhostGetTime )
function SpawNOnOff( v, _, args )
if( not active ) then active = false end
if( ( IsValid(v) and ( v:IsAdmin() or v:IsSuperAdmin() ) ) or ( not IsValid(v) ) ) then
if(tonumber(args[1]) >= 1) then
active = false
else
active = true
end
end
return !active
end
concommand.Add( "spawn_disable", SpawNOnOff )
function SpawNGhost( v, _, args )
if( not onoff ) then onoff = false end
if( args[1] != 1 ) then
args[1] = 0
else
args[1] = 1
end
if( ( IsValid(v) and ( v:IsAdmin() or v:IsSuperAdmin() ) ) or ( not IsValid(v) ) ) then
onoff = tonumber(args[1])
end
if(ply:GetNetworkedVar("reSpawNing") == 1) then
return onoff
else
return false
end
end
concommand.Add( "spawn_ghost", SpawNGhost )
function SpawNPos( v, _, args )
if( not reset ) then reset = false end
if( args[1] != 1 ) then
args[1] = 0
else
args[1] = 1
end
if( ( IsValid(v) and ( v:IsAdmin() or v:IsSuperAdmin() ) ) or ( not IsValid(v) ) ) then
reset = tonumber(args[1])
end
return reset
end
concommand.Add( "spawn_reset_pos", SpawNPos )
function spawn( ply )
if( SpawNOnOff() and ( ( SpawNGetTime() != 0 ) or ( SpawNGhostGetTime() != 0 ) ) ) then
ply:Freeze( true )
savedPos = ply:GetPos()
timer.Simple( 1, function()
ply:Freeze( false )
ply:SetNetworkedVar("pSpawN", 1)
ply:StripWeapons()
if(SpawNGhost()) then ply:SetCollisionGroup(COLLISION_GROUP_DEBRIS) end
-- ply:GodEnable() --
if(SpawNGhost()) then
rdrInvis( ply, true, 100 )
else
rdrInvis( ply, true, 0 )
end
if( SpawNGetTime() != 0 ) then
notify( ply, "[SpawN] You are protected!", "NOTIFY_GENERIC" )
else if( SpawNGhostGetTime() != 0 )
notify( ply, "[SpawN] You are now a ghost!", "NOTIFY_GENERIC" )
end
end)
if(ply:UserID()) then
if(SpawNGhost()) then val = SpawNGetTime() else val = SpawNGhostGetTime() end
timer.Create(tostring(ply:UserID()) .. "_SpawnMe", val+1, 1, function()
if(ply and IsValid(ply)) then
rdrInvis( ply, false, 255 )
ply:SetNetworkedVar("pSpawN", 0)
if(SpawNGhost()) then ply:SetCollisionGroup(COLLISION_GROUP_PLAYER) end
-- ply:GodDisable() --
if(SpawNGhost() or SpawNPos()) then ply:SetPos(savedPos) end
ply:SetNetworkedVar("reSpawNing", 0)
--Now for the loadout--
GAMEMODE:PlayerLoadout( ply )
if( SpawNGetTime() != 0 ) then
notify( ply, "[SpawN] You are protected!", "NOTIFY_GENERIC" )
else if( SpawNGhostGetTime() != 0 )
notify( ply, "[SpawN] You are no longer a ghost!", "NOTIFY_GENERIC" )
end
end
end)
else
ply:Kick("UserID Error.")
end
end
end
hook.Add( "PlayerSpawn", "spawn", spawn )
function fixSpawn( ply )
if( ply and IsValid(ply) ) then
ply:SetNetworkedVar("reSpawNing", 1)
end
if( ply:UserID() and timer.Exists(tostring(ply:UserID()) .. "_SpawnMe") ) then
timer.Destroy(tostring(ply:UserID()) .. "_SpawnMe")
end
end
hook.Add( "DoPlayerDeath", "fixSpawn", fixSpawn )