SetPlayerArmor: Difference between revisions
Jump to navigation
Jump to search
Complete Lua function catalog |
Clarify player appearance API behavior |
||
| Line 39: | Line 39: | ||
* The player must own at least one copy of a non-empty item before it can be equipped. | * 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. | * The selected appearance is reliably synchronized and included in late-join state. | ||
* A named body preset visually displays its original outfit or armor; use <code>setPlayerBody(playerId, "default")</code> to show the independently equipped armor. | |||
[[Category:Lua Functions]] | [[Category:Lua Functions]] | ||
Revision as of 21:43, 15 August 2026
setPlayerArmor
Equips or clears a player's authoritative armor slot.
Syntax
bool setPlayerArmor(int playerId, string itemKey)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
playerId |
int |
yes | The connected player identifier. |
itemKey |
string |
yes | A key returned by getPlayerArmorNames, 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 armor slot:
local itemKey = "water_robe"
if givePlayerItem(playerId, itemKey) then
setPlayerArmor(playerId, itemKey)
end
Example 2
Clear the armor slot:
setPlayerArmor(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.
- A named body preset visually displays its original outfit or armor; use
setPlayerBody(playerId, "default")to show the independently equipped armor.