Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    1. Red Dead Redemption 2

      1. Gameplay
      2. Missions
      3. Help & Support
    2. Red Dead Online

      1. Gameplay
      2. Find Lobbies & Outlaws
      3. Help & Support
    1. Crews & Posses

      1. Recruitment
    2. Events

    1. GTA Online

      1. Arena War
      2. After Hours
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Grand Theft Auto Series

    3. GTA Next

    4. GTA V

      1. PC
      2. Guides & Strategies
      3. Help & Support
    5. GTA IV

      1. Episodes from Liberty City
      2. Multiplayer
      3. Guides & Strategies
      4. Help & Support
      5. GTA Mods
    6. GTA Chinatown Wars

    7. GTA Vice City Stories

    8. GTA Liberty City Stories

    9. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    10. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    11. GTA III

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    12. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    13. Wiki

      1. Merchandising
    1. GTA Modding

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    3. Featured Mods

      1. DYOM
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Red Dead Redemption

    2. Rockstar Games

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Programming
      5. Movies & TV
      6. Music
      7. Sports
      8. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. News

    2. Forum Support

    3. Site Suggestions

Sign in to follow this  
motorsport71

Walk me through Gun Components and Addons if you would?

Recommended Posts

motorsport71

So the whole gun components and addons system has me completely frazzled. I have looked through all of the other findings but still cannot make them work for myself. I am using vb but if someone has a working example in C# that would be great to.

 

 

So, first off, if i try this:

Dim weapon As Integer = GTA.Native.Function.Call(Of Integer)(Hash.GET_SELECTED_PED_WEAPON, Game.Player.Character)GTA.Native.Function.Call(Hash.GIVE_WEAPON_COMPONENT_TO_PED, Game.Player.Character, weapon, "COMPONENT_AT_AR_FLSH")

So with my player.character holding the Special Carbine "weapon" it should attach a flashlight to it, right? Not only do i not get a light, my ammo is depleted as well. I verified there are no attachments on the gun in the weapon wheel as well.

 

Now there are a couple of different natives revolving around weapon components. First:

 

GIVE_WEAPON_COMPONENT_TO_WEAPON_OBJECT(Entity weaponObject, Hash addonHash)

 

 

And second:

 

 

GIVE_WEAPON_COMPONENT_TO_PED(Ped ped, Hash weaponHash, Hash componentHash)

 

 

So, with the information i found here:

 

https://www.teamofweaponsandtactics.com/index.php?/departments/dept_it/grand-theft-auto-v-modification-development/model_db_weapons/

 

They have it listed out that some parts are components while others are addons. I've tried all manors of configurations, hashes, etc. but no luck.

 

Any help so i can figure this out would be greatly appreciated.

 

Thanks

Share this post


Link to post
Share on other sites
CamxxCore

So the whole gun components and addons system has me completely frazzled. I have looked through all of the other findings but still cannot make them work for myself. I am using vb but if someone has a working example in C# that would be great to.

 

 

So, first off, if i try this:

Dim weapon As Integer = GTA.Native.Function.Call(Of Integer)(Hash.GET_SELECTED_PED_WEAPON, Game.Player.Character)GTA.Native.Function.Call(Hash.GIVE_WEAPON_COMPONENT_TO_PED, Game.Player.Character, weapon, "COMPONENT_AT_AR_FLSH")

So with my player.character holding the Special Carbine "weapon" it should attach a flashlight to it, right? Not only do i not get a light, my ammo is depleted as well. I verified there are no attachments on the gun in the weapon wheel as well.

 

Now there are a couple of different natives revolving around weapon components. First:

 

GIVE_WEAPON_COMPONENT_TO_WEAPON_OBJECT(Entity weaponObject, Hash addonHash)

 

 

And second:

 

 

GIVE_WEAPON_COMPONENT_TO_PED(Ped ped, Hash weaponHash, Hash componentHash)

 

 

So, with the information i found here:

 

https://www.teamofweaponsandtactics.com/index.php?/departments/dept_it/grand-theft-auto-v-modification-development/model_db_weapons/

 

They have it listed out that some parts are components while others are addons. I've tried all manors of configurations, hashes, etc. but no luck.

 

Any help so i can figure this out would be greatly appreciated.

 

Thanks

 

Here is some code from a script I made a while back. I never really got around to finishing so it might look a little strange. Should point you in the right direction though. The issue with your code is you are supplying a string to the function when it takes a hash.

   public bool GiveWeaponComponent(WeaponComponent component)        {            var hash = WeaponComponentHash.None;            var weapon = Game.Player.Character.Weapons.Current;            var weaponType = Helpers.GetWeaponType(weapon);            if (component == WeaponComponent.ArmyCamo ||                component == WeaponComponent.GoldCamo ||                component == WeaponComponent.GreenCamo ||                component == WeaponComponent.LSPDCamo ||                component == WeaponComponent.OrangeCamo ||                component == WeaponComponent.PinkCamo ||                component == WeaponComponent.PlatinumCamo)            {                Function.Call(Hash.SET_PED_WEAPON_TINT_INDEX, _ped.Handle, (int)weapon.Hash, (int)component);                if (Function.Call<int>(Hash.GET_PED_WEAPON_TINT_INDEX, _ped.Handle, (int)weapon.Hash) == (int)component)                    return true;                else return false;            }            else            {                if (weaponType == WeaponType.Pistol)                {                    if (component == WeaponComponent.ExtendedClip)                    {                        if (weapon.Hash == WeaponHash.SNSPistol)                        {                            hash = WeaponComponentHash.SNSPistolClip1;                        }                        else if (weapon.Hash == WeaponHash.HeavyPistol)                        {                            hash = WeaponComponentHash.HeavyPistolClip1;                        }                        else hash = WeaponComponentHash.HeavyPistolClip1;                    }                    else if (component == WeaponComponent.Flashlight)                    {                        hash = WeaponComponentHash.PistolFlashlight;                    }                    else if (component == WeaponComponent.Supressor)                    {                        hash = WeaponComponentHash.PistolSupressor;                    }                }                else if (weaponType == WeaponType.Carbine)                {                    if (component == WeaponComponent.Flashlight)                    {                        hash = WeaponComponentHash.AssaultRifleFlashlight;                    }                    else if (component == WeaponComponent.ExtendedClip)                    {                        hash = WeaponComponentHash.SpecialCarbineClip1;                    }                    else if (component == WeaponComponent.Scope)                    {                        hash = WeaponComponentHash.MediumScope;                    }                    else if (component == WeaponComponent.Supressor)                    {                        hash = WeaponComponentHash.AssaultRifleSupressor;                    }                    else if (component == WeaponComponent.Grip)                    {                        hash = WeaponComponentHash.AssaultRifleGrip;                    }                }                else if (weaponType == WeaponType.Rifle || weaponType == WeaponType.SMG || weaponType == WeaponType.Shotgun || weaponType == WeaponType.MG)                {                    if (component == WeaponComponent.ExtendedClip)                    {                        hash = WeaponComponentHash.SpecialCarbineClip1;                    }                    else if (component == WeaponComponent.Flashlight)                    {                        hash = WeaponComponentHash.AssaultRifleFlashlight;                    }                    else if (component == WeaponComponent.Supressor)                    {                        if (weapon.Hash == WeaponHash.PumpShotgun)                            hash = WeaponComponentHash.UnknownSupressor;                        else                            hash = WeaponComponentHash.AssaultRifleSupressor;                    }                    else if (component == WeaponComponent.Grip)                    {                        hash = WeaponComponentHash.AssaultRifleGrip;                    }                    else if (component == WeaponComponent.Scope)                    {                        if (weapon.Hash == WeaponHash.AdvancedRifle)                            hash = WeaponComponentHash.SmallScope;                        else if (weapon.Hash == WeaponHash.MG || weapon.Hash == WeaponHash.CombatMG)                            hash = WeaponComponentHash.MediumScope;                        else if (weapon.Hash == WeaponHash.MarksmanRifle)                            hash = WeaponComponentHash.LargeScope;                        else if (weapon.Hash == WeaponHash.AssaultRifle || weapon.Hash == WeaponHash.AssaultSMG)                            hash = WeaponComponentHash.MacroScope;                    }                }                else if (weaponType == WeaponType.Sniper)                {                    if (component == WeaponComponent.Supressor)                    {                        hash = WeaponComponentHash.AssaultRifleSupressor2;                    }                    else if (component == WeaponComponent.Scope)                    {                        hash = WeaponComponentHash.LargeScope;                    }                }                Function.Call(Hash.GIVE_WEAPON_COMPONENT_TO_PED, _ped.Handle, (int)weapon.Hash, (int)hash);                if (Function.Call<bool>(Hash.HAS_PED_GOT_WEAPON_COMPONENT, _ped.Handle, (int)weapon.Hash, (int)hash)) return true;                else return false;            }        }
public enum WeaponComponent    {        GreenCamo,        GoldCamo,        PinkCamo,        ArmyCamo,        LSPDCamo,        OrangeCamo,        PlatinumCamo,        Grip,        Flashlight,        ExtendedClip,        Supressor,        Scope    }
public enum WeaponComponentHash : uint    {        PistolFlashlight = 899381934,        PistolSupressor = 3271853210,        SmallScope = 2855028148,        MediumScope = 2698550338,        MacroScope = 2637152041,        LargeScope = 3527687644,        MaxScope = 3159677559,        AssaultRifleSupressor = 2205435306,        AssaultRifleSupressor2 = 2805810788,        AssaultRifleFlashlight = 2076495324,        SpecialCarbineClip1 = 3334989185,        SpecialCarbineClip2 = 2089537806,        HeavyPistolClip1 = 222992026,        HeavyPistolClip2 = 1694090795,        SNSPistolClip1 = 4169150169,        SNSPistolClip2 = 2063610803,        BullpupRifleClip1 = 3315675008,        BullpupRifleClip2 = 3009973007,        AssaultRifleGrip = 202788691,        UnknownSupressor = 3859329886,        None = 0    }
Edited by CamxxCore

Share this post


Link to post
Share on other sites
motorsport71

Thank you, I really appreciate it. I will check it out in the morning. I am glad to know right off the get go I wasn't using the hash properly.

Share this post


Link to post
Share on other sites
motorsport71

@CamxxCore Thanks, that was it. Much appreciated.

 

I did notice that if i try to add several weapon components at once only a few will apply. For example:

Dim Weapon As Integer = GTA.Native.Function.Call(Of Integer)(Hash.GET_SELECTED_PED_WEAPON, Game.Player.Character)If Weapon = -1357824103 Then            GTA.Native.Function.Call(Hash.GIVE_WEAPON_COMPONENT_TO_PED, Game.Player.Character, -1357824103, 2395064697)            GTA.Native.Function.Call(Hash.GIVE_WEAPON_COMPONENT_TO_PED, Game.Player.Character, -1357824103, 2076495324)            GTA.Native.Function.Call(Hash.GIVE_WEAPON_COMPONENT_TO_PED, Game.Player.Character, -1357824103, 2855028148)            GTA.Native.Function.Call(Hash.GIVE_WEAPON_COMPONENT_TO_PED, Game.Player.Character, -1357824103, 2205435306)            GTA.Native.Function.Call(Hash.SET_PED_AMMO, Game.Player.Character, -1357824103, 10000)        End If

In this instance only the Flashlight will show up: 2076495324.

In the case of the Special Carbine the extended clip and flashlight will apply, but the suppressor won't.

Edited by motorsport71

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • 3 Users Currently Viewing
    0 members, 0 Anonymous, 3 Guests

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.