Skip to content

Update spechud.sp - MP5 reserve ammo - #1030

Open
theletterjwithadot wants to merge 1 commit into
SirPlease:masterfrom
theletterjwithadot:spechud-mp5-ammo
Open

theletterjwithadot wants to merge 1 commit 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:

int g_iOffsetAmmo;
int g_iPrimaryAmmoType;

public void OnPluginStart() {
    // Offsets to setting reserve ammo
    g_iOffsetAmmo      = FindSendPropInfo("CTerrorPlayer",     "m_iAmmo");
    g_iPrimaryAmmoType = FindSendPropInfo("CBaseCombatWeapon", "m_iPrimaryAmmoType");
}

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

    int iOffset = GetEntData(iWeapon, g_iPrimaryAmmoType) * 4;
    if (iOffset <= 0)
        return 0;

    return GetEntData(iClient, g_iOffsetAmmo + iOffset);
}

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.

2 participants