Files
wnsrc/lua/autorun/properties/collisions.lua
lifestorm 9c918c46e5 Upload
2024-08-04 23:12:27 +03:00

84 lines
1.8 KiB
Lua

--[[
| 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( "collision_off", {
MenuLabel = "#collision_off",
Order = 1500,
MenuIcon = "icon16/collision_off.png",
Filter = function( self, ent, ply )
if ( !IsValid( ent ) ) then return false end
if ( ent:IsPlayer() ) then return false end
if ( !gamemode.Call( "CanProperty", ply, "collision", ent ) ) then return false end
if ( ent:GetCollisionGroup() == COLLISION_GROUP_WORLD ) then return false end
return true
end,
Action = function( self, ent )
self:MsgStart()
net.WriteEntity( ent )
self:MsgEnd()
end,
Receive = function( self, length, ply )
local ent = net.ReadEntity()
if ( !properties.CanBeTargeted( ent, ply ) ) then return end
if ( !self:Filter( ent, ply ) ) then return end
ent:SetCollisionGroup( COLLISION_GROUP_WORLD )
end
} )
properties.Add( "collision_on", {
MenuLabel = "#collision_on",
Order = 1500,
MenuIcon = "icon16/collision_on.png",
Filter = function( self, ent, ply )
if ( !IsValid( ent ) ) then return false end
if ( ent:IsPlayer() ) then return false end
if ( !gamemode.Call( "CanProperty", ply, "collision", ent ) ) then return false end
return ent:GetCollisionGroup() == COLLISION_GROUP_WORLD
end,
Action = function( self, ent )
self:MsgStart()
net.WriteEntity( ent )
self:MsgEnd()
end,
Receive = function( self, length, ply )
local ent = net.ReadEntity()
if ( !properties.CanBeTargeted( ent, ply ) ) then return end
if ( !self:Filter( ent, ply ) ) then return end
ent:SetCollisionGroup( COLLISION_GROUP_NONE )
end
} )