Skip to content

OnPlayerPickup

The player picked a pickup up - return false to take it back.

The player’s client already holds the item when this runs. The server first checks the claim against its own record of the pickup: it must still be there, in the player’s view and in their world, within about eight metres of them, and nobody may have taken it first - a claim that fails any of these (or that the mode refuses here) has its item taken out of the player’s game at once, in every [audit] mode. Return false and the item goes back the same way and the pickup stays in the world for everyone. Otherwise the pickup is gone for everyone and the item is the player’s - the item check counts it as explained. A mode that refuses the pickup to give the item itself reads GetPickupHealth and GetPickupQuality first and passes both to GivePlayerItem, or the item comes new and at its class’s own quality.

function OnPlayerPickup(pid, id)
-- ...
end
Parameter Type
pid number the player
id number the pickup entity (GetEntityTemplate is its class GUID)

false refuses the pickup; anything else lets them keep it

function OnPlayerPickup(pid, id)
if GetEntityData(id, "owner") and GetEntityData(id, "owner") ~= pid then
SendClientMessage(pid, COLOR_RED, "That is not yours.")
return false
end
return true
end

OnPlayerDrop · CreatePickup · GetEntityTemplate · the Items and inventory group of the index