SixL client API / game/weapon / GameWeaponMp
Interface: GameWeaponMp
The weapon functions: ammunition, the weapon a ped holds and the weapon kinds.
Remarks
A weapon and an ammunition type are given as a number (its hash) or as a name, which is hashed to its 32-bit joaat. Getters are asynchronous: they return a Promise.
Example
const { ammo } = await mp.game.weapon.getMaxAmmo(ped, '<weapon name>');
Methods
getClipSize()
getClipSize(weaponHash):Promise<number>
The clip (magazine) size of a weapon, in rounds.
Parameters
weaponHash
string | number
The weapon: its name, or its hash.
Returns
Promise<number>
A Promise of the clip size as an integer.
Example
const size = await mp.game.weapon.getClipSize(mp.joaat('<weapon name>'));
getCurrentPedWeapon()
getCurrentPedWeapon(ped):Promise<{result:boolean;weaponHash:number; }>
The weapon the ped holds now.
Parameters
ped
number | { handle: number; }
The ped, or its handle.
Returns
Promise<{ result: boolean; weaponHash: number; }>
A Promise of { result, weaponHash }: result is the game's own true or false answer, weaponHash the hash of the weapon the ped holds.
Example
const { weaponHash } = await mp.game.weapon.getCurrentPedWeapon(ped);
getMaxAmmo()
getMaxAmmo(ped,weaponHash):Promise<{ammo:number;result:boolean; }>
The maximum ammunition a ped can carry for a weapon.
Parameters
ped
number | { handle: number; }
The ped, or its handle.
weaponHash
string | number
The weapon's name or hash.
Returns
Promise<{ ammo: number; result: boolean; }>
A Promise of { result, ammo }: result is the game's own true or false answer, ammo the maximum ammunition as an integer.
Example
const { result, ammo } = await mp.game.weapon.getMaxAmmo(ped, '<weapon name>');
getMaxAmmoInClip()
getMaxAmmoInClip(ped,weaponHash,p2?):Promise<number>
The maximum ammunition in one clip of a weapon a ped holds.
Parameters
ped
number | { handle: number; }
The ped, or its handle.
weaponHash
string | number
The weapon's name or hash.
p2?
boolean
A flag of the game; SixL does not use it.
Returns
Promise<number>
A Promise of the clip size as an integer.
Example
const size = await mp.game.weapon.getMaxAmmoInClip(ped, '<weapon name>');
getPedAmmoByType()
getPedAmmoByType(ped,ammoTypeHash):Promise<number>
The ammunition a ped carries for an ammunition type.
Parameters
ped
number | { handle: number; }
The ped, or its handle.
ammoTypeHash
string | number
The ammunition type's name or hash.
Returns
Promise<number>
A Promise of the ammunition count as an integer.
Example
const rounds = await mp.game.weapon.getPedAmmoByType(ped, 'ammotype_pistol');
getWeaponClipSize()
getWeaponClipSize(weaponHash):Promise<number>
The same as GameWeaponMp.getClipSize.
Parameters
weaponHash
string | number
The weapon: its name, or its hash.
Returns
Promise<number>
A Promise of the clip size as an integer.
Example
const size = await mp.game.weapon.getWeaponClipSize(mp.joaat('<weapon name>'));
getWeapontypeGroup()
getWeapontypeGroup(weaponHash):Promise<number>
The group of a weapon (its type class, such as the pistols or the rifles).
Parameters
weaponHash
string | number
The weapon's name or hash.
Returns
Promise<number>
A Promise of the weapon group as an integer hash.
Example
const group = await mp.game.weapon.getWeapontypeGroup('<weapon name>');
isPedArmed()
isPedArmed(ped,typeFlags):Promise<boolean>
Whether a ped holds a weapon of the kinds given.
Parameters
ped
number | { handle: number; }
The ped, or its handle.
typeFlags
number
The kinds of weapon to look for, as a bit mask of the game's weapon-type flags.
Returns
Promise<boolean>
A Promise of true when the ped is armed with such a weapon.
Example
const armed = await mp.game.weapon.isPedArmed(ped, 7);
isValid()
isValid(weaponHash):Promise<boolean>
The same check as isWeaponValid.
Parameters
weaponHash
string | number
The weapon's name or hash.
Returns
Promise<boolean>
A Promise of true when the weapon is valid.
Example
const valid = await mp.game.weapon.isValid('<weapon name>');
isWeaponValid()
isWeaponValid(weaponHash):Promise<boolean>
Whether a weapon is a valid weapon the game knows.
Parameters
weaponHash
string | number
The weapon's name or hash.
Returns
Promise<boolean>
A Promise of true when the weapon is valid.
Example
const valid = await mp.game.weapon.isWeaponValid('<weapon name>');
makePedReload()
makePedReload(ped):Promise<boolean>
Makes a ped reload its weapon.
Parameters
ped
number | { handle: number; }
The ped, or its handle.
Returns
Promise<boolean>
A Promise of true when the reload was started.
Example
const reloading = await mp.game.weapon.makePedReload(ped);
setPedChanceOfFiringBlanks()
setPedChanceOfFiringBlanks(ped,xBias,yBias):void
Sets how often a ped fires blank rounds (with no bullet) instead of live ones.
Parameters
ped
number | { handle: number; }
The ped, or its handle.
xBias
number
The first bias value, a float the game uses for the blank-round chance.
yBias
number
The second bias value, a float the game uses for the blank-round chance.
Returns
void
Example
mp.game.weapon.setPedChanceOfFiringBlanks(ped, 0.5, 0.5);
setPedInfiniteAmmoClip()
setPedInfiniteAmmoClip(ped,toggle):void
Gives a ped infinite ammunition in its clip, so it never needs to reload.
Parameters
ped
number | { handle: number; }
The ped, or its handle.
toggle
boolean
true to give infinite ammunition, false to take it back.
Returns
void
Example
mp.game.weapon.setPedInfiniteAmmoClip(ped, true);