GivePlayerItem: 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 35: Line 35:
* The resulting total may not be negative or exceed 100000 items.
* The resulting total may not be negative or exceed 100000 items.


[[Category:Lua Functions]]
[[Category:Server Functions]]
[[Category:Server Functions]]
[[Category:Player Functions]]
[[Category:Player Functions]]
[[Category:Inventory Functions]]
[[Category:Inventory Functions]]

Latest revision as of 09:53, 15 August 2026

givePlayerItem

Adds a known item to a player's authoritative inventory.

Syntax

bool givePlayerItem(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 add, from 1 to 1000; defaults to 1.

Returns

Returns true when the inventory change is validated, replicated, and applied by the server; otherwise returns false.

Examples

Give a player one sword and equip it:

if givePlayerItem(playerId, "1h_sword_01") then
    setPlayerWeapon(playerId, "1h_sword_01")
end

Notes

  • Available only in server-side resource scripts.
  • Preferred descriptive inventory function.
  • The resulting total may not be negative or exceed 100000 items.