SetWeaponClipAmmo: Difference between revisions
Jump to navigation
Jump to search
m (Added OOP syntax and improved some things) |
Fernando187 (talk | contribs) (Remove obsolete Requirements section) |
||
(3 intermediate revisions by one other user not shown) | |||
Line 5: | Line 5: | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua">bool setWeaponClipAmmo ( weapon theWeapon, int clipAmmo )</syntaxhighlight> | <syntaxhighlight lang="lua">bool setWeaponClipAmmo ( weapon theWeapon, int clipAmmo )</syntaxhighlight> | ||
{{OOP||[[Element/Weapon|weapon]]:setClipAmmo|clipAmmo|getWeaponClipAmmo}} | |||
===Required Arguments=== | ===Required Arguments=== | ||
Line 11: | Line 12: | ||
===Returns=== | ===Returns=== | ||
This function returns ''true'' if the arguments are valid and the weapon clip ammo could be changed; '' | This function returns ''true'' if the arguments are valid and the weapon clip ammo could be changed; ''false'' otherwise. | ||
==Example== | ==Example== | ||
Line 22: | Line 23: | ||
addCommandHandler("weapon", createWeaponWithLowClipAmmo) | addCommandHandler("weapon", createWeaponWithLowClipAmmo) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==See also== | ==See also== | ||
{{ | {{Client weapon creation functions}} |
Latest revision as of 17:06, 7 November 2024
This function sets the ammo left in a custom weapon's magazine/clip.
Syntax
bool setWeaponClipAmmo ( weapon theWeapon, int clipAmmo )
OOP Syntax Help! I don't understand this!
- Method: weapon:setClipAmmo(...)
- Variable: .clipAmmo
- Counterpart: getWeaponClipAmmo
Required Arguments
- theWeapon: The weapon to set the clip ammo of.
- clipAmmo: The amount of ammo in the clip.
Returns
This function returns true if the arguments are valid and the weapon clip ammo could be changed; false otherwise.
Example
This example adds a /weapon command that creates a M4 where the player uses it, and gives 1 clip ammo to it.
function createWeaponWithLowClipAmmo() local wep = createWeapon("m4", getElementPosition(localPlayer)) setWeaponClipAmmo(wep, 1) -- Give the weapon 1 clip ammo, so it will reload at the next shoot. end addCommandHandler("weapon", createWeaponWithLowClipAmmo)
See also
- createWeapon
- fireWeapon
- getWeaponAmmo
- getWeaponClipAmmo
- getWeaponFiringRate
- getWeaponFlags
- getWeaponOwner
- getWeaponProperty
- getWeaponState
- getWeaponTarget
- resetWeaponFiringRate
- setWeaponAmmo
- setWeaponClipAmmo
- setWeaponFiringRate
- setWeaponFlags
- setWeaponProperty
- setWeaponState
- setWeaponTarget