Prop Protection makes every entity a player spawns the property of the character that spawned it, and builds the sandbox rules on that ownership. Without the plugin the physics gun, the tool gun and the context menu are checked against permissions only: whoever holds the permission may pick up or change anything. With it a player may pick up, freeze, unfreeze, drive and use tools and properties on the entities of their own character, whether or not they hold the physgun_pickup and physgun_freeze permissions, and on nothing else. What stands in the way is one of the rules listed below, each of which is switched by a config of its own and is waived for staff with the bypass_prop_protection permission (physgun_pickup waives the rules for the physics gun as well, and physgun_freeze those for freezing). Plugins overrule a single decision with the PlayerCanManipulateEntity hook.

An entity is owned under a key made of the SteamID64 of the player and the ID of their active character, which is networked to everyone in the fl_prop_owner variable of the entity. When the owner disconnects or switches characters, their entities stay protected and are removed after the prop_removal_delay config, unless the owner comes back on that character in time. Static entities are never removed that way; they are released instead. The entities of staff who are exempt from the rules stay where they are, unless the remove_staff_entities config says otherwise.

The plugin also keeps players from being hurt by props that are held with the physics gun, have just been dropped by it or have just been spawned (prop_kill_protection). Addons that speak the Common Prop Protection Interface find the CPPI table and the CPPI entity and player methods in lib/meta/sh_entity.lua.

Rules and the configs that switch them:

players  - physgun_protect_players  - players cannot be picked up with the physics gun
vehicles - physgun_protect_vehicles - neither can vehicles that have a driver
ragdolls - physgun_protect_ragdolls - nor the ragdolls of players
owned    - prop_protection          - the entity belongs to another character
map      - protect_map_entities     - the entity was created by the map
world    - protect_world_entities   - the entity belongs to nobody (items, players, ...)

The first three concern the physics gun only and are checked first. Switching one of them off does not hand the entity over: the last three, which are about ownership, still apply to it.

Summary

Hooks

Refuses to let a player drive an entity without the context_menu permission, or an entity that the rules protect from them.
Refuses to let a player unfreeze an entity that the rules protect from them.
Refuses the properties of the context menu to players without the context_menu permission, which the gamemode only checks when the menu is opened on the client, and on entities that the rules protect from the player.
Refuses the use of a Sandbox tool on an entity that the rules protect from the player, and of the right click of the remover when anything constrained to the entity is protected.
Draws the owner of the entity that the local player is looking at above its target ID: a note on their own entities, and the name of the owner on those of others.
Forgets what the plugin kept about an entity that is being removed.
Blocks the impact damage a player would take from a harmless entity (one that is held with the physics gun, or was spawned or dropped by it a moment ago) while the prop_kill_protection config is on, and from being pushed into the world by one.
Starts the removal countdown for the entities of the character a player drops.
Hands the entities of a character back to the player who has loaded it.
Starts the removal countdown for the entities of the character a player switches away from.
Refuses to let a player freeze an entity that the rules protect from them.
Remembers who holds an entity with the physics gun, so that it cannot hurt players while it is held.
Forgets who held an entity that the physics gun has let go of and keeps the entity harmless to players for a while, so that it cannot be thrown at them.
Refuses to let a player pick up an entity that the rules protect from them.
Lets a player without the physgun_freeze permission freeze an entity that the rules allow them, which is what lets players freeze their own entities.
Lets a player without the physgun_pickup permission pick up an entity that the rules allow them, which is what makes their own entities movable.
Starts the removal countdown for the entities of a player who disconnects.
Hands the entities that a player owned without a character back to them when they reconnect, which is all there is to return on a server without the Characters plugin.
Makes the effect a player has spawned theirs.
Makes the NPC a player has spawned theirs.
Makes the prop a player has spawned theirs.
Makes the ragdoll a player has spawned theirs.
Makes the scripted entity a player has spawned theirs.
Makes the vehicle a player has spawned theirs.
Registers the setting that shows or hides the owner line of entities.
Registers the 'bypass_prop_protection' permission.

Methods

Starts the removal countdown for the entities of a player's active character, as the plugin does when the player disconnects or switches to another character.
Checks whether the rules do not apply to a player: they hold the bypass_prop_protection permission, or the permission that Flux already ties to the action (physgun_pickup for the physics gun, physgun_freeze for freezing).
Decides whether a player may do something to an entity.
Checks whether a player may do something to every entity that is constrained to an entity, such as the parts of a contraption that the remover is about to delete together.
Handles an entity that a player has just created: gives it to their active character and makes it harmless to players for a while.
Finds the connected player who currently plays the character behind an ownership key.
Finds the first rule that stands between a player and an entity for an action, regardless of whether the rule is switched on and of the permissions of the player.
Forgets what the plugin keeps about an entity that is being removed: its place in the index of owned entities and the player who holds it with the physics gun.
Returns the key that entities are owned under by the active character of a player: the SteamID64 of the player and the ID of the character, which is 0 when the Characters plugin is not loaded or no character is active.
Returns the entities that are owned under a key.
Makes an entity the property of the active character of a player, taking it from its previous owner.
Checks whether an entity is one whose impacts players are protected from: it is held with the physics gun or carried by a player, or it has been spawned or dropped by the physics gun within the prop_kill_protection_time config.
Checks whether an entity was created by the map.
Checks whether an entity is the ragdoll of a player, as created by the Ragdoll plugin for players who are dead or knocked down.
Makes an entity harmless to players for the time of the prop_kill_protection_time config, counted from now.
Tells a player why they may not touch an entity, at most once a second.
Removes the entities owned under a key, unless the owner is connected on that character.
Stops the removal of the entities of a player's active character, which is how they get their entities back when they reconnect or switch back to the character in time.
Starts the countdown after which the entities owned under a key are removed.
Makes an entity the property of nobody.

Hooks

PropProtection:CanDrive(actor, entity)

shared plugins/propprotection/plugin/sh_plugin.lua:360

Refuses to let a player drive an entity without the context_menu permission, or an entity that the rules protect from them.

Parameters

  • actor Player
  • entity Entity the entity the player wants to drive

Returns

  • Boolean false to refuse, nothing otherwise

PropProtection:CanPlayerUnfreeze(actor, entity, _phys_obj)

server plugins/propprotection/plugin/sv_hooks.lua:43

Refuses to let a player unfreeze an entity that the rules protect from them.

Parameters

  • actor Player
  • entity Entity the frozen entity
  • _phys_obj PhysObj the physics object that is being unfrozen

Returns

  • Boolean false to refuse, nothing otherwise

PropProtection:CanProperty(actor, property, entity)

shared plugins/propprotection/plugin/sh_plugin.lua:337

Refuses the properties of the context menu to players without the context_menu permission, which the gamemode only checks when the menu is opened on the client, and on entities that the rules protect from the player.

Parameters

  • actor Player
  • property String property name
  • entity Entity the entity the property is used on

Returns

  • Boolean false to refuse the property, nothing otherwise

PropProtection:CanTool(actor, trace, tool_name, _tool, button)

shared plugins/propprotection/plugin/sh_plugin.lua:304

Refuses the use of a Sandbox tool on an entity that the rules protect from the player, and of the right click of the remover when anything constrained to the entity is protected. The Flux tools that are tied to a permission of their own are not checked: that permission is what guards them.

Parameters

  • actor Player
  • trace Map trace result of the tool use
  • tool_name String tool ID
  • _tool Map tool object
  • button Number 1 for the primary attack, 2 for the secondary one, 3 for reload

Returns

  • Boolean false to block the tool, nothing otherwise

PropProtection:DrawEntityTargetID(entity, x, y, dist)

client plugins/propprotection/plugin/cl_hooks.lua:48

Implements hook DrawEntityTargetID

Draws the owner of the entity that the local player is looking at above its target ID: a note on their own entities, and the name of the owner on those of others. The line can be switched off with the 'show_prop_owners' client setting. Other players' entities only show their owner if the prop_owner_display config is on or the local player is exempt from prop protection.

Parameters

  • entity Entity
  • x Number screen x of the horizontal center of the target ID
  • y Number screen y of the first line of the target ID
  • dist Number distance between the local player and the entity

PropProtection:EntityRemoved(entity)

server plugins/propprotection/plugin/sv_hooks.lua:157

Forgets what the plugin kept about an entity that is being removed.

Parameters

  • entity Entity

PropProtection:EntityTakeDamage(target, damage_info)

server plugins/propprotection/plugin/sv_hooks.lua:123

Blocks the impact damage a player would take from a harmless entity (one that is held with the physics gun, or was spawned or dropped by it a moment ago) while the prop_kill_protection config is on, and from being pushed into the world by one.

Parameters

  • target Entity the entity that is taking damage
  • damage_info CTakeDamageInfo

Returns

  • Boolean true to block the damage, nothing otherwise

PropProtection:OnActiveCharacterCleared(owner, _character)

server plugins/propprotection/plugin/sv_hooks.lua:190

Implements hook OnActiveCharacterCleared

Starts the removal countdown for the entities of the character a player drops.

Parameters

  • owner Player
  • _character Character the character that is being dropped

PropProtection:OnActiveCharacterSet(owner, _character)

server plugins/propprotection/plugin/sv_hooks.lua:183

Implements hook OnActiveCharacterSet

Hands the entities of a character back to the player who has loaded it.

Parameters

  • owner Player
  • _character Character the character that is now active

PropProtection:OnCharacterChange(owner, new_char, old_char)

server plugins/propprotection/plugin/sv_hooks.lua:172

Implements hook OnCharacterChange

Starts the removal countdown for the entities of the character a player switches away from. Nothing happens when the player selects the character that is already active.

Parameters

  • owner Player
  • new_char Character the character that is about to become active
  • old_char Character the character that is still active

PropProtection:OnPhysgunFreeze(_weapon, _phys_obj, entity, actor)

server plugins/propprotection/plugin/sv_hooks.lua:16

Refuses to let a player freeze an entity that the rules protect from them. Nothing is returned for everything else, so that the handlers of other plugins may still refuse and the gamemode does the freezing.

Parameters

  • _weapon Weapon the physics gun
  • _phys_obj PhysObj the physics object that is being frozen
  • entity Entity the entity the physics object belongs to
  • actor Player the player who is trying to freeze it

Returns

  • Boolean false to refuse, nothing otherwise

PropProtection:OnPhysgunPickup(actor, entity)

server plugins/propprotection/plugin/sv_hooks.lua:55

Remembers who holds an entity with the physics gun, so that it cannot hurt players while it is held.

Parameters

  • actor Player the player who has picked the entity up
  • entity Entity

PropProtection:PhysgunDrop(_actor, entity)

server plugins/propprotection/plugin/sv_hooks.lua:65

Forgets who held an entity that the physics gun has let go of and keeps the entity harmless to players for a while, so that it cannot be thrown at them.

Parameters

  • _actor Player the player who has dropped the entity
  • entity Entity

PropProtection:PhysgunPickup(actor, entity)

shared plugins/propprotection/plugin/sh_plugin.lua:272

Refuses to let a player pick up an entity that the rules protect from them. Nothing is returned for everything else, so that the handlers of other plugins may still refuse.

Parameters

  • actor Player
  • entity Entity the entity that is being picked up

Returns

  • Boolean false to refuse, nothing otherwise

PropProtection:PlayerCanPhysgunFreeze(actor, entity)

server plugins/propprotection/plugin/sv_hooks.lua:30

Implements hook PlayerCanPhysgunFreeze

Lets a player without the physgun_freeze permission freeze an entity that the rules allow them, which is what lets players freeze their own entities. Entities that forbid the physics gun themselves are left alone.

Parameters

  • actor Player the player who is trying to freeze the entity
  • entity Entity the entity that is being frozen

Returns

  • Boolean true to allow the freeze, nothing otherwise

PropProtection:PlayerCanPhysgunPickup(actor, entity)

shared plugins/propprotection/plugin/sh_plugin.lua:286

Implements hook PlayerCanPhysgunPickup

Lets a player without the physgun_pickup permission pick up an entity that the rules allow them, which is what makes their own entities movable. Entities that forbid the physics gun themselves are left alone.

Parameters

  • actor Player
  • entity Entity the entity that is being picked up

Returns

  • Boolean true to allow the pickup, nothing otherwise

PropProtection:PlayerDisconnected(actor)

server plugins/propprotection/plugin/sv_hooks.lua:163

Implements hook PlayerDisconnected

Starts the removal countdown for the entities of a player who disconnects.

Parameters

  • actor Player

PropProtection:PlayerInitialized(actor)

server plugins/propprotection/plugin/sv_hooks.lua:199

Implements hook PlayerInitialized

Hands the entities that a player owned without a character back to them when they reconnect, which is all there is to return on a server without the Characters plugin. Done once their client has finished loading, so that the notification reaches it; until then the entities are safe because their owner is connected.

Parameters

  • actor Player

PropProtection:PlayerSpawnedEffect(actor, _model, entity)

server plugins/propprotection/plugin/sv_hooks.lua:92

Makes the effect a player has spawned theirs.

Parameters

  • actor Player
  • _model String model of the effect
  • entity Entity the effect

PropProtection:PlayerSpawnedNPC(actor, entity)

server plugins/propprotection/plugin/sv_hooks.lua:113

Makes the NPC a player has spawned theirs.

Parameters

  • actor Player
  • entity Entity the NPC

PropProtection:PlayerSpawnedProp(actor, _model, entity)

server plugins/propprotection/plugin/sv_hooks.lua:76

Makes the prop a player has spawned theirs.

Parameters

  • actor Player
  • _model String model of the prop
  • entity Entity the prop

PropProtection:PlayerSpawnedRagdoll(actor, _model, entity)

server plugins/propprotection/plugin/sv_hooks.lua:84

Makes the ragdoll a player has spawned theirs.

Parameters

  • actor Player
  • _model String model of the ragdoll
  • entity Entity the ragdoll

PropProtection:PlayerSpawnedSENT(actor, entity)

server plugins/propprotection/plugin/sv_hooks.lua:106

Makes the scripted entity a player has spawned theirs.

Parameters

  • actor Player
  • entity Entity

PropProtection:PlayerSpawnedVehicle(actor, entity)

server plugins/propprotection/plugin/sv_hooks.lua:99

Makes the vehicle a player has spawned theirs.

Parameters

  • actor Player
  • entity Entity the vehicle

PropProtection:RegisterClientSettings()

client plugins/propprotection/plugin/cl_hooks.lua:29

Implements hook RegisterClientSettings

Registers the setting that shows or hides the owner line of entities.

PropProtection:RegisterPermissions()

shared plugins/propprotection/plugin/sh_plugin.lua:379

Implements hook RegisterPermissions

Registers the 'bypass_prop_protection' permission.

Methods

PropProtection:abandon_entities(actor)

server plugins/propprotection/plugin/sv_plugin.lua:187

Starts the removal countdown for the entities of a player's active character, as the plugin does when the player disconnects or switches to another character. The entities of players who are exempt from the rules are left alone unless the remove_staff_entities config is on.

Parameters

  • actor Player

Returns

  • Boolean whether the countdown has been started

See also

PropProtection:can_bypass(actor, action)

shared plugins/propprotection/plugin/sh_plugin.lua:197

Checks whether the rules do not apply to a player: they hold the bypass_prop_protection permission, or the permission that Flux already ties to the action (physgun_pickup for the physics gun, physgun_freeze for freezing).

Parameters

  • actor Player
  • action String optional, defaults to nil action that is being checked, see PropProtection:find_rule

Returns

  • Boolean

PropProtection:can_manipulate(actor, entity, action, detail)

shared plugins/propprotection/plugin/sh_plugin.lua:225

Decides whether a player may do something to an entity. The world and invalid entities are never protected.

if !PropProtection:can_manipulate(actor, entity, 'tool', 'my_tool') then
  return false
end

Parameters

  • actor Player
  • entity Entity
  • action String 'physgun', 'freeze', 'unfreeze', 'tool', 'property' or 'drive'; plugins may pass names of their own, which are checked like 'tool'
  • detail String optional, defaults to nil what the action is done with: the tool ID or the property name

Returns

  • Boolean whether the action is allowed
  • String ID of the rule that refuses it (nil if it is allowed or was refused by the PlayerCanManipulateEntity hook alone)

PropProtection:can_manipulate_constrained(actor, entity, action, detail)

server plugins/propprotection/plugin/sv_plugin.lua:280

Checks whether a player may do something to every entity that is constrained to an entity, such as the parts of a contraption that the remover is about to delete together.

Parameters

  • actor Player
  • entity Entity
  • action String see PropProtection:can_manipulate
  • detail String optional, defaults to nil the tool ID or the property name

Returns

  • Boolean whether the action is allowed for all of them
  • String ID of the rule that refuses it

PropProtection:entity_spawned(actor, entity)

server plugins/propprotection/plugin/sv_plugin.lua:172

Handles an entity that a player has just created: gives it to their active character and makes it harmless to players for a while. The plugin calls it for everything that comes out of the spawn menu and for everything Sandbox adds to the cleanup list of a player, which covers what the tools create. Call it for entities that a player creates in any other way.

Parameters

  • actor Player the player who created the entity
  • entity Entity

Returns

  • Boolean whether the entity is now owned by the active character of the player

PropProtection:find_owner(key)

shared plugins/propprotection/plugin/sh_plugin.lua:94

Finds the connected player who currently plays the character behind an ownership key. On the client the answer is kept for half a second, as the lookup walks every player and is asked for every frame while an owned entity is looked at; the server always looks.

Parameters

  • key String ownership key, see PropProtection:get_key

Returns

  • Player the owner, or nil if they are not connected or play another character

PropProtection:find_rule(actor, entity, action)

shared plugins/propprotection/plugin/sh_plugin.lua:187

Finds the first rule that stands between a player and an entity for an action, regardless of whether the rule is switched on and of the permissions of the player. The rules of the physics gun come before those of ownership; PropProtection:can_manipulate goes on to the ownership rule when the physics gun rule it has found is switched off.

Parameters

  • actor Player
  • entity Entity a valid entity
  • action String 'physgun', 'freeze', 'unfreeze', 'tool', 'property' or 'drive'

Returns

  • String rule ID ('players', 'vehicles', 'ragdolls', 'owned', 'map' or 'world'); nil if the entity belongs to the active character of the player and no other rule applies

PropProtection:forget_entity(entity)

server plugins/propprotection/plugin/sv_plugin.lua:137

Forgets what the plugin keeps about an entity that is being removed: its place in the index of owned entities and the player who holds it with the physics gun.

Parameters

  • entity Entity

PropProtection:get_key(target)

shared plugins/propprotection/plugin/sh_plugin.lua:79

Returns the key that entities are owned under by the active character of a player: the SteamID64 of the player and the ID of the character, which is 0 when the Characters plugin is not loaded or no character is active.

Parameters

  • target Player

Returns

  • String ownership key, such as '76561198000000000:12'; nil if the SteamID64 of the player is not known, which is the case for bots on the client

PropProtection:get_owned_entities(key)

server plugins/propprotection/plugin/sv_plugin.lua:150

Returns the entities that are owned under a key.

Parameters

  • key String ownership key, see PropProtection:get_key

Returns

  • List<Entity>

PropProtection:give_ownership(actor, entity, permanent)

server plugins/propprotection/plugin/sv_plugin.lua:61

Makes an entity the property of the active character of a player, taking it from its previous owner. Players, weapons and entities that are not networked cannot be owned. Runs the PlayerCanOwnEntity hook before and the EntityOwnershipGiven hook after a change of the owner; giving an entity to the character that already owns it changes nothing but the permanent flag.

PropProtection:give_ownership(actor, entity)

Parameters

  • actor Player the new owner
  • entity Entity
  • permanent Boolean optional, defaults to nil true to keep the entity when its owner leaves, false to remove it like any other; the current setting is kept when nil

Returns

  • Boolean whether the entity is now owned by the active character of the player

PropProtection:is_harmless(entity)

server plugins/propprotection/plugin/sv_plugin.lua:324

Checks whether an entity is one whose impacts players are protected from: it is held with the physics gun or carried by a player, or it has been spawned or dropped by the physics gun within the prop_kill_protection_time config. Players, NPCs and weapons are never harmless, and a vehicle is only while it is held.

Parameters

  • entity Entity

Returns

  • Boolean

PropProtection:is_map_entity(entity)

shared plugins/propprotection/plugin/sh_plugin.lua:127

Checks whether an entity was created by the map. The answer comes from the engine, which always knows it on the server; a client that cannot tell treats the entity as not created by the map.

Parameters

  • entity Entity

Returns

  • Boolean

PropProtection:is_player_ragdoll(entity)

shared plugins/propprotection/plugin/sh_plugin.lua:136

Checks whether an entity is the ragdoll of a player, as created by the Ragdoll plugin for players who are dead or knocked down. Only the server knows which player a ragdoll belongs to.

Parameters

  • entity Entity

Returns

  • Boolean

PropProtection:mark_harmless(entity)

server plugins/propprotection/plugin/sv_plugin.lua:314

Makes an entity harmless to players for the time of the prop_kill_protection_time config, counted from now.

Parameters

  • entity Entity

PropProtection:notify_refusal(actor, rule)

server plugins/propprotection/plugin/sv_plugin.lua:297

Tells a player why they may not touch an entity, at most once a second.

Parameters

  • actor Player
  • rule String optional, defaults to nil ID of the rule that has refused the action

PropProtection:remove_abandoned(key)

server plugins/propprotection/plugin/sv_plugin.lua:214

Removes the entities owned under a key, unless the owner is connected on that character. Entities that were given as permanent stay owned. Static entities and those the ShouldRemoveAbandonedEntity hook keeps are released instead of removed, so that they belong to nobody from then on.

Parameters

  • key String ownership key, see PropProtection:get_key

PropProtection:return_ownership(actor)

server plugins/propprotection/plugin/sv_plugin.lua:248

Stops the removal of the entities of a player's active character, which is how they get their entities back when they reconnect or switch back to the character in time. Notifies the player and runs the PlayerEntitiesReturned hook if a removal was pending.

Parameters

  • actor Player

Returns

  • List<Entity> the entities of the active character of the player

PropProtection:schedule_removal(key)

server plugins/propprotection/plugin/sv_plugin.lua:197

Starts the countdown after which the entities owned under a key are removed. Does nothing if nothing is owned under the key or the prop_removal_delay config is 0.

Parameters

  • key String ownership key, see PropProtection:get_key

Returns

  • Boolean whether the countdown has been started

PropProtection:take_ownership(entity)

server plugins/propprotection/plugin/sv_plugin.lua:111

Makes an entity the property of nobody. Runs the EntityOwnershipTaken hook afterward.

Parameters

  • entity Entity

Returns

  • Boolean true if the entity had an owner

Defined in