GetPlayerWeaponState: Difference between revisions
Jump to navigation
Jump to search
Clarify 0.1.4 weapon clearing, manual equipment and confirmation APIs |
Release 0.1.4 BUILD133 / Protocol 36 and document authenticated event origin |
||
| Line 1: | Line 1: | ||
= getPlayerWeaponState = | = getPlayerWeaponState = | ||
'''Since 0.1.4 | '''Since 0.1.4. Requires a compatible client and server.''' | ||
Server function returning separate native melee/ranged observations and pending weapon requests. | Server function returning separate native melee/ranged observations and pending weapon requests. | ||
Latest revision as of 20:40, 21 September 2026
getPlayerWeaponState
Since 0.1.4. Requires a compatible client and server.
Server function returning separate native melee/ranged observations and pending weapon requests.
table|false getPlayerWeaponState(int playerId)
Returns false for an unavailable player; otherwise returns a table with:
supported: whether the client has sent the native weapon report.known: whether both native slots could be resolved. Unknown is not empty.fresh: a known observation no older than 3 seconds while alive.melee,ranged: observed catalog keys;""means an empty slot when the observation is known.pending: array of{requestId, itemKey}; a clear request uses"none".
This function observes inventory state, not global rendering completion. Empty slots can be observed even when a request later fails during carry-visual cleanup. For scripted completion, also await onPlayerWeaponChangeResult. Manual changes can make the current state differ from an earlier completed request.
local state = getPlayerWeaponState(playerId)
if state and state.known and state.fresh then
-- Save state.melee and state.ranged separately in your database.
end
See Weapon control for ownership, lifecycle, timeouts and clearing behavior.