GetPlayerItemCount: Difference between revisions

From Wiki G1R-MP G1 Remake Multiplayer
Jump to navigation Jump to search
Automatyczna aktualizacja dokumentacji funkcji
 
Complete Lua function catalog
Line 33: Line 33:
* Inventory is server-authoritative.
* Inventory is server-authoritative.


[[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:53, 15 August 2026

getPlayerItemCount

Returns the authoritative quantity of a known inventory item owned by a player.

Syntax

int|false getPlayerItemCount(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 the item quantity, including 0 when the player owns none, or false for an invalid player or item key.

Examples

Check how many copies of a sword a player owns:

local count = getPlayerItemCount(playerId, "1h_sword_01")
if count and count > 0 then
    outputChatBox("Sword available", playerId)
end

Notes

  • Available only in server-side resource scripts.
  • Inventory is server-authoritative.