SetWeaponState: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
Line 17: Line 17:
===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("ak", 0, 0, 4)
            setWeaponState(wep, "firing")
      end
)</syntaxhighlight>


==Requirements==
==Requirements==

Revision as of 11:17, 13 April 2015

Accessories-text-editor.png Script Example Missing Function SetWeaponState needs a script example, help out by writing one.

Before submitting check out Editing Guidelines Script Examples.

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("ak", 0, 0, 4)
            setWeaponState(wep, "firing")
      end
)

Requirements

This template will be deleted.

See also