From Multi Theft Auto: Wiki
Jump to navigation Jump to search

This function sets a custom weapon's state.


bool setWeaponState ( weapon theWeapon, string theState )

OOP Syntax Help! I don't understand this!

Method: weapon:setState(...)
Variable: .state
Counterpart: getWeaponState

Required Arguments

  • theWeapon: the weapon you wish to set the state of.
  • theState: the state you wish to set:
    • reloading: makes the weapon reload.
    • firing: makes the weapon constantly fire its target (unless any shooting blocking flags are set) according to its assigned firing rate.
    • ready: makes the weapon stop reloading or firing.


Returns true on success, false otherwise.


addEventHandler("onClientResourceStart", resourceRoot,
            local wep = createWeapon("m4", 0, 0, 4)
            setWeaponState(wep, "firing")


Minimum supported server n/a
Minimum supported client 1.3.0-9.04555

Note: Using this function/event requires the resource to have the above minimum version declared in the meta.xml <min_mta_version> section. e.g. <min_mta_version client="1.3.0-9.04555" />

See also