SetWeaponClipAmmo

From Multi Theft Auto: Wiki
Revision as of 17:23, 23 December 2014 by AlexTMjugador (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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)

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