SetWeaponState: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Client function}}
{{Client function}}
{{Needs_Example}}
This function sets a [[Element/Weapon|custom weapon]]'s state.
This function sets a [[Element/Weapon|custom weapon]]'s state.


Line 17: Line 16:
===Returns===
===Returns===
Returns ''true'' on success, ''false'' otherwise.
Returns ''true'' on success, ''false'' otherwise.
===Example===
<syntaxhighlight lang="lua">addEventHandler("onClientResourceStart", resourceRoot,
      function()
            local wep = createWeapon("m4", 0, 0, 4)
            setWeaponState(wep, "firing")
      end
)</syntaxhighlight>


==Requirements==
==Requirements==

Latest revision as of 19:39, 4 May 2015

This function sets a custom weapon's state.

Syntax

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

Returns true on success, false otherwise.

Example

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

Requirements

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

Note: Using this feature 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