GetPlayerWeapon: Difference between revisions

From Wiki G1R-MP G1 Remake Multiplayer
Jump to navigation Jump to search
Automatyczna aktualizacja dokumentacji funkcji
 
Release 0.1.4 BUILD133 / Protocol 36 and document authenticated event origin
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
<!-- This page is generated automatically from the function definition: getPlayerWeapon. -->
= getPlayerWeapon =
= getPlayerWeapon =
Returns the stable key of the weapon equipped by a player.
'''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 ==
Returns the equipped weapon key, an empty string when the slot is clear, or <code>false</code> for an invalid player.
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.


== Examples ==
== Example ==
Read a player's equipped weapon:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua" line>
local itemKey = getPlayerWeapon(playerId)
local itemKey = getPlayerWeapon(playerId)
if itemKey and itemKey ~= "" then
if itemKey and itemKey ~= "" then
     outputDebugString("Equipped weapon: " .. itemKey)
     outputDebugString("Server weapon key: " .. itemKey)
end
end
</syntaxhighlight>
</syntaxhighlight>


== Notes ==
== Confirmed equipment since 0.1.4 ==
* Available only in server-side resource scripts.
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.
* Equipment state is server-authoritative and included in player synchronization.
 
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: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.