Garry's Mod Wiki

PropertyAdd

Description

Structure used for properties.Add.

Parameters

Type [string]

Can be set to "toggle" to make this property a toggle property.

Default: "simple"

MenuLabel [string]

Label to show on opened menu

MenuIcon [string]

Icon to show on opened menu for this item. Optional for simple properties and unused for toggle properties.

StructureField (Order) [number]

Where in the list should the property be positioned, relative to other properties.

For reference, here are the default properties and their Order values:

Property Order
Bone Manipulate 500
Bodygroups 600
Skin 601
Keep Upright 900
Ignite/Extinguish 999
Remove 1000
Gravity 1001
Drive 1100
Collision 1500
Statue 1501
NPC Biggify/Smallify 1799, 1800
Motion Control (Kinect) 2500
Edit Properties 90001

PrependSpacer [boolean]

Whether to add a spacer before this property. This should generally be true for the first property in a group of properties.

Default: false

Filter [function]

Used clientside to decide whether this property should be shown for an entity. Gets these arguments:

  • table self - the property table
  • Entity ent - the entity the player clicked

Return true if the property should be shown for this entity. It's good practice to call SANDBOX:CanProperty in this hook via gamemode.Call or hook.Run.

Checked [function]

Required for toggle properties (clientside). Must return a boolean value to either check or uncheck the toggle property.

  • table self - the property table
  • Entity ent - the entity the player clicked
  • table tr - the player's eye trace

Action [function]

Called clientside when the property is clicked with these arguments:

  • table self - the property table
  • Entity ent - the entity the player clicked
  • table tr - the player's eye trace

When appropriate, within this function you can call self:MsgStart(), write data with the net 'Write' functions, and finish with self:MsgEnd(). This will activate the 'Receive' function on the server. In most cases, you will want to send the entity to the server, as it's not done by default.

Receive [function]

Called serverside if the client sends a message in the 'Action' function (see above).

  • table self - the property table
  • number len - the net message length, although this includes the property identifier used internally (the name of the property)
  • Player ply - the player who clicked the property

You can read data received from the client with the net 'Read' functions. It's good practice to check SANDBOX:CanProperty here via gamemode.Call or hook.Run.

MenuOpen [function]

Called clientside when the property option has been created in the right-click menu. This is not called for toggle properties!

  • table self - the property table
  • DMenuOption option - the menu option
  • Entity ent - the entity the player right-clicked
  • table tr - the player's eye trace

OnCreate [function]

Same as MenuOpen, but also called for toggle properties and has different arguments. This is called immediately after MenuOpen, but nothing happens in between so you should only ever use one or the other.

Page Links


Special Pages


Wikis

?

Render Time: 79ms

DB GetPage 4
Generate Html 45
SaveChanges (1) 14
Render Body 0
Render Sidebar 12