Page 2 of 3

Posted: Mon Sep 29, 2014 1:03 pm
by qazuar
I would really like to know how you can make the player drop the weapon because im getting this:

Unable to add attribute 'drop_weapon'of type 'functions' to entity type 'player'
due to the following:
Could not find signature.

[SP] Caught an Exception:
Traceback (most recent call last):
File '..\addons\source-python\packages\source-python\events\listener.py', line
90, in fire_game_event
callback(game_event)
File '..\addons\source-python\plugins\weaponrestrict\weaponrestrict.py', line
56, in item_pickup
player.drop_weapon(weapon.pointer, True, True)
File '..\addons\source-python\packages\source-python\entities\entity.py', line
114, in __getattr__
raise AttributeError('Attribute '{0}' not found'.format(attr))

AttributeError: Attribute 'drop_weapon' not found

Posted: Mon Sep 29, 2014 1:14 pm
by L'In20Cible
Signature is outdated.

Code: Select all

Unable to add attribute 'drop_weapon'of type 'functions' to entity type 'player'
due to the following:
Could not find signature.

Posted: Mon Sep 29, 2014 2:38 pm
by qazuar
Very true, but in the post before mine he claims he can make it work, so i was just wondering.

Posted: Mon Sep 29, 2014 3:00 pm
by L'In20Cible
Probably different games.

Posted: Mon Sep 29, 2014 4:08 pm
by 8guawong
qazuar wrote:Very true, but in the post before mine he claims he can make it work, so i was just wondering.


are you refering to me??

drop weapon works for me
remove also works

csgo on linux

Posted: Mon Sep 29, 2014 6:12 pm
by Ayuto
L'In20Cible wrote:Probably different games.
or operating system.

Posted: Sun Dec 21, 2014 9:36 pm
by DJiSer
When i take enemy's weapon and trying to drop it:

Code: Select all

  File '../addons/source-python/plugins/restrict/restrict.py', line 83, in drop
    for weapon_index in player.weapon_indexes(not_filters='knife'):
  File '../addons/source-python/packages/source-python/players/weapons/__init__.py', line 355, in weapon_indexes
    index = index_from_inthandle(handle)
 
ValueError: Conversion failed...
 

CS:GO, Linux


Also CS:GO windows signatures for drop_weapon and give_named_item is outdated.

Posted: Sun Dec 21, 2014 9:50 pm
by L'In20Cible
I explained why this is happening here. Update your ../addons/source-python/packages/source-python/players/weapons/__init__.py to the lastest version and this should be fixed.

Posted: Sun Dec 21, 2014 10:04 pm
by satoon101
As for the signatures, when the entities_changes are complete, we won't be using those signatures anyway, as both of those functions can be gotten by virtual offset instead. Also, as in another thread, CS:GO's GiveNamedItem takes another argument which we have yet to fully explore.

Posted: Thu Mar 05, 2015 4:41 pm
by Mahi
Is it possible to restrict a weapon completely? Like, to prevent a player for picking it up in the first place?

Posted: Thu Mar 05, 2015 4:44 pm
by satoon101
Yes, you can hook touch (can't remember the full function name) to stop it. I intend to create a weapon restrict mod that will also handle purchasing weapons.

Posted: Thu Mar 05, 2015 6:11 pm
by L'In20Cible
The easiest function to hook is CCSPlayer::BumpWeapon.

Posted: Sat Dec 19, 2015 12:01 pm
by decompile
Is there an easier way of stripping a player completly?

Posted: Sat Dec 19, 2015 12:21 pm
by iPlayer
1st approach. This strips all weapons from a player:

Syntax: Select all

for index in player.weapon_indexes():
weapon = Entity(index) # TODO: BaseEntity would be enough here?
player.drop_weapon(weapon.pointer, Vector(0, 0, 0), Vector(0, 0, 0))
weapon.remove()


player here is a PlayerEntity. Also don't forget to import:

Syntax: Select all

from mathlib import Vector
from entities.entity import Entity


Dropping weapons is necessary, too. If you just remove it, it still remains in player's weapons props, later raising exceptions on every attempt to work with the player's weapons.

2nd approach: since you're stripping all weapons, you could just use a player_weaponstrip entity.


I believe, the 1st approach is a subject to change when they release new player/weapon libs.

Posted: Sun Dec 20, 2015 11:42 pm
by decompile
Sounds good.. How can i use the player_weaponstrip Entity? Is it just Firing the Entity On the given player?

Posted: Mon Dec 21, 2015 4:19 am
by iPlayer
I believe this way

Syntax: Select all

entity = Entity.create('player_weaponstrip')
entity.call_input("Strip", activator=player.index)
entity.remove()


The key moment here is that the player must be an activator

Posted: Mon Dec 21, 2015 11:50 am
by satoon101
Just a quick note. I added CStripWeapons to the entity data, so now that could just be:

Syntax: Select all

entity = Entity.create('player_weaponstrip')
entity.strip(activator=player.index)
entity.remove()

Re: Stripping weapons

Posted: Mon Oct 16, 2017 5:39 pm
by rocco
I'm going to have to spend some time on this. For HL2DM, I want to strip all but some weapons from all players who join for certain maps. Example Only for specific map dm_killbox_crossbow_big.bsp might only have crossbows available for the duration of the map level, all other weapons are stripped until the next map level.

Re: Stripping weapons

Posted: Sun Dec 03, 2017 8:09 pm
by BackRaw
Does the player_weaponstrip entity has any benefits over calling weapon.remove()? What about iterating over the player's weapons and calling .remove() each time? Or is it just that the weapon filters are more flexible?

Re: Stripping weapons

Posted: Sun Dec 03, 2017 8:19 pm
by Ayuto
No, iterating over the player's weapons and removing them is perfectly fine.