Hooks called by Pickup Objects

Summary

Hooks

Lets plugins change the heaviest object a player can carry, for example with the strength of their character.
Asks whether a player may start dragging a ragdoll.
Called on the server when a player drops the object they carry or drag.
Asks whether a player may pick up an object with their hands.
Asks whether a player may throw the object they hold, and lets plugins change the throw.

Hooks

AdjustPickupMassLimit(actor, ent, info)

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

Lets plugins change the heaviest object a player can carry, for example with the strength of their character. Called on the server when the plugin's own PlayerPickupObject handler compares the mass of an object with the limit, and by PickupObjects:get_mass_limit. Every handler may change the table, so a handler should return nothing to let the others run. Dragged ragdolls have no mass limit.

Parameters

  • actor Player the player picking the object up
  • ent Entity the object, nil if the limit is asked for no object in particular
  • info Map modified in place: limit (Number the mass limit, the pickup_max_mass config to begin with)

Called from

Call sites

PlayerCanDragRagdoll(actor, ent, owner)

server plugins/pickup_objects/plugin/sv_plugin.lua:306

Asks whether a player may start dragging a ragdoll. Called on the server when the player tries to pick up a ragdoll within reach while the pickup_drag_ragdolls config is on, before PlayerPickupObject. The plugin's own handler denies it while the player the ragdoll belongs to is getting up.

Parameters

  • actor Player The player who is about to drag the ragdoll
  • ragdoll Entity The ragdoll
  • target Player The player whose ragdoll it is, fallen over or dead; nil for a corpse left behind by a player who has respawned and for any other ragdoll

Returns

  • Boolean Return false to prevent the dragging

Called from

Call sites

PlayerDropObject(actor, data.entity)

server plugins/pickup_objects/plugin/sv_plugin.lua:345

Called on the server when a player drops the object they carry or drag. It is run once per drop: before a drop or a throw the player asks for, which a handler can prevent, or once the object is found to be no longer held for any other reason; what handlers return is ignored then.

Parameters

  • actor Player The player holding the object; may no longer be valid if they have disconnected
  • ent Entity The object being dropped

Returns

  • Boolean Return false to keep the player from dropping the object

Called from

Call sites

PlayerPickupObject(actor, ent, drag)

server plugins/pickup_objects/plugin/sv_plugin.lua:320

Asks whether a player may pick up an object with their hands. Called on the server when the player tries to pick up the entity they are looking at and it is close enough. The plugin's own handler denies pickups during the cooldown of the player and, for objects that are carried, anything that is not a movable physics object or weighs more than the mass limit of the player (see AdjustPickupMassLimit). A handler that returns true lets the player pick up what the plugin would deny.

Parameters

  • actor Player The player picking the object up
  • ent Entity The object being picked up
  • drag Boolean True if the object is a ragdoll that is going to be dragged, false if it is going to be carried

Returns

  • Boolean Return false to prevent the pickup

Called from

Call sites

PlayerThrowObject(actor, ent, info)

server plugins/pickup_objects/plugin/sv_plugin.lua:383

Asks whether a player may throw the object they hold, and lets plugins change the throw. Called on the server when the player presses primary attack while holding an object, before PlayerDropObject. Nothing happens if the throw is prevented or its force is not positive: the player keeps holding the object.

Parameters

  • actor Player The player throwing the object
  • ent Entity The object being thrown
  • info Map Modified in place: force (Number the pickup_throw_force config to begin with, before it is scaled with the mass of the object) and direction (Vector the aim vector of the player)

Returns

  • Boolean Return false to prevent the throw

Called from

Call sites

Defined in