SetWeaponState: Difference between revisions
Jump to navigation
Jump to search
(Created page with "__NOTOC__ {{Client function}} Sets a custom weapons state. ==Syntax== <syntaxhighlight lang="lua">bool setWeaponState ( weapon theWeapon, string theState )</syntaxhighlight> ===Required Arguments=== * '''...") |
Fernando187 (talk | contribs) (Remove obsolete Requirements section) |
||
(7 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Client function}} | {{Client function}} | ||
This function sets a [[Element/Weapon|custom weapon]]'s state. | |||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua">bool setWeaponState ( weapon theWeapon, string theState )</syntaxhighlight> | <syntaxhighlight lang="lua">bool setWeaponState ( weapon theWeapon, string theState )</syntaxhighlight> | ||
{{OOP||[[Element/Weapon|weapon]]:setState|state|getWeaponState}} | |||
===Required Arguments=== | ===Required Arguments=== | ||
* '''theWeapon | * '''theWeapon''': the weapon you wish to set the state of. | ||
* '''theState | * '''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=== | ||
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> | |||
==See | ==See also== | ||
{{Client weapon functions}} | {{Client weapon creation functions}} |
Latest revision as of 17:07, 7 November 2024
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 )
See also
- createWeapon
- fireWeapon
- getWeaponAmmo
- getWeaponClipAmmo
- getWeaponFiringRate
- getWeaponFlags
- getWeaponOwner
- getWeaponProperty
- getWeaponState
- getWeaponTarget
- resetWeaponFiringRate
- setWeaponAmmo
- setWeaponClipAmmo
- setWeaponFiringRate
- setWeaponFlags
- setWeaponProperty
- setWeaponState
- setWeaponTarget