getWeaponState | Multi Theft Auto: Wiki Skip to content

getWeaponState

Client-side
Server-side
Shared

Pair: setWeaponState

Manual Review Required

Please finish this page using the corresponding Old Wiki article. Go to Contribution guidelines for more information.


This function gets the state of a custom weapon.

OOP Syntax Help! I don't understand this!

  • Method: weapon:getState(...)
  • Variable: .state

Syntax

string getWeaponState ( weapon theWeapon )
Required Arguments
  • theWeapon: the weapon to get the state of.

Returns

  • string: value

This example creates a gun where the local player is and informs any player about its state.

Code Examples

shared

This example creates a gun where the local player is and informs any player about its state.

local function testWeaponState()
local weapon = createWeapon("m4", getElementPosition(localPlayer)) -- Create the weapon
outputChatBox("The weapon that has just been created state is " .. getWeaponState(weapon) .. ".") -- Tell the player its state
end
addEventHandler("onClientResourceStart", resourceRoot, testWeaponState)

See Also