setWeaponClipAmmo | Multi Theft Auto: Wiki Skip to content

setWeaponClipAmmo

Client-side
Server-side
Shared

Pair: getWeaponClipAmmo

Manual Review Required

Please finish this page using the corresponding Old Wiki article. Go to Contribution guidelines for more information.


This function sets the ammo left in a custom weapon's magazine/clip.

OOP Syntax Help! I don't understand this!

  • Method: weapon:setClipAmmo(...)
  • Variable: .clipAmmo

Syntax

bool setWeaponClipAmmo ( weapon theWeapon, int clipAmmo )
Required Arguments
  • theWeapon: The weapon to set the clip ammo of.
  • clipAmmo: The amount of ammo in the clip.

Returns

  • bool: value

This function returns true if the arguments are valid and the weapon clip ammo could be changed; false otherwise.

Code Examples

shared

This example adds a/weaponcommand 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