GetPlayerWeapon: Difference between revisions
Complete Lua function catalog |
Release 0.1.4 BUILD133 / Protocol 36 and document authenticated event origin |
||
| (2 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
= getPlayerWeapon = | = getPlayerWeapon = | ||
Returns the | '''0.1.4 compatibility note: this existing server function remains a legacy single-key view. Use the new confirmation APIs for a native two-slot loadout.''' | ||
Returns the player's legacy server-side weapon key. It is not a direct read of both native equipment slots and must not be used as proof that an asynchronous weapon request completed. | |||
== Syntax == | == Syntax == | ||
| Line 16: | Line 17: | ||
== Returns == | == Returns == | ||
The legacy server-side weapon key, an empty string when that key is clear, or <code>false</code> for an invalid player. In 0.1.4, accepted requests and validated equipment observations can update this key; it does not represent both slots or a completion guarantee. | |||
== | == Example == | ||
<syntaxhighlight lang="lua"> | |||
<syntaxhighlight lang="lua" | |||
local itemKey = getPlayerWeapon(playerId) | local itemKey = getPlayerWeapon(playerId) | ||
if itemKey and itemKey ~= "" then | if itemKey and itemKey ~= "" then | ||
outputDebugString(" | outputDebugString("Server weapon key: " .. itemKey) | ||
end | end | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== | == Confirmed equipment since 0.1.4 == | ||
Use [[getPlayerWeaponState]] to inspect separate <code>melee</code> and <code>ranged</code> observations, their freshness and pending requests. Use [[onPlayerWeaponChangeResult]] to sequence dependent scripted changes. A failed request does not automatically roll back the legacy key. | |||
The updated server clears the persistent key after a validated successful <code>"none"</code> request, preventing earlier equipment observations from preserving the old weapon. This does not prevent later manual equipment changes. | |||
See [[Weapon control]] and [[setPlayerWeapon]]. | |||
[[Category:Lua Functions]] | [[Category:Lua Functions]] | ||
[[Category:Server Functions]] | [[Category:Server Functions]] | ||
[[Category:Player Functions]] | [[Category:Player Functions]] | ||
[[Category:Equipment Functions]] | [[Category:Equipment Functions]] | ||
Latest revision as of 20:40, 21 September 2026
getPlayerWeapon
0.1.4 compatibility note: this existing server function remains a legacy single-key view. Use the new confirmation APIs for a native two-slot loadout.
Returns the player's legacy server-side weapon key. It is not a direct read of both native equipment slots and must not be used as proof that an asynchronous weapon request completed.
Syntax
string|false getPlayerWeapon(int playerId)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
playerId |
int |
yes | The connected player identifier. |
Returns
The legacy server-side weapon key, an empty string when that key is clear, or false for an invalid player. In 0.1.4, accepted requests and validated equipment observations can update this key; it does not represent both slots or a completion guarantee.
Example
local itemKey = getPlayerWeapon(playerId)
if itemKey and itemKey ~= "" then
outputDebugString("Server weapon key: " .. itemKey)
end
Confirmed equipment since 0.1.4
Use getPlayerWeaponState to inspect separate melee and ranged observations, their freshness and pending requests. Use onPlayerWeaponChangeResult to sequence dependent scripted changes. A failed request does not automatically roll back the legacy key.
The updated server clears the persistent key after a validated successful "none" request, preventing earlier equipment observations from preserving the old weapon. This does not prevent later manual equipment changes.
See Weapon control and setPlayerWeapon.