• Print

Author Topic: SpawN (Advanced Spawn Protection.)  (Read 20051 times)

0 Members and 1 Guest are viewing this topic.

Offline LuaTenshi

  • Hero Member
  • *****
  • Posts: 545
  • Karma: 47
  • Just your ordinary moon angel!
    • Mirai.Red
SpawN (Advanced Spawn Protection.)
« on: December 28, 2012, 02:06:01 am »
This requires rdr_invis get it here!
Code: Text
  1. --[[
  2. Copyright (C) <2012> <Kio Foxx (aka HeLLFox15)>
  3.  
  4. 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:
  5.  
  6. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
  7.  
  8. 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.
  9. ]]
  10.  
  11. -- Made by HeLLFox15 @ http://steamcommunity.com/profiles/76561198000875949 --
  12.  
  13. function notify( ply, msg, cvar )
  14.     ply:SendLua("GAMEMODE:AddNotify(\"" .. msg .. "\", " .. tostring(cvar) .. ", 5)")
  15. end
  16.  
  17. function FalseGodMode( ply, dmginfo )
  18.         if(ply:GetNetworkedVar("pSpawN") == 1) then
  19.                 dmginfo:ScaleDamage( 0 )
  20.         end
  21. end
  22. hook.Add("EntityTakeDamage", "FalseGodMode", FalseGodMode)
  23.  
  24. function SpawNNoWeapons(ply)
  25.         if(ply:GetNetworkedVar("pSpawN") == 1) then return false end
  26. end
  27. hook.Add("PlayerCanPickupWeapon", "SpawN_SpawNNoWeapons", SpawNNoWeapons)
  28. hook.Add("PlayerSpawnSWEP", "SpawN_SpawNNoWeaponsA", SpawNNoWeapons)
  29. hook.Add("PlayerGiveSWEP", "SpawN_SpawNNoWeaponsB", SpawNNoWeapons)
  30.  
  31. function SpawNGetTime( v, _, args )
  32.         if( time < 0 or not time ) then time = 15 end
  33.         if( ( IsValid(v) and ( v:IsAdmin() or v:IsSuperAdmin() ) ) or ( not IsValid(v) ) ) then
  34.                 time = tonumber(args[1])
  35.         end
  36.         return time
  37. end
  38. concommand.Add( "spawn_ptime", SpawNGetTime )
  39.  
  40. function SpawNGhostGetTime( v, _, args )
  41.         if( ghostTime < 0 or not ghostTime ) then ghostTime = 10 end
  42.         if( ( IsValid(v) and ( v:IsAdmin() or v:IsSuperAdmin() ) ) or ( not IsValid(v) ) ) then
  43.                 ghostTime = tonumber(args[1])
  44.         end
  45.        
  46.         if(ply:GetNetworkedVar("reSpawNing") == 1) then
  47.                 return ghostTime
  48.         else
  49.                 return 0
  50.         end
  51. end
  52. concommand.Add( "spawn_ghost_time", SpawNGhostGetTime )
  53.  
  54. function SpawNOnOff( v, _, args )
  55.         if( not active ) then active = false end
  56.         if( ( IsValid(v) and ( v:IsAdmin() or v:IsSuperAdmin() ) ) or ( not IsValid(v) ) ) then
  57.                 if(tonumber(args[1]) >= 1) then
  58.                         active = false
  59.                 else
  60.                         active = true
  61.                 end
  62.         end
  63.         return !active
  64. end
  65. concommand.Add( "spawn_disable", SpawNOnOff )
  66.  
  67. function SpawNGhost( v, _, args )
  68.         if( not onoff ) then onoff = false end
  69.         if( args[1] != 1 ) then
  70.                 args[1] = 0
  71.         else
  72.                 args[1] = 1
  73.         end
  74.        
  75.         if( ( IsValid(v) and ( v:IsAdmin() or v:IsSuperAdmin() ) ) or ( not IsValid(v) ) ) then
  76.                 onoff = tonumber(args[1])
  77.         end
  78.        
  79.         if(ply:GetNetworkedVar("reSpawNing") == 1) then
  80.                 return onoff
  81.         else
  82.                 return false
  83.         end
  84. end
  85. concommand.Add( "spawn_ghost", SpawNGhost )
  86.  
  87. function SpawNPos( v, _, args )
  88.         if( not reset ) then reset = false end
  89.         if( args[1] != 1 ) then
  90.                 args[1] = 0
  91.         else
  92.                 args[1] = 1
  93.         end
  94.        
  95.         if( ( IsValid(v) and ( v:IsAdmin() or v:IsSuperAdmin() ) ) or ( not IsValid(v) ) ) then
  96.                 reset = tonumber(args[1])
  97.         end
  98.        
  99.         return reset
  100. end
  101. concommand.Add( "spawn_reset_pos", SpawNPos )
  102.  
  103. function spawn( ply )
  104.         if( SpawNOnOff() and ( ( SpawNGetTime() != 0 ) or ( SpawNGhostGetTime() != 0 ) ) ) then
  105.                 ply:Freeze( true )
  106.                 savedPos = ply:GetPos()
  107.                 timer.Simple( 1, function()
  108.                         ply:Freeze( false )
  109.                         ply:SetNetworkedVar("pSpawN", 1)
  110.                         ply:StripWeapons()
  111.                         if(SpawNGhost()) then ply:SetCollisionGroup(COLLISION_GROUP_DEBRIS) end
  112.                         -- ply:GodEnable() --
  113.                        
  114.                         if(SpawNGhost()) then
  115.                                 rdrInvis( ply, true, 100 )
  116.                         else
  117.                                 rdrInvis( ply, true, 0 )
  118.                         end
  119.                        
  120.                         if( SpawNGetTime() != 0 ) then
  121.                                 notify( ply, "[SpawN] You are protected!", "NOTIFY_GENERIC" )
  122.                         else if( SpawNGhostGetTime() != 0 )
  123.                                 notify( ply, "[SpawN] You are now a ghost!", "NOTIFY_GENERIC" )
  124.                         end
  125.                 end)
  126.                 if(ply:UserID()) then
  127.                   if(SpawNGhost()) then val = SpawNGetTime() else val = SpawNGhostGetTime() end
  128.                   timer.Create(tostring(ply:UserID()) .. "_SpawnMe", val+1, 1, function()
  129.                         if(ply and IsValid(ply)) then
  130.                                  rdrInvis( ply, false, 255 )
  131.                                  ply:SetNetworkedVar("pSpawN", 0)
  132.                                  if(SpawNGhost()) then ply:SetCollisionGroup(COLLISION_GROUP_PLAYER) end
  133.                                  -- ply:GodDisable() --
  134.                                  if(SpawNGhost() or SpawNPos()) then ply:SetPos(savedPos) end
  135.                                  ply:SetNetworkedVar("reSpawNing", 0)
  136.                                  --Now for the loadout--
  137.                                  GAMEMODE:PlayerLoadout( ply )
  138.                                  if( SpawNGetTime() != 0 ) then
  139.                                         notify( ply, "[SpawN] You are protected!", "NOTIFY_GENERIC" )
  140.                                  else if( SpawNGhostGetTime() != 0 )
  141.                                         notify( ply, "[SpawN] You are no longer a ghost!", "NOTIFY_GENERIC" )
  142.                                  end
  143.                         end
  144.                   end)
  145.                 else
  146.                   ply:Kick("UserID Error.")
  147.                 end
  148.         end
  149. end
  150. hook.Add( "PlayerSpawn", "spawn", spawn )
  151.  
  152. function fixSpawn( ply )
  153.         if( ply and IsValid(ply) ) then
  154.                 ply:SetNetworkedVar("reSpawNing", 1)
  155.         end
  156.         if( ply:UserID() and timer.Exists(tostring(ply:UserID()) .. "_SpawnMe") ) then
  157.                 timer.Destroy(tostring(ply:UserID()) .. "_SpawnMe")
  158.         end
  159. end
  160. hook.Add( "DoPlayerDeath", "fixSpawn", fixSpawn )
  161.  

Normal Mode
Players will spawn invisible and with no weapons, during the time that they are protected (15 seconds or Set by admin.) they will be invisible have god mode and be able to move around freely. When the spawn protection wears off they become visible again and get their weapons, and will be moved back into the location where they spawned (Set by admin).

Ghost Mode
(Will not apply to players who just joined your server.)
When in ghost mode players will spawn as Ghosts (Useful for RP), when a player is a ghost every thing above applies to them how ever the ghost time will be added to the time that the player is protected and they will not be invisible, they will also be moved back to the location where they spawned (after the Spawn protection runs out), and will also be able to move through props and other players.
---
Ghost Mode is useful for RP servers as apposed to being unable to re-spawn for a certain amount of time.

Console Commands
"spawn_disable #" to disable/enable spawn protection.
---
"spawn_ptime #" to set how long players are protected.
---
"spawn_ghost #" to enable/disable ghost mode.
---
"spawn_ghost_time #" to set how long players are ghosts for.
« Last Edit: July 01, 2013, 12:38:54 pm by HeLLFox_15 »
I cry every time I see that I am not a respected member of this community.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: SpawN (Advanced Spawn Protection.)
« Reply #1 on: December 28, 2012, 03:26:34 pm »
First, sounds like nice work.
Second - Help me out a bit...it's spawn protection. I get that.
You spawn, it prevents people from seeing/killing you, presumably if they are spawn camping. I think I get that.
What I definitely don't get.... why move them back to where they spawned after the protection time is up, especially if this was made to protect from spawn campers killing them in the first place.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline LuaTenshi

  • Hero Member
  • *****
  • Posts: 545
  • Karma: 47
  • Just your ordinary moon angel!
    • Mirai.Red
Re: SpawN (Advanced Spawn Protection.)
« Reply #2 on: December 28, 2012, 03:35:56 pm »
First, sounds like nice work.
Second - Help me out a bit...it's spawn protection. I get that.
You spawn, it prevents people from seeing/killing you, presumably if they are spawn camping. I think I get that.
What I definitely don't get.... why move them back to where they spawned after the protection time is up, especially if this was made to protect from spawn campers killing them in the first place.

Well I just gave admins the option to have it do that, its more for the ghost mode then any thing so that players wont spawn in props or other players.
---
I am going to add the option to ghost players move them back to spawn when ghost runs out and then apply the normal spawn protection on them.

---
I need to remake this code with cvars instead of functions,  or atleast have functions that call cvars... you know what I mean...
« Last Edit: January 09, 2013, 06:46:24 am by HeLLFox_15 »
I cry every time I see that I am not a respected member of this community.

Offline H-0-R-I-Z-0-N

  • Newbie
  • *
  • Posts: 3
  • Karma: -1
Re: SpawN (Advanced Spawn Protection.)
« Reply #3 on: March 28, 2015, 05:47:23 pm »
Where do I download this? The rdr_invis says it's down.
I take back everything I've said. You wore those words on your lips, as if they meant anything anyway.

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
Re: SpawN (Advanced Spawn Protection.)
« Reply #4 on: March 28, 2015, 06:20:43 pm »
Where do I download this? The rdr_invis says it's down.

it appears that this player doesn't play anymore: August 24, 2014, 11:42:09 AM

So we have no way of helping you find the link, seeing as this is a few years old of a thread.
Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: SpawN (Advanced Spawn Protection.)
« Reply #5 on: March 28, 2015, 09:59:33 pm »
« Last Edit: March 28, 2015, 10:16:49 pm by Aaron113 »

Offline COOLJ

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
Re: SpawN (Advanced Spawn Protection.)
« Reply #6 on: April 10, 2015, 05:43:21 pm »
If this can be used with DarkRP please explain how

  • Print