mirror of
https://github.com/lifestorm/wnsrc.git
synced 2025-12-17 13:53:45 +03:00
Upload
This commit is contained in:
67
lua/autorun/properties/remove.lua
Normal file
67
lua/autorun/properties/remove.lua
Normal file
@@ -0,0 +1,67 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
|
||||
AddCSLuaFile()
|
||||
|
||||
properties.Add( "remove", {
|
||||
MenuLabel = "#remove",
|
||||
Order = 1000,
|
||||
MenuIcon = "icon16/delete.png",
|
||||
|
||||
Filter = function( self, ent, ply )
|
||||
|
||||
if ( !gamemode.Call( "CanProperty", ply, "remover", ent ) ) then return false end
|
||||
if ( !IsValid( ent ) ) then return false end
|
||||
if ( ent:IsPlayer() ) then return false end
|
||||
|
||||
return true
|
||||
|
||||
end,
|
||||
|
||||
Action = function( self, ent )
|
||||
|
||||
self:MsgStart()
|
||||
net.WriteEntity( ent )
|
||||
self:MsgEnd()
|
||||
|
||||
end,
|
||||
|
||||
Receive = function( self, length, ply )
|
||||
if ( !IsValid( ply ) ) then return end
|
||||
|
||||
local ent = net.ReadEntity()
|
||||
if ( !IsValid( ent ) ) then return end
|
||||
|
||||
-- Don't allow removal of players or objects that cannot be physically targeted by properties
|
||||
if ( !properties.CanBeTargeted( ent, ply ) ) then return end
|
||||
if ( !self:Filter( ent, ply ) ) then return end
|
||||
|
||||
-- Remove all constraints (this stops ropes from hanging around)
|
||||
constraint.RemoveAll( ent )
|
||||
|
||||
-- Remove it properly in 1 second
|
||||
timer.Simple( 1, function() if ( IsValid( ent ) ) then ent:Remove() end end )
|
||||
|
||||
-- Make it non solid
|
||||
ent:SetNotSolid( true )
|
||||
ent:SetMoveType( MOVETYPE_NONE )
|
||||
ent:SetNoDraw( true )
|
||||
|
||||
-- Send Effect
|
||||
local ed = EffectData()
|
||||
ed:SetEntity( ent )
|
||||
util.Effect( "entity_remove", ed, true, true )
|
||||
|
||||
ply:SendLua( "achievements.Remover()" )
|
||||
|
||||
end
|
||||
|
||||
} )
|
||||
Reference in New Issue
Block a user