Log in to reply
 

Can't add ammo for the MK2 weapons



  • Hi,

    I have been working on this mod that adds ammo to your gun, it works perfectly on normal ammo, but if use a MK2 weapon with a special MK2 ammo, the ammo wont go up.

    Can anyone help me with this problem?

    void GiveWeaponComponents(WeaponHash weaponHash, WeaponComponent weaponComponent, int weaponIndex, int ComponentsIndex)
        {
            if (Money >= WeaponsSpecialList[weaponIndex].ComponentsCost[ComponentsIndex])
            {
                _player.Weapons.Select(weaponHash);
                if (_player.Weapons.Current.Ammo >= _player.Weapons.Current.MaxAmmo)
                {
                    UI.Notify("You have the maximum amount of this item");
                    return;
                }
                else
                {
                    _player.Weapons.Current.SetComponent(weaponComponent, true);
                    _player.Weapons.Current.Ammo += 30;
    
                    Money -= WeaponsSpecialList[weaponIndex].ComponentsCost[ComponentsIndex];
                    UI.Notify("You have bought " + WeaponsSpecialList[weaponIndex].weaponComponentName[ComponentsIndex]);
                }
            }
            else
            {
                UI.Notify("You don't have enough money to buy this item");
            }
        }


  • Use the natives GET_PED_AMMO_TYPE_FROM_WEAPON and ADD_AMMO_TO_PED_BY_TYPE



  • @JustDancePC said in Can't add ammo for the MK2 weapons:

    ADD_AMMO_TO_PED_BY_TYPE

    if i use Function.Call(Hash.GET_PED_AMMO_TYPE_FROM_WEAPON, _player, weaponHash, 30); i will get a error that the "GET_PED_AMMO_TYPE_FROM_WEAPON" doesn't exit

    am i doing something wrong, dont really native functions



  • @Youni Well, yeah, you're not using the function correctly. You can use this site to check the correct parameters for most functions.

    That specific function only takes two parameters, the ped's handle, which is an int, and the weapon's hash, which is UInt. https://alloc8or.re/gta5/nativedb/?n=0x7FEAD38B326B9F74



  • You can check how i did it here ; https://github.com/Adopcalipt/New_Street_Phone_Missions/blob/main/NSPM_Contacts/NSPM_Contacts/Class1.cs

    Is a bit iffy as the player has tobe holding the weapon as you add the ammo, also it some times needs several add ammo calls before the ammo is filled.



  • Thanks for the replies, i appreciate both of you helping me.

    the problem is when i type the native function, it gives me an error, as if the function doesn't exist. see the picture to find out what i mean
    Picture



  • That's weird, it works for me. I'm using SHVDN 3.3.2
    alt text



  • @JustDancePC i also use the newest version, but i use the SHVDN2.dll for my script, is that wrong?



  • That's not the latest version, SHVDN2.dll is the version 2 of SHVDN, which is pretty old. The current version would be the SHVDN3.dll


Log in to reply
 

Looks like your connection to GTA5-Mods.com Forums was lost, please wait while we try to reconnect.