GetPlayerWeapon
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.