How to get weapon's max ammo?
Posted: Wed Nov 04, 2015 3:25 pm
Say I want to give player ammo every time he jumps, if he doesn't have full ammo already:
How would I get the weapon's maximum ammo? For example 90 for AK47 and 40 for M4A1-S in CS:GO
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