Skip to content

Update spechud.sp - MP5 reserve ammo - #1030

Merged
SirPlease merged 2 commits into
SirPlease:masterfrom
theletterjwithadot:spechud-mp5-ammo
Nov 3, 2026
Merged

SirPlease merged 2 commits into
SirPlease:masterfrom
theletterjwithadot:spechud-mp5-ammo

Conversation

@theletterjwithadot

Copy link
Copy Markdown
Contributor

Update spechud.sp - MP5 reserve ammo

spechud.sp 3.9.2

  • Fixed the MP5's reserve ammo showing as -1 - the MP5 shares the SMG ammo slot but was missing from the SMG case in GetWeaponExtraAmmo.

@nikita1824

nikita1824 commented Oct 30, 2026 •

Copy link
Copy Markdown

Hello, there is better method:

// m_iAmmo
int GetWeaponExtraAmmo(int iClient, int iWeapon) {
    // Offsets to setting reserve ammo
    static int iOffs_Ammo = -1;
    if (iOffs_Ammo == -1)
        iOffs_Ammo = FindSendPropInfo("CTerrorPlayer", "m_iAmmo");

    static int iOffs_PrimaryAmmoType = -1;
    if (iOffs_PrimaryAmmoType == -1)
        iOffs_PrimaryAmmoType = FindSendPropInfo("CBaseCombatWeapon", "m_iPrimaryAmmoType");

    if (iWeapon <= 0)
        return 0;

    // Thanks to "Root" or whoever for this method of not hard-coding offsets: https://github.com/zadroot/AmmoManager/blob/master/scripting/ammo_manager.sp
    int iOffset = GetEntData(iWeapon, iOffs_PrimaryAmmoType) * 4;
    if (iOffset <= 0)
        return 0;

    return GetEntData(iClient, iOffs_Ammo + iOffset);
}

@SirPlease

Copy link
Copy Markdown
Owner

Pushed a follow-up that reads the reserve through the weapon's m_iPrimaryAmmoType, along the lines of nikita1824's suggestion, so no weapon needs a table entry (this also fixes the M60).

@SirPlease
SirPlease merged commit b32c7e8 into SirPlease:master Nov 3, 2026
1 of 2 checks passed
@theletterjwithadot
theletterjwithadot deleted the spechud-mp5-ammo branch November 3, 2026 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants