CS:S Issue - Impossible to use your grenade

All other Source.Python topics and issues.
User avatar
iPlayer
Developer
Posts: 590
Joined: Sat Nov 14, 2015 8:37 am
Location: Moscow
Contact:

CS:S Issue - Impossible to use your grenade

Postby iPlayer » Thu Apr 21, 2016 3:56 am

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.
Image /id/its_iPlayer
My plugins: Map Cycle • Killstreaker • DeadChat • Infinite Jumping • TripMines • AdPurge • Bot Damage • PLRBots • Entity AntiSpam

Hail, Companion. [...] Hands to yourself, sneak thief. Image
User avatar
iPlayer
Developer
Posts: 590
Joined: Sat Nov 14, 2015 8:37 am
Location: Moscow
Contact:

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

Postby iPlayer » Thu Apr 21, 2016 4:27 am

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.
Image /id/its_iPlayer
My plugins: Map Cycle • Killstreaker • DeadChat • Infinite Jumping • TripMines • AdPurge • Bot Damage • PLRBots • Entity AntiSpam

Hail, Companion. [...] Hands to yourself, sneak thief. Image
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

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

Postby L'In20Cible » Thu Apr 21, 2016 4:56 am

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)
User avatar
iPlayer
Developer
Posts: 590
Joined: Sat Nov 14, 2015 8:37 am
Location: Moscow
Contact:

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

Postby iPlayer » Thu Apr 21, 2016 6:33 am

Tried that, didn't work. Well, the problem is that the original flashbang doesn't for some reason fully disappear from the loadout.
Image /id/its_iPlayer
My plugins: Map Cycle • Killstreaker • DeadChat • Infinite Jumping • TripMines • AdPurge • Bot Damage • PLRBots • Entity AntiSpam

Hail, Companion. [...] Hands to yourself, sneak thief. Image
User avatar
iPlayer
Developer
Posts: 590
Joined: Sat Nov 14, 2015 8:37 am
Location: Moscow
Contact:

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

Postby iPlayer » Thu Apr 21, 2016 6:56 am

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)
Image /id/its_iPlayer
My plugins: Map Cycle • Killstreaker • DeadChat • Infinite Jumping • TripMines • AdPurge • Bot Damage • PLRBots • Entity AntiSpam

Hail, Companion. [...] Hands to yourself, sneak thief. Image

Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 34 guests