Page 1 of 1

How to get weapon's max ammo?

Posted: Wed Nov 04, 2015 3:25 pm
by Mahi
Say I want to give player ammo every time he jumps, if he doesn't have full ammo already:

Syntax: Select all

from entities.helpers import index_from_inthandle
from events import Event
from players.entity import PlayerEntity
from players.helpers import index_from_userid
from weapons.entity import WeaponEntity

@Event
def on_jump(event):
player = PlayerEntity(index_from_userid(event['userid']))
weapon = WeaponEntity(index_from_inthandle(player.active_weapon))
if weapon.ammo < weapon.max_ammo: # No such attr as max_ammo
weapon.ammo += 1

How would I get the weapon's maximum ammo? For example 90 for AK47 and 40 for M4A1-S in CS:GO

Posted: Wed Nov 04, 2015 3:41 pm
by necavi
If I remember correctly you're going to have to find the GetMaxAmmo (or something very similar) signature for the weapon entity - it isn't as easy as a simple entity property, unfortunately.

Posted: Wed Nov 04, 2015 4:19 pm
by Ayuto

Posted: Wed Nov 04, 2015 4:57 pm
by necavi
Bloody hell that's useful!

Posted: Wed Nov 04, 2015 7:25 pm
by satoon101
There are 4 weapons that we do not have the proper data for in CS:GO. I know that info is somewhere on the forums, but I don't remember if it is in the private section or public. I will look for it and post again when I get the chance tonight.

The issue with those weapons is they share the same classname as other weapons, making it much more difficult to store the data.

Posted: Fri Nov 06, 2015 3:13 am
by satoon101
Here is the information I found back in January, some of it might have changed since then:


The following entity class names are used for 2 different weapons each. The weapons are the ones you can choose between in the game's loadout screen:

  • weapon_hkp2000:

    • USP-S:
      • Clip: 12
      • AmmoProp: 12
      • MaxAmmo Cvar: ammo_357sig_small_max
    • P2000:
      • Clip: 13
      • AmmoProp: 10
      • MaxAmmo Cvar: ammo_357sig_max
  • weapon_m4a1:

    • M4A4:
      • Clip: 30
      • AmmoProp: 3
      • MaxAmmo Cvar: ammo_556mm_max
    • M4A1-S:
      • Clip: 20
      • AmmoProp: 4
      • MaxAmmo Cvar: ammo_556mm_small_max
  • weapon_p250:

    • P250:
      • Clip: 13
      • AmmoProp: 11
      • MaxAmmo Cvar: ammo_357sig_p250_max
    • CZ75-Auto:
      • Clip: 12
      • AmmoProp: 13
      • MaxAmmo Cvar: ammo_357sig_min_max