import type { eAddItemReason } from '../enums/eAddItemReason'; import type { eAmmoType } from '../enums/eAmmoType'; import type { eRemoveItemReason } from '../enums/eRemoveItemReason'; import type { eWeaponHash } from '../enums/eWeaponHash'; import type { Entity } from '../classes/Entity'; import type { Prop } from '../classes/Prop'; import { Vector2 } from '../types/Vector2'; import { Vector3 } from '../types/Vector3'; import { Vector4 } from '../types/Vector4'; import { Color } from '../types/Color'; import type { Ped } from './Ped'; import { createFromHandle } from '../types/HandleRegistry'; import { inv, rai, raf, ras, rav, pvi, pvf, pvv, pvii, pvfi, _h, f, int, uint, float, Hash, u8, u16, u32, u64, i8, i16, i32, i64 } from '../types/NativeAliases'; export class Weapon { protected ped: Ped; constructor(ped: Ped) { this.ped = ped; } /** * @param ammoType * @returns */ getPedAmmoByType(ammoType: string | number): int { return inv('0x39D22031557946C1', this.ped.handle, _h(ammoType), rai()); } /** * @param p1 * @param p2 * @returns */ getBestPedWeapon(p1: boolean, p2: boolean): number { return (inv('0x8483E98E8B888AE2', this.ped.handle, p1, p2, rai())) & 0xFFFFFFFF; } /** * @param toggle * @param weaponHash * @returns The instance for method chaining */ setPedInfiniteAmmo(toggle: boolean, weaponHash: eWeaponHash): this { inv('0x3EDCB0505123623B', this.ped.handle, toggle, weaponHash); return this; } /** * @param weaponHash * @param ammoHash Refer to {@link eWeaponHash} * @returns The instance for method chaining */ setAmmoTypeForPedWeapon(weaponHash: eWeaponHash, ammoHash: eAmmoType): this { inv('0xCC9C4393523833E2', this.ped.handle, weaponHash, ammoHash); return this; } /** * *GET_BEST** - *GET_CLOSEST** * * @returns weaponGuid */ get CorrectKitEmoteTwirlGun(): [boolean, number] { const result = inv<[boolean, number]>('0xCD356B42C57BFE01', this.ped.handle, pvi(), rai()); return [!!result[0], result[1]]; } /** * @param weaponHash * @returns */ setCurrentPedVehicleWeapon(weaponHash: eWeaponHash): boolean { return !!inv('0x75C55983C2C39DAA', this.ped.handle, weaponHash, rai()); } /** * Returns whether the ped has a rifle p1: 0 or 1 * * @param p1 * @returns */ doesPedHaveRifle(p1: int): boolean { return !!inv('0x95CA12E2C68043E5', this.ped.handle, p1, rai()); } /** * Puts the gun visibly in your horse's holster without having to be close to the horse. Use `_SEND_WEAPON_TO_INVENTORY` before using this native * _A* or _B* * * @param weaponHash * @param ped Refer to {@link eWeaponHash} */ N_0x14FF0C2545527F9B(weaponHash: eWeaponHash, ped: Ped): void { inv('0x14FF0C2545527F9B', this.ped.handle, weaponHash, ped.handle); } /** * Returns iSpinHash / iVariationSpin * * @param weaponEmoteVariation * @returns */ getPedGunSpinningHashFromWeaponEmoteVariation(weaponEmoteVariation: int): number { return (inv('0xF3B1620B920D1708', this.ped.handle, weaponEmoteVariation, rai())) & 0xFFFFFFFF; } /** * Returns whether the ped has a repeater p1: 0 or 1 * * @param p1 * @returns */ doesPedHaveRepeater(p1: int): boolean { return !!inv('0x495A04CAEC263AF8', this.ped.handle, p1, rai()); } /** * @param weaponCollection */ giveWeaponCollectionToPed(weaponCollection: string | number): void { inv('0x899A04AFCC725D04', this.ped.handle, _h(weaponCollection)); } /** * @returns */ get IsPedWeaponReadyToShoot(): boolean { return !!inv('0xB80CA294F2F26749', this.ped.handle, rai()); } /** * @param componentHash * @param weaponHash */ removeWeaponComponentFromPed(componentHash: string | number, weaponHash: eWeaponHash): void { inv('0x19F70C4D80494FF8', this.ped.handle, _h(componentHash), weaponHash); } /** * @param visible * @param deselectWeapon * @param p3 * @param p4 * @returns The instance for method chaining */ setPedCurrentWeaponVisible(visible: boolean, deselectWeapon: boolean, p3: boolean, p4: boolean): this { inv('0x0725A4CCFDED9A70', this.ped.handle, visible, deselectWeapon, p3, p4); return this; } /** * Old name: _DROP_CURRENT_PED_WEAPON * * @param p1 * @param attachPoint * @param p3 Refer to {@link eWeaponAttachPoint} * @param p4 * @returns */ makePedDropWeapon(p1: boolean, attachPoint: int, p3: boolean, p4: boolean): Entity | null { return createFromHandle('Entity', inv('0xCEF4C65DE502D367', this.ped.handle, p1, attachPoint, p3, p4, rai())); } removeAllPedAmmo(): void { inv('0x1B83C0DEEBCBB214', this.ped.handle); } /** * @param allow */ set AllowDualWield(allow: boolean) { inv('0x83B8D50EB9446BBA', this.ped.handle, allow); } /** * @param allow * @returns The instance for method chaining */ setAllowDualWield(allow: boolean): this { inv('0x83B8D50EB9446BBA', this.ped.handle, allow); return this; } /** * Returns weaponEmoteVariation WEAPON_EMOTE_VARIATION_INVALID = -2, * WEAPON_EMOTE_VARIATION_BASE, * WEAPON_EMOTE_VARIATION_A, * WEAPON_EMOTE_VARIATION_B, * WEAPON_EMOTE_VARIATION_C, * WEAPON_EMOTE_VARIATION_D, * WEAPON_EMOTE_VARIATION_PREVIEW, * WEAPON_EMOTE_NUM_VARIATIONS * * @param variation * @returns */ getWeaponEmoteVariation(variation: int): int { return inv('0x86147D05FA831D3A', this.ped.handle, variation, rai()); } /** * @param weaponHash * @returns */ isPedCarryingWeapon(weaponHash: eWeaponHash): boolean { return !!inv('0xF29A186ED428B552', this.ped.handle, weaponHash, rai()); } /** * @returns */ refillAmmoInCurrentPedWeapon(): any { return inv('0x0A2AB7B7ABC055F4', this.ped.handle); } /** * Unequip current weapon and set current weapon to WEAPON_UNARMED. * p0 usually 2 in R* scripts. Doesn't seem to have any effect if changed.... * immediately: if true it will instantly switch to unarmed * * @param p0 * @param immediately */ hidePedWeapons(p0: int, immediately: boolean): void { inv('0xFCCC886EDE3C63EC', this.ped.handle, p0, immediately); } /** * @param weaponHash * @returns ammo */ getAmmoInClip(weaponHash: eWeaponHash): [boolean, number] { const result = inv<[boolean, number]>('0x2E1202248937775C', this.ped.handle, pvi(), weaponHash, rai()); return [!!result[0], result[1]]; } /** * @param toggle */ N_0x16D9841A85FA627E(toggle: boolean): void { inv('0x16D9841A85FA627E', this.ped.handle, toggle); } /** * @param weaponHash * @param offset Refer to {@link eWeaponHash} * @param ammoCount * @returns The instance for method chaining */ setPedDropsInventoryWeapon(weaponHash: eWeaponHash, offset: Vector3, ammoCount: int): this { inv('0x208A1888007FC0E6', this.ped.handle, weaponHash, f(offset.x), f(offset.y), f(offset.z), ammoCount); return this; } /** * spinHash can be -1, 0 to disable * * @param weaponEmoteTrickType * @param spin * @returns The instance for method chaining */ setActiveGunSpinningKitEmoteTwirl(weaponEmoteTrickType: int, spin: string | number): this { inv('0x01F661BB9C71B465', this.ped.handle, weaponEmoteTrickType, _h(spin)); return this; } /** * Appears to just send specified weapon to your horse holster without having to be close * However, the weapon is not visible on the horse holster, but you can reach the weapon on the weapon wheel * * @param weaponHash */ sendWeaponToInventory(weaponHash: eWeaponHash): void { inv('0xE9BD19F8121ADE3E', this.ped.handle, weaponHash); } /** * If near your horse when called, weapons stored on your horse will be considered * Returns weaponHash * * @param weaponGroup * @param p2 * @param p3 * @returns */ getBestPedWeaponInGroup(weaponGroup: string | number, p2: boolean, p3: boolean): number { return (inv('0x9F67929D98E7C6E8', this.ped.handle, _h(weaponGroup), p2, p3, rai())) & 0xFFFFFFFF; } /** * Only used in R* SP Scripts native_son2, native_son3 and smuggler2 * Params: p2 = -1 * * @param p1 * @param p2 */ N_0x8A779706DA5CA3DD(p1: boolean, p2: int): void { inv('0x8A779706DA5CA3DD', this.ped.handle, p1, p2); } /** * @param weaponHash * @param ammoHash Refer to {@link eWeaponHash} */ disableAmmoTypeForPedWeapon(weaponHash: eWeaponHash, ammoHash: eAmmoType): void { inv('0xF0D728EEA3C99775', this.ped.handle, weaponHash, ammoHash); } /** * @returns data; outData */ giveWeaponToPedWithOptions(): [boolean, number, number] { const result = inv<[boolean, number, number]>('0xBE7E42B07FD317AC', this.ped.handle, pvi(), pvi(), rai()); return [!!result[0], result[1], result[2]]; } /** * @returns */ get MaxLockonDistanceOfCurrentPedWeapon(): float { return inv('0x79B1A6E780266DB0', this.ped.handle, raf()); } /** * Stores longarms to your horse on dismount * Params: p2 = 0 * SET_[I - M]* * * @param storeLongarms * @param p2 * @returns The instance for method chaining */ setInstantlyStoreLongarmsOnDismount(storeLongarms: boolean, p2: int): this { inv('0xB832F1A686B9B810', this.ped.handle, storeLongarms, p2); return this; } /** * @param removeReason * @returns weaponGuid */ removeWeaponFromPedByGuid(removeReason: eRemoveItemReason): number { const result = inv('0x51C3B71591811485', this.ped.handle, pvi(), removeReason); return result; } /** * attachPoint: * * @param weaponHash * @param equipNow Refer to {@link eWeaponHash} * @param attachPoint * @param p4 Refer to {@link eWeaponAttachPoint} * @param p5 * @returns The instance for method chaining */ setCurrentPedWeapon(weaponHash: eWeaponHash, equipNow: boolean, attachPoint: int, p4: boolean, p5: boolean): this { inv('0xADF692B254977C0C', this.ped.handle, weaponHash, equipNow, attachPoint, p4, p5); return this; } /** * Equips a weapon from a weaponItem, similar to GIVE_WEAPON_TO_PED * * @param p2 * @param p3 * @param p4 * @param p5 * @returns weaponUid */ setCurrentPedWeaponByGuid(p2: boolean, p3: boolean, p4: boolean, p5: boolean): number { const result = inv('0x12FB95FE3D579238', this.ped.handle, pvi(), p2, p3, p4, p5); return result; } /** * @param componentHash * @param weaponHash * @returns */ hasPedGotWeaponComponent(componentHash: string | number, weaponHash: eWeaponHash): any { return inv('0xBBC67A6F965C688A', this.ped.handle, _h(componentHash), weaponHash); } /** * @param weaponHash The ped to give the ammo, this cannot be a remote player. * @param amount Refer to {@link eWeaponHash} * @param addReason The amount of ped to add to the ammo */ addAmmoToPed(weaponHash: eWeaponHash, amount: int, addReason: eAddItemReason): void { inv('0xB190BCA3F4042F95', this.ped.handle, weaponHash, amount, addReason); } /** * @param ammoType * @param amount * @param addReason */ addAmmoToPedByType(ammoType: string | number, amount: int, addReason: eAddItemReason): void { inv('0x106A811C6D3035F3', this.ped.handle, _h(ammoType), amount, addReason); } /** * @param targetPed * @returns */ isTargetPedConstrainedByPedUsingBolas(targetPed: Ped): boolean { return !!inv('0x8D50F43298AB9545', this.ped.handle, targetPed.handle, rai()); } /** * @param p1 * @returns guidPrimary */ getBestPedWeaponInInventory(p1: any): [any, number] { const result = inv<[number, number]>('0x7B98500614C8E8B8', this.ped.handle, p1, pvi()); return [result[0], result[1]]; } /** * @param toggle */ N_0xF08D8FEB455F2C8C(toggle: boolean): void { inv('0xF08D8FEB455F2C8C', this.ped.handle, toggle); } /** * @returns ammo; inventoryUid */ get AmmoInClipByInventoryUid(): [any, number, number] { const result = inv<[number, number, number]>('0x678F00858980F516', this.ped.handle, pvi(), pvi()); return [result[0], result[1], result[2]]; } /** * removeReason must be REMOVE_REASON_USED, REMOVE_REASON_GIVEN, REMOVE_REASON_DROPPED or REMOVE_REASON_DEBUG, unless amount is -1 * * @param ammoHash * @param amount Refer to {@link eAmmoType} * @param removeReason */ removeAmmoFromPedByType(ammoHash: eAmmoType, amount: int, removeReason: eRemoveItemReason): void { inv('0xB6CFEC32E3742779', this.ped.handle, ammoHash, amount, removeReason); } /** * Holster the holded shoulder weapon. Precisions: 0 means with anim while 1 means direct holster * * @param disableAnim */ set PedWeaponOnBack(disableAnim: boolean) { inv('0x4820A6939D7CEF28', this.ped.handle, disableAnim); } /** * Holster the holded shoulder weapon. Precisions: 0 means with anim while 1 means direct holster * * @param disableAnim * @returns The instance for method chaining */ setPedWeaponOnBack(disableAnim: boolean): this { inv('0x4820A6939D7CEF28', this.ped.handle, disableAnim); return this; } /** * @param ammoType * @param ammo * @returns The instance for method chaining */ setPedAmmoByType(ammoType: string | number, ammo: int): this { inv('0x5FD1E1F011E76D7E', this.ped.handle, _h(ammoType), ammo); return this; } /** * @param p1 * @returns */ getPedBackupWeapon(p1: boolean): number { return (inv('0xC71FE230A513C30F', this.ped.handle, p1, rai())) & 0xFFFFFFFF; } /** * @param attachPoint */ set ForceCurrentWeaponIntoCockedState(attachPoint: int) { inv('0x5230D3F6EE56CFE6', this.ped.handle, attachPoint); } /** * @param attachPoint * @returns The instance for method chaining */ setForceCurrentWeaponIntoCockedState(attachPoint: int): this { inv('0x5230D3F6EE56CFE6', this.ped.handle, attachPoint); return this; } /** * @returns */ get PedHogtieWeapon(): number { return (inv('0x90EB1CB189923587', this.ped.handle, rai())) & 0xFFFFFFFF; } /** * Returns whether the ped has a pistol p1: 0 or 1 * * @param p1 * @returns */ doesPedHavePistol(p1: int): boolean { return !!inv('0xBFCA7AFABF9D7967', this.ped.handle, p1, rai()); } /** * *STOP** - *TEST** * * @param emoteType */ set GunSpinningInventorySlotIdActivate(emoteType: int) { inv('0x408CF580C5E96D49', this.ped.handle, emoteType); } /** * *STOP** - *TEST** * * @param emoteType * @returns The instance for method chaining */ setGunSpinningInventorySlotIdActivate(emoteType: int): this { inv('0x408CF580C5E96D49', this.ped.handle, emoteType); return this; } /** * @returns weaponHash: Refer to {@link eWeaponHash} */ get CurrentPedVehicleWeapon(): [boolean, number] { const result = inv<[boolean, number]>('0x1017582BCD3832DC', this.ped.handle, pvi(), rai()); return [!!result[0], result[1]]; } /** * @param attachPoint * @param visible Refer to {@link eWeaponAttachPoint} * @returns The instance for method chaining */ setPedWeaponAttachPointVisibility(attachPoint: int, visible: boolean): this { inv('0x67E21ACC5C0C970C', this.ped.handle, attachPoint, visible); return this; } /** * @param p1 * @param p2 * @param p3 * @param immediately */ holsterPedWeapons(p1: boolean, p2: boolean, p3: boolean, immediately: boolean): void { inv('0x94A3C1B804D291EC', this.ped.handle, p1, p2, p3, immediately); } /** * onlyCheckPlayerInventory: If true, it will only check the players current inventory. If false, it also checks your horse inventory * * @param weaponHash * @param p2 Refer to {@link eWeaponHash} * @param onlyCheckPlayerInventory * @returns */ hasPedGotWeapon(weaponHash: eWeaponHash, p2: int, onlyCheckPlayerInventory: boolean): boolean { return !!inv('0x8DECB02F88F428BC', this.ped.handle, weaponHash, p2, onlyCheckPlayerInventory, rai()); } /** * @returns */ get AllowDualWield(): any { return inv('0x918990BD9CE08582', this.ped.handle); } /** * Returns eCurrentHeldWeapon * _GET_R* - _GET_T* * * @returns */ get PedCurrentHeldWeapon(): number { return (inv('0x8425C5F057012DAB', this.ped.handle, rai())) & 0xFFFFFFFF; } /** * @param toggle */ set ForceAutoEquip(toggle: boolean) { inv('0xBE711B14A159E84F', this.ped.handle, toggle); } /** * @param toggle * @returns The instance for method chaining */ setForceAutoEquip(toggle: boolean): this { inv('0xBE711B14A159E84F', this.ped.handle, toggle); return this; } /** * @param weaponHash * @param ammo Refer to {@link eWeaponHash} * @returns The instance for method chaining */ setPedAmmo(weaponHash: eWeaponHash, ammo: int): this { inv('0x14E56BC5B5DB6A19', this.ped.handle, weaponHash, ammo); return this; } /** * Gives the ped the weapon. * List: https://github.com/femga/rdr3_discoveries/blob/master/weapons/weapons.lua Params: p7 is 0.5f, and p8 is 1.0f. p11 and p12 are both 0 in R* Scripts * permanentDegradation: default 0.5, any higher than 0 it will automatically make the weapon worn, you can also adjust the value to change the weapons maximum cleanliness * * @param weaponHash * @param ammoCount Refer to {@link eWeaponHash} * @param bForceInHand * @param bForceInHolster * @param attachPoint * @param bAllowMultipleCopies Refer to {@link eWeaponAttachPoint} * @param p7 * @param p8 * @param addReason * @param bIgnoreUnlocks Refer to {@link eAddItemReason} * @param permanentDegradation * @param p12 * @returns */ giveWeaponToPed(weaponHash: eWeaponHash, ammoCount: int, bForceInHand: boolean, bForceInHolster: boolean, attachPoint: int, bAllowMultipleCopies: boolean, p7: float, p8: float, addReason: eAddItemReason, bIgnoreUnlocks: boolean, permanentDegradation: float, p12: boolean): number { return (inv('0x5E3BDDBCB83F3D84', this.ped.handle, weaponHash, ammoCount, bForceInHand, bForceInHolster, attachPoint, bAllowMultipleCopies, f(p7), f(p8), addReason, bIgnoreUnlocks, f(permanentDegradation), p12, rai())) & 0xFFFFFFFF; } /** * @param weaponHash * @returns */ getAmmoInPedWeapon(weaponHash: eWeaponHash): int { return inv('0x015A522136D7F951', this.ped.handle, weaponHash, rai()); } /** * @param attachPoint * @returns weaponGuid */ getPedWeaponGuidAtAttachPoint(attachPoint: int): [any, number] { const result = inv<[number, number]>('0x6929E22158E52265', this.ped.handle, attachPoint, pvi()); return [result[0], result[1]]; } /** * emote hashes: KIT_EMOTE_TWIRL_GUN, KIT_EMOTE_TWIRL_GUN_LEFT_HOLSTER, KIT_EMOTE_TWIRL_GUN_DUAL, 0 (to unequip) * * @param emote */ set ActiveGunSpinningEquipKitEmoteTwirl(emote: string | number) { inv('0xCBCFFF805F1B4596', this.ped.handle, _h(emote)); } /** * emote hashes: KIT_EMOTE_TWIRL_GUN, KIT_EMOTE_TWIRL_GUN_LEFT_HOLSTER, KIT_EMOTE_TWIRL_GUN_DUAL, 0 (to unequip) * * @param emote * @returns The instance for method chaining */ setActiveGunSpinningEquipKitEmoteTwirl(emote: string | number): this { inv('0xCBCFFF805F1B4596', this.ped.handle, _h(emote)); return this; } /** * @param weaponHash * @param ammoHash Refer to {@link eWeaponHash} */ enableAmmoTypeForPedWeapon(weaponHash: eWeaponHash, ammoHash: eAmmoType): void { inv('0x23FB9FACA28779C1', this.ped.handle, weaponHash, ammoHash); } /** * @param toggle */ N_0x431240A58484D5D0(toggle: boolean): void { inv('0x431240A58484D5D0', this.ped.handle, toggle); } /** * @param p2 * @param p3 * @returns outGUID */ getBestPedShortarmGuid(p2: boolean, p3: boolean): number { const result = inv('0xF52BD94B47CCF736', this.ped.handle, pvi(), p2, p3); return result; } /** * @returns coords */ get PedLastWeaponImpactCoord(): [boolean, Vector3] { const result = inv<[boolean, number[]]>('0x6C4D0409BA1A2BC2', this.ped.handle, pvv(), rai()); return [!!result[0], Vector3.fromArray(result[1])]; } /** * Returns WeaponAttachPoint * * @param attachPoint * @returns */ getWeaponAttachPoint(attachPoint: int): int { return inv('0xCAD4FE9398820D24', this.ped.handle, attachPoint, rai()); } /** * @param p2 * @param attachPoint * @param p4 Refer to {@link eWeaponAttachPoint} * @returns weaponHash: Refer to {@link eWeaponHash} */ getCurrentPedWeapon(p2: boolean, attachPoint: int, p4: boolean): [boolean, number] { const result = inv<[boolean, number]>('0x3A87E44BB9A01D54', this.ped.handle, pvi(), p2, attachPoint, p4, rai()); return [!!result[0], result[1]]; } /** * Returns whether the ped has a revolver p1: 0 or 1 * * @param p1 * @returns */ doesPedHaveRevolver(p1: int): boolean { return !!inv('0x5B235F24472F2C3B', this.ped.handle, p1, rai()); } /** * Returns emote Hash * * @returns */ get PedGunSpinningEquippedKitEmoteTwirl(): number { return (inv('0x2C4FEC3D0EFA9FC0', this.ped.handle, rai())) & 0xFFFFFFFF; } /** * @param weaponHash */ enableAmmoTypeForPed(weaponHash: eWeaponHash): void { inv('0x3B7B7908B7ADFB4B', this.ped.handle, weaponHash); } /** * Detaches the weapon from the ped and actually removes the ped's weapon * * @param p1 * @returns */ getWeaponObjectFromPed(p1: boolean): Prop | null { return createFromHandle('Prop', inv('0xC6A6789BB405D11C', this.ped.handle, p1, rai())); } /** * @returns */ get IsPedCurrentWeaponHolstered(): boolean { return !!inv('0xBDD9C235D8D1052E', this.ped.handle, rai()); } /** * @param toggle */ set InstantlyEquipWeaponPickups(toggle: boolean) { inv('0x739B9C6D0E7F7F93', this.ped.handle, toggle); } /** * @param toggle * @returns The instance for method chaining */ setInstantlyEquipWeaponPickups(toggle: boolean): this { inv('0x739B9C6D0E7F7F93', this.ped.handle, toggle); return this; } /** * Hides the ped's weapon during a cutscene. * * @param toggle */ hidePedWeaponForScriptedCutscene(toggle: boolean): void { inv('0x6F6981D2253C208F', this.ped.handle, toggle); } /** * @returns guidPrimary; guidSecondary */ setPlayerPedQuickSwapWeaponByGuid(): [number, number] { const result = inv<[number, number]>('0xEC1F85DA51D3D6C4', this.ped.handle, pvi(), pvi()); return [result[0], result[1]]; } /** * @returns Returns the total ammo in the ped weapon from it's guid, or `0`.; guid * @example * ```lua * -- Example: * local ped = PlayerPedId() * local weaponGuid = DataView.ArrayBuffer(16 * 8) * * for attachPoint = 0, 3 do * -- GET_PED_WEAPON_GUID_AT_ATTACH_POINT * if (Citizen.InvokeNative(0x6929E22158E52265, ped, attachPoint, weaponGuid:Buffer())) then * -- This will return the total ammo of each of the player weapon slots * local ammo = Citizen.InvokeNative(0x4823F13A21F51964, ped, weaponGuid:Buffer(), Citizen.ResultAsInteger()) or 0 * print(string.format("You have %s ammo in the weapon at attach point #%s", ammo, attachPoint)) * end * end * ``` */ get AmmoInPedWeaponFromGuid(): [int, number] { const result = inv<[number, number]>('0x4823F13A21F51964', this.ped.handle, pvi(), rai()); return [result[0], result[1]]; } /** * @param p1 * @param p2 */ removeAllPedWeapons(p1: boolean, p2: boolean): void { inv('0xF25DF915FA38C5F3', this.ped.handle, p1, p2); } /** * Returns ammoHash from weaponObject (Returned by 0x6CA484C9A7377E4F) * * @param weaponObject * @returns */ getCurrentPedWeaponAmmoType(weaponObject: Prop): number { return (inv('0x7E7B19A4355FEE13', this.ped.handle, weaponObject.handle, rai())) & 0xFFFFFFFF; } /** * @param p1 * @param p2 * @param p3 * @returns */ getPedWorstWeapon(p1: boolean, p2: boolean, p3: boolean): number { return (inv('0xDA37A053C1522F5D', this.ped.handle, p1, p2, p3, rai())) & 0xFFFFFFFF; } /** * @param toggle */ set PedDropsWeaponsWhenDead(toggle: boolean) { inv('0x476AE72C1D19D1A8', this.ped.handle, toggle); } /** * @param toggle * @returns The instance for method chaining */ setPedDropsWeaponsWhenDead(toggle: boolean): this { inv('0x476AE72C1D19D1A8', this.ped.handle, toggle); return this; } /** * Returns ammoHash * * @returns Returns the {@link eAmmoType}; weaponGuid */ get CurrentAmmoTypeFromGuid(): [number, number] { const result = inv<[number, number]>('0xAF9D167A5656D6A6', this.ped.handle, pvi(), rai()); return [result[0] & 0xFFFFFFFF, result[1]]; } /** * @param toggle */ set PedInfiniteAmmoClip(toggle: boolean) { inv('0xFBAA1E06B6BCA741', this.ped.handle, toggle); } /** * @param toggle * @returns The instance for method chaining */ setPedInfiniteAmmoClip(toggle: boolean): this { inv('0xFBAA1E06B6BCA741', this.ped.handle, toggle); return this; } /** * returns the amount of peds that were restrained with the weapon thrown bolas * * @returns */ get NumPedsRestrainedFromWeaponBolas(): any { return inv('0x46D42883E873C1D7', this.ped.handle); } /** * @param toggle */ set AllowAnyWeaponDrop(toggle: boolean) { inv('0x78030C7867D8B9B6', this.ped.handle, toggle); } /** * @param toggle * @returns The instance for method chaining */ setAllowAnyWeaponDrop(toggle: boolean): this { inv('0x78030C7867D8B9B6', this.ped.handle, toggle); return this; } /** * @returns */ makePedReload(): any { return inv('0x79E1E511FF7EFB13', this.ped.handle); } /** * @param weaponHash * @param ammoCount Refer to {@link eWeaponHash} * @param p3 * @param addReason */ giveDelayedWeaponToPed(weaponHash: eWeaponHash, ammoCount: int, p3: boolean, addReason: eAddItemReason): void { inv('0xB282DC6EBD803C75', this.ped.handle, weaponHash, ammoCount, p3, addReason); } /** * @param toggle */ N_0x45E57FDD531C9477(toggle: boolean): void { inv('0x45E57FDD531C9477', this.ped.handle, toggle); } /** * @param ammoHash * @returns weaponInventoryUid */ setAmmoTypeForPedWeaponInventory(ammoHash: eAmmoType): number { const result = inv('0xEBE46B501BC3FBCF', this.ped.handle, pvi(), ammoHash); return result; } /** * @param weaponHash * @param p2 Refer to {@link eWeaponHash} * @param removeReason */ removeWeaponFromPed(weaponHash: eWeaponHash, p2: boolean, removeReason: eRemoveItemReason): void { inv('0x4899CB088EDF59B8', this.ped.handle, weaponHash, p2, removeReason); } /** * @param visible */ set PedAllWeaponsVisibility(visible: boolean) { inv('0x4F806A6CFED89468', this.ped.handle, visible); } /** * @param visible * @returns The instance for method chaining */ setPedAllWeaponsVisibility(visible: boolean): this { inv('0x4F806A6CFED89468', this.ped.handle, visible); return this; } /** * @param weaponHash * @param ammo Refer to {@link eWeaponHash} * @returns */ setAmmoInClip(weaponHash: eWeaponHash, ammo: int): boolean { return !!inv('0xDCD2A934D65CB497', this.ped.handle, weaponHash, ammo, rai()); } /** * _GET_M* - _GET_PED_A* * * @param p1 * @returns */ getPedWeaponObject(p1: boolean): Prop | null { return createFromHandle('Prop', inv('0x6CA484C9A7377E4F', this.ped.handle, p1, rai())); } /** * slotHash is usually just the weaponHash name, but WEAPON_* is replaced with SLOT_* * * @param slotHash * @returns */ getPedWeaponInSlot(slotHash: string | number): number { return (inv('0xDBC4B552B2AE9A83', this.ped.handle, _h(slotHash), rai())) & 0xFFFFFFFF; } /** * Outputs cached guids * * @returns guidPrimary; guidSecondary */ get PlayerPedQuickSwapWeaponByGuid(): [number, number] { const result = inv<[number, number]>('0xB7E52A058B07C7E2', this.ped.handle, pvi(), pvi()); return [result[0], result[1]]; } /** * Returns true if the ped is currently holstering or unholstering a weapon * * @returns */ get IsWeaponHolsterStateChanging(): boolean { return !!inv('0x2387D6E9C6B478AA', this.ped.handle, rai()); } /** * @param ammoHash * @returns */ N_0x44C8F4908F1B2622(ammoHash: eAmmoType): boolean { return !!inv('0x44C8F4908F1B2622', this.ped.handle, ammoHash, rai()); } /** * @param p2 * @returns clipInventoryUid */ refillAmmoInClip(p2: int): [any, number] { const result = inv<[number, number]>('0xDF4A3404D022ADDE', this.ped.handle, pvi(), p2); return [result[0], result[1]]; } /** * _SET_A* - _SET_B* * * @param p1 */ N_0x2EBF70E1D8C06683(p1: string | number): void { inv('0x2EBF70E1D8C06683', this.ped.handle, _h(p1)); } /** * @param ammoHash */ disableAmmoTypeForPed(ammoHash: eAmmoType): void { inv('0xAA5A52204E077883', this.ped.handle, ammoHash); } /** * Returns whether the ped has a shotgun p1: 0 or 1 * * @param p1 * @returns */ doesPedHaveShotgun(p1: int): boolean { return !!inv('0xABC18A28BAD4B46F', this.ped.handle, p1, rai()); } clearPedLastWeaponDamage(): void { inv('0x087D8F4BC65F68E4', this.ped.handle); } /** * Returns true if ped is on a horse while inside of a town * Params: p1 = 0 * GET_L* - GET_MA* * * @param p1 * @returns */ N_0x5A695BD328586B44(p1: int): any { return inv('0x5A695BD328586B44', this.ped.handle, p1); } /** * @param weaponHash * @param amount Refer to {@link eWeaponHash} * @param removeReason */ removeAmmoFromPed(weaponHash: eWeaponHash, amount: int, removeReason: eRemoveItemReason): void { inv('0xF4823C813CB8277D', this.ped.handle, weaponHash, amount, removeReason); } /** * @param p1 * @param p2 * @returns The instance for method chaining */ setPedAmmoToDrop(p1: int, p2: int): this { inv('0xA4EFEF9440A5B0EF', this.ped.handle, p1, p2); return this; } /** * Returns the current ammo type of the specified ped's specified weapon. * * @param weaponHash * @returns */ getPedAmmoTypeFromWeapon(weaponHash: eWeaponHash): number { return (inv('0x7FEAD38B326B9F74', this.ped.handle, weaponHash, rai())) & 0xFFFFFFFF; } /** * @param weaponHash * @returns ammo */ getMaxAmmo(weaponHash: eWeaponHash): [boolean, number] { const result = inv<[boolean, number]>('0xDC16122C7A20C933', this.ped.handle, pvi(), weaponHash, rai()); return [!!result[0], result[1]]; } /** * @returns */ enableWeaponRestore(): any { return inv('0xC395355843BE134B', this.ped.handle); } /** * Returns whether the specified ped is holding a weapon with the given hash. * only these weapons below return true * WEAPON_BOW, WEAPON_KIT_METAL_DETECTOR, WEAPON_MELEE_CLEAVER, WEAPON_MELEE_DAVY_LANTERN, WEAPON_MELEE_HATCHET, WEAPON_MELEE_HATCHET_HUNTER, WEAPON_MELEE_KNIFE_JAWBONE, WEAPON_MELEE_LANTERN WEAPON_MELEE_TORCH, WEAPON_MOONSHINEJUG_MP, WEAPON_RIFLE_BOLTACTION, WEAPON_SHOTGUN_PUMP, WEAPON_THROWN_BOLAS, WEAPON_THROWN_MOLOTOV * * @param weapon * @returns */ isPedHoldingWeapon(weapon: string | number): boolean { return !!inv('0x07E1C35F0078C3F9', this.ped.handle, _h(weapon), rai()); } /** * _GET_D* - _GET_L* * * @returns */ N_0x0DE0944ECCB3DF5D(): boolean { return !!inv('0x0DE0944ECCB3DF5D', this.ped.handle, rai()); } /** * @param flags * @returns */ isPedArmed(flags: int): boolean { return !!inv('0xCB690F680A3EA971', this.ped.handle, flags, rai()); } /** * Returns whether the ped has a sniper p1: 0 or 1 * * @param p1 * @returns */ doesPedHaveSniper(p1: int): boolean { return !!inv('0x80BB243789008A82', this.ped.handle, p1, rai()); } /** * Returns the ped's default unarmed weapon hash as defined in CPedModelInfo (DefaultUnarmedWeapon). * Falls back to WEAPON_UNARMED if the ped doesn't have a valid model info pointer, or 0 if the ped doesn't exist. * * @returns */ get DefaultUnarmedWeaponHash(): number { return (inv('0x08FF1099ED2E6E21', this.ped.handle, rai())) & 0xFFFFFFFF; } /** * @param weaponHash * @param p2 Refer to {@link eWeaponHash} * @returns */ getMaxAmmoInClip(weaponHash: eWeaponHash, p2: boolean): int { return inv('0xA38DCFFCEA8962FA', this.ped.handle, weaponHash, p2, rai()); } /** * @param attachPoint * @returns Returns the weapon entity */ getCurrentPedWeaponEntityIndex(attachPoint: int): Entity | null { return createFromHandle('Entity', inv('0x3B390A939AF0B5FC', this.ped.handle, attachPoint, rai())); } }