public WeaponComponent this[WeaponComponentHash componentHash]
        {
            get
            {
                if (_components.Contains(componentHash))
                {
                    WeaponComponent component = null;
                    if (!_weaponComponents.TryGetValue(componentHash, out component))
                    {
                        component = new WeaponComponent(_owner, _weapon, componentHash);
                        _weaponComponents.Add(componentHash, component);
                    }

                    return(component);
                }
                else
                {
                    return(_invalidComponent);
                }
            }
        }
        public WeaponComponent this[int index]
        {
            get
            {
                WeaponComponent component = null;
                if (index >= 0 && index < Count)
                {
                    WeaponComponentHash componentHash = _components[index];

                    if (!_weaponComponents.TryGetValue(componentHash, out component))
                    {
                        component = new WeaponComponent(_owner, _weapon, componentHash);
                        _weaponComponents.Add(componentHash, component);
                    }
                    return(component);
                }
                else
                {
                    return(_invalidComponent);
                }
            }
        }
Exemple #3
0
        public static string GetComponentDisplayNameFromHash(WeaponHash hash, WeaponComponent component)
        {
            if (hash == WeaponHash.KnuckleDuster)
            {
                switch (component)
                {
                case WeaponComponent.KnuckleVarmodBase:
                    return("WT_KNUCKLE");

                case WeaponComponent.KnuckleVarmodPimp:
                    return("WCT_KNUCK_02");

                case WeaponComponent.KnuckleVarmodBallas:
                    return("WCT_KNUCK_BG");

                case WeaponComponent.KnuckleVarmodDollar:
                    return("WCT_KNUCK_DLR");

                case WeaponComponent.KnuckleVarmodDiamond:
                    return("WCT_KNUCK_DMD");

                case WeaponComponent.KnuckleVarmodHate:
                    return("WCT_KNUCK_HT");

                case WeaponComponent.KnuckleVarmodLove:
                    return("WCT_KNUCK_LV");

                case WeaponComponent.KnuckleVarmodPlayer:
                    return("WCT_KNUCK_PC");

                case WeaponComponent.KnuckleVarmodKing:
                    return("WCT_KNUCK_SLG");

                case WeaponComponent.KnuckleVarmodVagos:
                    return("WCT_KNUCK_VG");
                }
            }
            else
            {
                switch (component)
                {
                case WeaponComponent.AtRailCover01:
                    return("WCT_RAIL");

                case WeaponComponent.AtArAfGrip:
                    return("WCT_GRIP");

                case WeaponComponent.AtPiFlsh:
                case WeaponComponent.AtArFlsh:
                    return("WCT_FLASH");

                case WeaponComponent.AtScopeMacro:
                    return("WCT_SCOPE_MAC");

                case WeaponComponent.AtScopeMacro02:
                    return("WCT_SCOPE_MAC");

                case WeaponComponent.AtScopeSmall:
                    return("WCT_SCOPE_SML");

                case WeaponComponent.AtScopeSmall02:
                    return("WCT_SCOPE_SML");

                case WeaponComponent.AtScopeMedium:
                    return("WCT_SCOPE_MED");

                case WeaponComponent.AtScopeLarge:
                    return("WCT_SCOPE_LRG");

                case WeaponComponent.AtScopeMax:
                    return("WCT_SCOPE_MAX");

                case WeaponComponent.AtPiSupp:
                case WeaponComponent.AtArSupp:
                case WeaponComponent.AtArSupp02:
                case WeaponComponent.AtSrSupp:
                    return("WCT_SUPP");

                case WeaponComponent.PistolClip01:
                case WeaponComponent.CombatPistolClip01:
                case WeaponComponent.APPistolClip01:
                case WeaponComponent.MicroSMGClip01:
                case WeaponComponent.AssaultRifleClip01:
                case WeaponComponent.CarbineRifleClip01:
                case WeaponComponent.AdvancedRifleClip01:
                case WeaponComponent.MGClip01:
                case WeaponComponent.CombatMGClip01:
                case WeaponComponent.AssaultShotgunClip01:
                case WeaponComponent.SniperRifleClip01:
                case WeaponComponent.HeavySniperClip01:
                case WeaponComponent.AssaultSMGClip01:
                case WeaponComponent.Pistol50Clip01:
                case (WeaponComponent)0x0BAAB157:
                case (WeaponComponent)0x5AF49386:
                case (WeaponComponent)0xCAEBD246:
                case (WeaponComponent)0xF8955D89:
                case WeaponComponent.SNSPistolClip01:
                case WeaponComponent.VintagePistolClip01:
                case WeaponComponent.HeavyShotgunClip01:
                case WeaponComponent.MarksmanRifleClip01:
                case WeaponComponent.CombatPDWClip01:
                case WeaponComponent.MarksmanPistolClip01:
                case WeaponComponent.MachinePistolClip01:
                    return("WCT_CLIP1");

                case WeaponComponent.PistolClip02:
                case WeaponComponent.CombatPistolClip02:
                case WeaponComponent.APPistolClip02:
                case WeaponComponent.MicroSMGClip02:
                case WeaponComponent.SMGClip02:
                case WeaponComponent.AssaultRifleClip02:
                case WeaponComponent.CarbineRifleClip02:
                case WeaponComponent.AdvancedRifleClip02:
                case WeaponComponent.MGClip02:
                case WeaponComponent.CombatMGClip02:
                case WeaponComponent.AssaultShotgunClip02:
                case WeaponComponent.MinigunClip01:
                case WeaponComponent.AssaultSMGClip02:
                case WeaponComponent.Pistol50Clip02:
                case (WeaponComponent)0x6CBF371B:
                case (WeaponComponent)0xE1C5FFFA:
                case (WeaponComponent)0x3E7E6956:
                case WeaponComponent.SNSPistolClip02:
                case WeaponComponent.VintagePistolClip02:
                case WeaponComponent.HeavyShotgunClip02:
                case WeaponComponent.MarksmanRifleClip02:
                case WeaponComponent.CombatPDWClip02:
                case WeaponComponent.MachinePistolClip02:
                    return("WCT_CLIP2");

                case WeaponComponent.AtScopeLargeFixedZoom:
                    return("WCT_SCOPE_LRG");

                case WeaponComponent.AtPiSupp02:
                    return("WCT_SUPP");

                case WeaponComponent.AssaultRifleVarmodLuxe:
                case WeaponComponent.CarbineRifleVarmodLuxe:
                case WeaponComponent.PistolVarmodLuxe:
                case WeaponComponent.SMGVarmodLuxe:
                case WeaponComponent.MicroSMGVarmodLuxe:
                case (WeaponComponent)0x161E9241:
                case WeaponComponent.AssaultSMGVarmodLowrider:
                case WeaponComponent.CombatPistolVarmodLowrider:
                case WeaponComponent.MGVarmodLowrider:
                case WeaponComponent.PumpShotgunVarmodLowrider:
                    return("WCT_VAR_GOLD");

                case WeaponComponent.AdvancedRifleVarmodLuxe:
                case WeaponComponent.APPistolVarmodLuxe:
                case WeaponComponent.SawnoffShotgunVarmodLuxe:
                case WeaponComponent.BullpupRifleVarmodLow:
                    return("WCT_VAR_METAL");

                case WeaponComponent.Pistol50VarmodLuxe:
                    return("WCT_VAR_SIL");

                case WeaponComponent.HeavyPistolVarmodLuxe:
                case WeaponComponent.SniperRifleVarmodLuxe:
                case WeaponComponent.SNSPistolVarmodLowrider:
                    return("WCT_VAR_WOOD");

                case WeaponComponent.CombatMGVarmodLowrider:
                case WeaponComponent.SpecialCarbineVarmodLowrider:
                    return("WCT_VAR_ETCHM");

                case WeaponComponent.SwitchbladeVarmodBase:
                    return("WCT_SB_BASE");

                case WeaponComponent.SwitchbladeVarmodVar1:
                    return("WCT_SB_VAR1");

                case WeaponComponent.SwitchbladeVarmodVar2:
                    return("WCT_SB_VAR2");

                case WeaponComponent.RevolverClip01:
                    return("WCT_CLIP1");

                case WeaponComponent.RevolverVarmodBoss:
                    return("WCT_REV_VARB");

                case WeaponComponent.RevolverVarmodGoon:
                    return("WCT_REV_VARG");

                case WeaponComponent.SMGClip03:
                case WeaponComponent.AssaultRifleClip03:
                case WeaponComponent.HeavyShotgunClip03:
                    return("WCT_CLIP_DRM");

                case WeaponComponent.CarbineRifleClip03:
                    return("WCT_CLIP_BOX");
                }
            }

            IntPtr data   = Marshal.AllocCoTaskMem(39 * 8);
            string result = string.Empty;

            for (int i = 0, count = Function.Call <int>(Native.Hash.GET_NUM_DLC_WEAPONS); i < count; i++)
            {
                if (Function.Call <bool>(Native.Hash.GET_DLC_WEAPON_DATA, i, data))
                {
                    if (MemoryAccess.ReadInt(data + 8) == (int)hash)
                    {
                        int maxComp = Function.Call <int>(Native.Hash.GET_NUM_DLC_WEAPON_COMPONENTS, i);

                        for (int j = 0; j < maxComp; j++)
                        {
                            if (Function.Call <bool>(Native.Hash.GET_DLC_WEAPON_COMPONENT_DATA, i, j, data))
                            {
                                if (MemoryAccess.ReadInt(data + 3 * 8) == (int)component)
                                {
                                    result = MemoryAccess.ReadString(data + 6 * 8);
                                    break;
                                }
                            }
                        }
                        break;
                    }
                }
            }

            Marshal.FreeCoTaskMem(data);

            return(result);
        }
Exemple #4
0
        public static WeaponComponent[] GetComponentsFromHash(WeaponHash hash)
        {
            switch (hash)
            {
            case WeaponHash.Pistol:
                return(new WeaponComponent[] {
                    WeaponComponent.PistolClip01,
                    WeaponComponent.PistolClip02,
                    WeaponComponent.AtPiFlsh,
                    WeaponComponent.AtPiSupp02,
                    WeaponComponent.PistolVarmodLuxe,
                });

            case WeaponHash.CombatPistol:
                return(new WeaponComponent[] {
                    WeaponComponent.CombatPistolClip01,
                    WeaponComponent.CombatPistolClip02,
                    WeaponComponent.AtPiFlsh,
                    WeaponComponent.AtPiSupp,
                    WeaponComponent.CombatPistolVarmodLowrider,
                });

            case WeaponHash.APPistol:
                return(new WeaponComponent[] {
                    WeaponComponent.APPistolClip01,
                    WeaponComponent.APPistolClip02,
                    WeaponComponent.AtPiFlsh,
                    WeaponComponent.AtPiSupp,
                    WeaponComponent.APPistolVarmodLuxe,
                });

            case WeaponHash.MicroSMG:
                return(new WeaponComponent[] {
                    WeaponComponent.MicroSMGClip01,
                    WeaponComponent.MicroSMGClip02,
                    WeaponComponent.AtPiFlsh,
                    WeaponComponent.AtScopeMacro,
                    WeaponComponent.AtArSupp02,
                    WeaponComponent.MicroSMGVarmodLuxe,
                });

            case WeaponHash.SMG:
                return(new WeaponComponent[] {
                    WeaponComponent.SMGClip01,
                    WeaponComponent.SMGClip02,
                    WeaponComponent.SMGClip03,
                    WeaponComponent.AtArFlsh,
                    WeaponComponent.AtPiSupp,
                    WeaponComponent.AtScopeMacro02,
                    WeaponComponent.AtArAfGrip,
                    WeaponComponent.SMGVarmodLuxe,
                });

            case WeaponHash.AssaultRifle:
                return(new WeaponComponent[] {
                    WeaponComponent.AssaultRifleClip01,
                    WeaponComponent.AssaultRifleClip02,
                    WeaponComponent.AssaultRifleClip03,
                    WeaponComponent.AtArAfGrip,
                    WeaponComponent.AtArFlsh,
                    WeaponComponent.AtScopeMacro,
                    WeaponComponent.AtArSupp02,
                    WeaponComponent.AssaultRifleVarmodLuxe,
                });

            case WeaponHash.CarbineRifle:
                return(new WeaponComponent[] {
                    WeaponComponent.CarbineRifleClip01,
                    WeaponComponent.CarbineRifleClip02,
                    WeaponComponent.CarbineRifleClip03,
                    WeaponComponent.AtRailCover01,
                    WeaponComponent.AtArAfGrip,
                    WeaponComponent.AtArFlsh,
                    WeaponComponent.AtScopeMedium,
                    WeaponComponent.AtArSupp,
                    WeaponComponent.CarbineRifleVarmodLuxe,
                });

            case WeaponHash.AdvancedRifle:
                return(new WeaponComponent[] {
                    WeaponComponent.AdvancedRifleClip01,
                    WeaponComponent.AdvancedRifleClip02,
                    WeaponComponent.AtArFlsh,
                    WeaponComponent.AtScopeSmall,
                    WeaponComponent.AtArSupp,
                    WeaponComponent.AdvancedRifleVarmodLuxe,
                });

            case WeaponHash.MG:
                return(new WeaponComponent[] {
                    WeaponComponent.MGClip01,
                    WeaponComponent.MGClip02,
                    WeaponComponent.AtScopeSmall02,
                    WeaponComponent.AtArAfGrip,
                    WeaponComponent.MGVarmodLowrider,
                });

            case WeaponHash.CombatMG:
                return(new WeaponComponent[] {
                    WeaponComponent.CombatMGClip01,
                    WeaponComponent.CombatMGClip02,
                    WeaponComponent.AtArAfGrip,
                    WeaponComponent.AtScopeMedium,
                    WeaponComponent.CombatMGVarmodLowrider,
                });

            case WeaponHash.PumpShotgun:
                return(new WeaponComponent[] {
                    WeaponComponent.AtSrSupp,
                    WeaponComponent.AtArFlsh,
                    WeaponComponent.PumpShotgunVarmodLowrider,
                });

            case WeaponHash.AssaultShotgun:
                return(new WeaponComponent[] {
                    WeaponComponent.AssaultShotgunClip01,
                    WeaponComponent.AssaultShotgunClip02,
                    WeaponComponent.AtArAfGrip,
                    WeaponComponent.AtArFlsh,
                    WeaponComponent.AtArSupp,
                });

            case WeaponHash.SniperRifle:
                return(new WeaponComponent[] {
                    WeaponComponent.SniperRifleClip01,
                    WeaponComponent.AtScopeLarge,
                    WeaponComponent.AtScopeMax,
                    WeaponComponent.AtArSupp02,
                    WeaponComponent.SniperRifleVarmodLuxe,
                });

            case WeaponHash.HeavySniper:
                return(new WeaponComponent[] {
                    WeaponComponent.HeavySniperClip01,
                    WeaponComponent.AtScopeLarge,
                    WeaponComponent.AtScopeMax,
                });

            case WeaponHash.GrenadeLauncher:
                return(new WeaponComponent[] {
                    WeaponComponent.AtArAfGrip,
                    WeaponComponent.AtArFlsh,
                    WeaponComponent.AtScopeSmall,
                });

            case WeaponHash.Minigun:
                return(new WeaponComponent[] {
                    WeaponComponent.MinigunClip01,
                });

            case WeaponHash.AssaultSMG:
                return(new WeaponComponent[] {
                    WeaponComponent.AssaultSMGClip01,
                    WeaponComponent.AssaultSMGClip02,
                    WeaponComponent.AtArFlsh,
                    WeaponComponent.AtScopeMacro,
                    WeaponComponent.AtArSupp02,
                    WeaponComponent.AssaultSMGVarmodLowrider,
                });

            case WeaponHash.BullpupShotgun:
                return(new WeaponComponent[] {
                    WeaponComponent.AtArAfGrip,
                    WeaponComponent.AtArFlsh,
                    WeaponComponent.AtArSupp02,
                });

            case WeaponHash.Pistol50:
                return(new WeaponComponent[] {
                    WeaponComponent.Pistol50Clip01,
                    WeaponComponent.Pistol50Clip02,
                    WeaponComponent.AtPiFlsh,
                    WeaponComponent.AtArSupp02,
                    WeaponComponent.Pistol50VarmodLuxe,
                });

            case WeaponHash.CombatPDW:
                return(new WeaponComponent[] {
                    WeaponComponent.CombatPDWClip01,
                    WeaponComponent.CombatPDWClip02,
                    WeaponComponent.CombatPDWClip03,
                    WeaponComponent.AtArFlsh,
                    WeaponComponent.AtScopeSmall,
                    WeaponComponent.AtArAfGrip,
                });

            case WeaponHash.SawnOffShotgun:
                return(new WeaponComponent[] {
                    WeaponComponent.SawnoffShotgunVarmodLuxe,
                });

            case WeaponHash.BullpupRifle:
                return(new WeaponComponent[] {
                    WeaponComponent.BullpupRifleClip01,
                    WeaponComponent.BullpupRifleClip02,
                    WeaponComponent.AtArFlsh,
                    WeaponComponent.AtScopeSmall,
                    WeaponComponent.AtArSupp,
                    WeaponComponent.AtArAfGrip,
                    WeaponComponent.BullpupRifleVarmodLow,
                });

            case WeaponHash.SNSPistol:
                return(new WeaponComponent[] {
                    WeaponComponent.SNSPistolClip01,
                    WeaponComponent.SNSPistolClip02,
                    WeaponComponent.SNSPistolVarmodLowrider,
                });

            case WeaponHash.SpecialCarbine:
                return(new WeaponComponent[] {
                    WeaponComponent.SpecialCarbineClip01,
                    WeaponComponent.SpecialCarbineClip02,
                    WeaponComponent.SpecialCarbineClip03,
                    WeaponComponent.AtArFlsh,
                    WeaponComponent.AtScopeMedium,
                    WeaponComponent.AtArSupp02,
                    WeaponComponent.AtArAfGrip,
                    WeaponComponent.SpecialCarbineVarmodLowrider,
                });

            case WeaponHash.KnuckleDuster:
                return(new WeaponComponent[] {
                    WeaponComponent.KnuckleVarmodPimp,
                    WeaponComponent.KnuckleVarmodBallas,
                    WeaponComponent.KnuckleVarmodDollar,
                    WeaponComponent.KnuckleVarmodDiamond,
                    WeaponComponent.KnuckleVarmodHate,
                    WeaponComponent.KnuckleVarmodLove,
                    WeaponComponent.KnuckleVarmodPlayer,
                    WeaponComponent.KnuckleVarmodKing,
                    WeaponComponent.KnuckleVarmodVagos,
                });

            case WeaponHash.MachinePistol:
                return(new WeaponComponent[] {
                    WeaponComponent.MachinePistolClip01,
                    WeaponComponent.MachinePistolClip02,
                    WeaponComponent.MachinePistolClip03,
                    WeaponComponent.AtPiSupp,
                });

            case WeaponHash.SwitchBlade:
                return(new WeaponComponent[] {
                    WeaponComponent.SwitchbladeVarmodVar1,
                    WeaponComponent.SwitchbladeVarmodVar2,
                });

            case WeaponHash.Revolver:
                return(new WeaponComponent[] {
                    WeaponComponent.RevolverClip01,
                    WeaponComponent.RevolverVarmodBoss,
                    WeaponComponent.RevolverVarmodGoon,
                });
            }

            IntPtr data = Marshal.AllocCoTaskMem(39 * 8);

            WeaponComponent[] result = null;

            for (int i = 0, count = Function.Call <int>(Native.Hash.GET_NUM_DLC_WEAPONS); i < count; i++)
            {
                if (Function.Call <bool>(Native.Hash.GET_DLC_WEAPON_DATA, i, data))
                {
                    if (MemoryAccess.ReadInt(data + 8) == (int)hash)
                    {
                        result = new WeaponComponent[Function.Call <int>(Native.Hash.GET_NUM_DLC_WEAPON_COMPONENTS, i)];

                        for (int j = 0; j < result.Length; j++)
                        {
                            if (Function.Call <bool>(Native.Hash.GET_DLC_WEAPON_COMPONENT_DATA, i, j, data))
                            {
                                result[j] = (WeaponComponent)MemoryAccess.ReadInt(data + 3 * 8);
                            }
                            else
                            {
                                result[j] = WeaponComponent.Invalid;
                            }
                        }
                        break;
                    }
                }
            }

            Marshal.FreeCoTaskMem(data);

            if (result == null)
            {
                result = new WeaponComponent[0];
            }

            return(result);
        }
Exemple #5
0
 public bool IsComponentActive(WeaponComponent component)
 {
     return(Function.Call <bool>(Native.Hash.HAS_PED_GOT_WEAPON_COMPONENT, _owner.Handle, Hash, component));
 }
Exemple #6
0
 public string GetComponentName(WeaponComponent component)
 {
     return(Game.GetGXTEntry(GetComponentDisplayNameFromHash(Hash, component)));
 }