Advertisement
Guest User

Garry's Mod Anti Prop Kill Script

a guest
Jul 20th, 2012
2,458
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.48 KB | None | 0 0
  1. function AntiPropPushPickup( userid, ent )  
  2.     if ent:GetClass() == "prop_physics" then
  3.         ent:SetCollisionGroup( COLLISION_GROUP_WEAPON )  
  4.         local r,g,b,a = ent:GetColor();  
  5.         ent:SetColor(r,g,b,180)  
  6.     end
  7. end
  8. hook.Add( "PhysgunPickup", "AntiPropPushPickup", AntiPropPushPickup )  
  9.    
  10. function AntiPropPushDrop( pl, ent )  
  11.     if ent:GetClass() == "prop_physics" then
  12.         ent:GetPhysicsObject():SetVelocity( Vector(0,0,0) )  
  13.         ent:GetPhysicsObject():AddAngleVelocity(ent:GetPhysicsObject():GetAngleVelocity( )*-1)
  14.         ent:SetCollisionGroup( COLLISION_GROUP_NONE )
  15.         local r,g,b,a = ent:GetColor();  
  16.         ent:SetColor(r,g,b,255)
  17.     end
  18. end
  19. hook.Add("PhysgunDrop", "AntiPropPushDrop", AntiPropPushDrop);  
  20.    
  21. function AntiPropPushFreezing(weapon, physobj, ent, ply)  
  22.     if ent:GetClass() == "prop_physics" then
  23.         local rad = ent:BoundingRadius()*1.3  
  24.         local inside = false  
  25.         for k, ply in pairs(player.GetAll()) do
  26.             if (ply:GetPos():Distance(ent:LocalToWorld(ent:OBBCenter())) < rad) then
  27.                 inside = true  
  28.             end
  29.         end
  30.         for k, ply in pairs(player.GetAll()) do
  31.             local pos = ply:GetPos() + Vector(0,0,64)  
  32.             if (pos:Distance(ent:LocalToWorld(ent:OBBCenter())) < rad) then
  33.                 inside = true  
  34.             end
  35.         end
  36.            
  37.         if inside then
  38.             ent:SetCollisionGroup( COLLISION_GROUP_WEAPON )  
  39.             local r,g,b,a = ent:GetColor();  
  40.             ent:SetColor(r,g,b,100)  
  41.         else
  42.             ent:SetCollisionGroup( COLLISION_GROUP_NONE )  
  43.             local r,g,b,a = ent:GetColor();  
  44.             ent:SetColor(r,g,b,255)  
  45.         end  
  46.     end
  47. end
  48. hook.Add("OnPhysgunFreeze", "AntiPropPushFreezing", AntiPropPushFreezing)  
  49.    
  50. function AntiPropKill(victim, attacker)  
  51.     if(not attacker:IsPlayer()) then
  52.         if (attacker:GetClass() == "prop_physics") then
  53.         return false  
  54.         end
  55.     end
  56. end
  57.    
  58. hook.Add( "PlayerShouldTakeDamage", "AntiPropKill", AntiPropKill)
  59.  
  60. hook.Add("PhysgunDrop", "AntiPP", function(ply, ent)
  61.     ent:SetCollisionGroup(COLLISION_GROUP_WORLD) --Collide with world only
  62.     ent:SetColor(255,255,255,180) --Opacify it so it's transparent
  63.     timer.Simple(1, function()
  64.         ent:SetCollisionGroup(COLLISION_GROUP_NONE) --Reset collision
  65.         ent:SetColor(255,255,255,255) --Reset opacity
  66.     end)
  67. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement