GetWeaponFiringRate: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
(Added OOP syntax and improved the example)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Client function}}
{{Client function}}
Gets the firing rate to be used when you set the custom weapon to the firing state.
This gets the firing rate to be used when a [[Element/Weapon|custom weapon]] opens fire.


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


===Required Arguments===
===Required Arguments===
Line 13: Line 14:


==Example==
==Example==
This example creates a minigun at the center of the map and creates a ''/firerate'' command that outputs its firerate to the player who types it.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
local wep = createWeapon("minigun", 0, 0, 0)
local weapon = createWeapon("minigun", 0, 0, 3)


function getWepRate()
function outputMinigunFireRate()
if (not wep) then return end
    outputChatBox("Fire rate: " .. getWeaponFiringRate(weapon))
local rate = getWeaponFiringRate(wep)
outputChatBox("Fire rate: "..rate)
end
end
addCommandHandler("firerate", getWepRate)
addCommandHandler("firerate", outputMinigunFireRate)
</syntaxhighlight>
</syntaxhighlight>


Line 27: Line 27:
{{Requirements|n/a|1.3.0-9.04555|}}
{{Requirements|n/a|1.3.0-9.04555|}}


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

Latest revision as of 16:36, 23 December 2014

This gets the firing rate to be used when a custom weapon opens fire.

Syntax

int getWeaponFiringRate ( weapon theWeapon )

OOP Syntax Help! I don't understand this!

Method: weapon:getFiringRate(...)
Variable: .firingRate
Counterpart: setWeaponFiringRate


Required Arguments

  • theWeapon: The weapon to modify the firing rate of.

Returns

Returns an integer with the firing rate of the custom weapon, false otherwise.

Example

This example creates a minigun at the center of the map and creates a /firerate command that outputs its firerate to the player who types it.

local weapon = createWeapon("minigun", 0, 0, 3)

function outputMinigunFireRate()
    outputChatBox("Fire rate: " .. getWeaponFiringRate(weapon))
end
addCommandHandler("firerate", outputMinigunFireRate)

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