SetWeaponFiringRate: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ {{Client function}} Sets the firing rate to be used when you set the custom weapon to the firing state. ==Syntax== <syntaxhighlight lang="lua">bool setWeaponFiringRate ( weapon theWeap...")
 
(Remove obsolete Requirements section)
 
(4 intermediate revisions by 4 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Client function}}
{{Client function}}
Sets the firing rate to be used when you set the custom weapon to the firing state.
This function sets the firing rate to be used when a [[Element/Weapon|custom weapon]] is in ''firing'' state.


==Syntax==
==Syntax==
<syntaxhighlight lang="lua">bool setWeaponFiringRate ( weapon theWeapon, int firingRate )</syntaxhighlight>
<syntaxhighlight lang="lua">bool setWeaponFiringRate ( weapon theWeapon, int firingRate )</syntaxhighlight>
{{OOP||[[Element/Weapon|weapon]]:setFiringRate|firingRate|getWeaponFiringRate}}


===Required Arguments===
===Required Arguments===
* '''theWeapon:''' The weapon to modify the firing rate of.
* '''theWeapon:''' The weapon to modify the firing rate of.
* '''firingRate:''' The weapon firing rate.
* '''firingRate:''' The weapon firing rate. It seems to be a kind of frecuency value, so the lower the quicker the [[Element/Weapon|custom weapon]] will shoot.


===Returns===
===Returns===
Returns ''true'' on success, ''false'' otherwise.
Returns ''true'' on success, ''false'' otherwise.


==Requirements==
==Example==
{{Requirements|1.3.0-4555|1.3.0-4555|}}
This example makes the Desert Eagle gun fire faster.
<syntaxhighlight lang="lua">
addEventHandler("onClientResourceStart", resourceRoot,
function()
  local weapon = createWeapon ("deagle",0,0,10) -- create the weapon (deagle)
  setWeaponAmmo(weapon,5000) -- set weapon ammo to 5000
  setWeaponState(weapon, "firing") -- in firing state.
  setWeaponFiringRate (weapon,2) -- change the weapon firing rate
end
)
</syntaxhighlight>


==See Also==
==See also==
{{Client weapon functions}}
{{Client weapon creation functions}}

Latest revision as of 17:06, 7 November 2024

This function sets the firing rate to be used when a custom weapon is in firing state.

Syntax

bool setWeaponFiringRate ( weapon theWeapon, int firingRate )

OOP Syntax Help! I don't understand this!

Method: weapon:setFiringRate(...)
Variable: .firingRate
Counterpart: getWeaponFiringRate


Required Arguments

  • theWeapon: The weapon to modify the firing rate of.
  • firingRate: The weapon firing rate. It seems to be a kind of frecuency value, so the lower the quicker the custom weapon will shoot.

Returns

Returns true on success, false otherwise.

Example

This example makes the Desert Eagle gun fire faster.

addEventHandler("onClientResourceStart", resourceRoot,
function()
   local weapon = createWeapon ("deagle",0,0,10) -- create the weapon (deagle)
   setWeaponAmmo(weapon,5000) -- set weapon ammo to 5000
   setWeaponState(weapon, "firing") -- in firing state.
   setWeaponFiringRate (weapon,2) -- change the weapon firing rate
end
)

See also