Garry's Mod Wiki

properties.Add

properties.Add( string name, table propertyData )

Description

Add properties to the properties module

Arguments

1 string name
A unique name used to identify the property
2 table propertyData
A table that defines the property. Uses the Structures/PropertyAdd.

Example

Defines a property that can be used to ignite entities (from Sandbox)

properties.Add( "ignite", { MenuLabel = "#ignite", -- Name to display on the context menu Order = 999, -- The order to display this property relative to other properties MenuIcon = "icon16/fire.png", -- The icon to display next to the property Filter = function( self, ent, ply ) -- A function that determines whether an entity is valid for this property if ( !IsValid( ent ) ) then return false end if ( ent:IsPlayer() ) then return false end if ( !CanEntityBeSetOnFire( ent ) ) then return false end if ( !gamemode.Call( "CanProperty", ply, "ignite", ent ) ) then return false end return !ent:IsOnFire() end, Action = function( self, ent ) -- The action to perform upon using the property ( Clientside ) self:MsgStart() net.WriteEntity( ent ) self:MsgEnd() end, Receive = function( self, length, player ) -- The action to perform upon using the property ( Serverside ) local ent = net.ReadEntity() if ( !self:Filter( ent, player ) ) then return end ent:Ignite( 360 ) end } )

Page Links


Special Pages


Wikis

?

Render Time: 31ms

DB GetPage 3
Generate Html 5
SaveChanges (1) 8
Render Body 0
Render Sidebar 12