AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Need a weapon pickup hook (https://forums.alliedmods.net/showthread.php?t=188237)

Misery 06-24-2012 03:23

Need a weapon pickup hook
 
Hi,

I was wondering... Is there a way to hook *any* weapon/item pickup, any but the one given as default by the map on CGameRules::PlayerSpawn() ?

Is there a way to retrieve a kind of list of default weapons given on PlayerSpawn(), so I could do for example
Code:

Hook_OnWeaponPickup(id, weaponid)
{
      if (!isWeaponGivenOnPlayerSpawn(weaponid)
                    drop_weapon(id, weaponid);
}

Is it possible?

Thanks!

Cordially,
Misery

pokemonmaster 06-24-2012 04:04

Re: Need a weapon pickup hook
 
Code:
// Maybe this? register_event("WeapPickUp", "fw_weappick", "a")

Backstabnoob 06-24-2012 04:15

Re: Need a weapon pickup hook
 
Try using Ham_Touch.

Misery 06-24-2012 04:25

Re: Need a weapon pickup hook
 
Well, you guys... have you read what I said?
I already know how I can hook the weapon pickup...

But, how to get the list of default items on PlayerSpawn()? You see if it's for example scoutzknivez, it'll be different items given on spawn than say de_dust2.

Also, Ham_touch might be quite lots of code, and slow... since I to get pickup of absolutely all weapon, everything but the ones given on spawn.

As for WeapPickUp, it does not provide the player id... quite problematic.

Any other ideas?
Thanks tho for giving me some of your time. I appreciate.

Misery

P.S. I use Orpheu too. Open to absolutely any solution...

Backstabnoob 06-24-2012 04:49

Re: Need a weapon pickup hook
 
Try hooking Ham_AddPlayerItem. You can hook Ham_Spawn as well, set global var for the client and unset it after 0.x seconds. Then in the addplayeritem hook, save the entid to some global array when the var is set and you got yourlist of items on spawn.

hornet 06-24-2012 07:06

Re: Need a weapon pickup hook
 
You could simply remove the game_player_equip entity on plugin_init().
Or if you actually want an array list of weapons you can retrieve them from that same entity.

Misery 06-24-2012 07:40

Re: Need a weapon pickup hook
 
Hmm, I think I will be able to make it... Disassembly shows UTIL_FindEntityByClassname on game_player_equip, then uses another function within the entity class. I only see ::Touch used.

So yeah, I can parse the entity, do the same thing... Anything can supercede UTIL_FindEntityByClassname() within AMXX, or do I have to hook it and make the calls myself?

Thanks!

hornet 06-24-2012 09:56

Re: Need a weapon pickup hook
 
I'm not sure I understand your question. You don't actually need to find the entity you can just retrieve the given weapons from using pfn_keyvalue() .

And yes touch is called when giving a player an item.


All times are GMT -4. The time now is 06:15.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.