RemovePlayerItem: Difference between revisions
Complete Lua function catalog |
Release 0.1.9 / BUILD264 / Protocol42: availability and download setup; preserve experimental limits |
||
| (One intermediate revision by the same user not shown) | |||
| Line 38: | Line 38: | ||
[[Category:Player Functions]] | [[Category:Player Functions]] | ||
[[Category:Inventory Functions]] | [[Category:Inventory Functions]] | ||
<!-- customkeys019:start --> | |||
'''Available from 0.1.9. Use matching updated server and clients.''' | |||
== Registered custom keys == | |||
This existing API also accepts the canonical item string from [[registerKeyDefinition]] in 0.1.9. Server registration, active definition and appropriate presentation readiness are required for mutations; use [[isPlayerKeyDefinitionReady]]. Do not pass the donor model alias as the custom item identity. Existing call shapes and limits remain; [[spawnItem]] creates one world item per call, whereas give/remove counts can manage copies. See [[Custom keys]] for safe server-side issuance, drop, pickup and persistence. | |||
<!-- customkeys019:end --> | |||
Latest revision as of 13:29, 20 October 2026
removePlayerItem
Removes a known item from a player's authoritative inventory.
Syntax
bool removePlayerItem(int playerId, string itemKey [, int quantity = 1])
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
playerId |
int |
yes | The connected player identifier. |
itemKey |
string |
yes | A rune, armor, or melee weapon key from the server catalog. |
quantity |
int |
no | Number of items to remove, from 1 to 1000; defaults to 1. |
Returns
Returns true when the complete quantity can be removed and the change is replicated; otherwise returns false.
Examples
Consume one item only when the player owns it:
if hasPlayerItem(playerId, "light") then
removePlayerItem(playerId, "light", 1)
end
Notes
- Available only in server-side resource scripts.
- The operation is rejected rather than allowing the inventory quantity to become negative.
Available from 0.1.9. Use matching updated server and clients.
Registered custom keys
This existing API also accepts the canonical item string from registerKeyDefinition in 0.1.9. Server registration, active definition and appropriate presentation readiness are required for mutations; use isPlayerKeyDefinitionReady. Do not pass the donor model alias as the custom item identity. Existing call shapes and limits remain; spawnItem creates one world item per call, whereas give/remove counts can manage copies. See Custom keys for safe server-side issuance, drop, pickup and persistence.