SetPlayerWeapon: 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 40: Line 40:
* The selected appearance is reliably synchronized and included in late-join state.
* The selected appearance is reliably synchronized and included in late-join state.


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

Latest revision as of 09:55, 15 August 2026

setPlayerWeapon

Equips or clears a player's authoritative weapon slot.

Syntax

bool setPlayerWeapon(int playerId, string itemKey)

Parameters

Name Type Required Description
playerId int yes The connected player identifier.
itemKey string yes A key returned by getPlayerWeaponNames, or "none" to clear the slot.

Returns

Returns true when the equipment change is accepted and replicated; otherwise returns false.

Examples

Example 1

Give an item and equip it in the weapon slot:

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

Example 2

Clear the weapon slot:

setPlayerWeapon(playerId, "none")

Notes

  • Available only in server-side resource scripts.
  • The player must own at least one copy of a non-empty item before it can be equipped.
  • The selected appearance is reliably synchronized and included in late-join state.