Page 1 of 1

CS:S Issue - Impossible to use your grenade

Posted: Thu Apr 21, 2016 3:56 am
by iPlayer
Hi there!

I'm just going to describe the issue in hope that somebody might have experienced it before and knows how to fix it. Because I've yet to figure out the conditions for this problem to happen, it can happen occasionally, and the only relatively stable way I've found to reproduce it is too complicated - when trying to simplify it, detach all things that are related to my plugin, the problem disappears.

So. If only may happen if you:
1. Only have a grenade, let's say weapon_flashbang equipped - no knife or other weapons
2. You throw it

Now, normally your character would've gone reference pose - you know that pose - because there're no weapons on him. Upon receiving another flashbang via GiveNamedItem, he would've automatically switched to that flashbang. And then he would've been able to throw it again.

Think of it as of a flashbang battle.

But when the subject problem occurs, your character doesn't go reference pose. Instead, he remains holding his non-existing flashbang. Upon receiving another flashbang, nothing happens. What is interesting, there's no viewmodel on his screen. What is sad, he can't use the new flashbang anymore. He just runs around with this flashbang in his hand. He does own it, he drops it on death.

If nobody has a clue, then I'll do my best to give a working code. But maybe anyone knows what I am talking about? Or maybe just wants to give some hints on what tests to run? Thanks.

Re: CS:S Issue - Impossible to use your grenade

Posted: Thu Apr 21, 2016 4:27 am
by iPlayer
After a bit of research, it turns out that the original weapon_flashbang is still in player's loadout even after flashbang_projectile has been spawned. How? It's present in player's m_hMyWeapons table, has valid index, I was able to get an edict out of that index.

I could probably drop that flashbang and remove that prior to giving a new one, but that's a workaround - I want to know how to prevent such thing from happening.

Re: CS:S Issue - Impossible to use your grenade

Posted: Thu Apr 21, 2016 4:56 am
by L'In20Cible
Did you try to force the player to use it after giving him a new flashbang?

Syntax: Select all

Player.client_command('use weapon_flashbang', server_side=True)

Re: CS:S Issue - Impossible to use your grenade

Posted: Thu Apr 21, 2016 6:33 am
by iPlayer
Tried that, didn't work. Well, the problem is that the original flashbang doesn't for some reason fully disappear from the loadout.

Re: CS:S Issue - Impossible to use your grenade

Posted: Thu Apr 21, 2016 6:56 am
by iPlayer
Okay, I'm sorry, the grenade remained in the loadout because I've had a parallel interval running that was maxing ammo of all weapons.

So, the code to reproduce the issue is

Code: Select all

from commands.client import ClientCommand
from entities.entity import Entity
from players.entity import Player

from mathlib import NULL_VECTOR


@ClientCommand('testme')
def client_testme(command, index):
    player = Player(index)
   
    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_flashbang', 0)
    player.set_ammo('weapon_flashbang', 2)