HasPlayerItem: Difference between revisions
Jump to navigation
Jump to search
Automatyczna aktualizacja dokumentacji funkcji |
Complete Lua function catalog |
||
| Line 31: | Line 31: | ||
* Available only in server-side resource scripts. | * Available only in server-side resource scripts. | ||
[[Category:Lua Functions]] | |||
[[Category:Server Functions]] | [[Category:Server Functions]] | ||
[[Category:Player Functions]] | [[Category:Player Functions]] | ||
[[Category:Inventory Functions]] | [[Category:Inventory Functions]] | ||
Revision as of 09:54, 15 August 2026
hasPlayerItem
Checks whether a player owns at least one copy of a known inventory item.
Syntax
bool hasPlayerItem(int playerId, string itemKey)
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. |
Returns
Returns true when the authoritative quantity is greater than zero; otherwise returns false.
Examples
Equip a sword only when it is present in the inventory:
if hasPlayerItem(playerId, "1h_sword_01") then
setPlayerWeapon(playerId, "1h_sword_01")
end
Notes
- Available only in server-side resource scripts.