Page 1 of 1

[CSGO] Setting ammo doesn't work

Posted: Tue Apr 12, 2016 8:08 pm
by VinciT
I can't get set_ammo to work in CSGO. Setting the weapon clip works fine, but setting the weapon ammo only changes the ammo count on the UI.
As soon as you either reload or drop and pick up the weapon again, the ammo will revert to the previous value.

Syntax: Select all

#set_ammo_test.py
from events import Event
from mathlib import NULL_VECTOR

from entities.entity import Entity

from players.entity import Player
from players.helpers import index_from_userid

from weapons.entity import Weapon
from listeners.tick import Delay

@Event('player_spawn')
def player_setup(game_event):
player = Player(index_from_userid(game_event.get_int('userid')))

for index in player.weapon_indexes():
weapon = Entity(index)
player.drop_weapon(weapon.pointer, NULL_VECTOR, NULL_VECTOR)
weapon.remove()

player.give_named_item('weapon_deagle', 0, None, True)
Delay(0, ammo_setup, player)

def ammo_setup(player):
player.set_secondary_clip(1)
player.set_secondary_ammo(1)

Am I messing something up, or is setting ammo broken in CSGO?

Posted: Tue Apr 12, 2016 8:34 pm
by satoon101
There is an issue for that already:
https://github.com/Source-Python-Dev-Team/Source.Python/issues/50

We have not yet gotten around to fully fixing that on CS:GO, yet. The issue is that they moved ownership of the extra ammo to the weapon itself instead of the player. So, it has to be handled differently than it used to. Not sure why they did this, as it really doesn't make sense to me, but whatever Valve...

Posted: Tue Apr 12, 2016 9:30 pm
by VinciT
My bad, forgot to check github. Thanks for the workaround, satoon.