Raised This Month: $ Target: $400
 0% 

Need a weapon pickup hook


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Misery
Senior Member
Join Date: Dec 2010
Old 06-24-2012 , 03:23   Need a weapon pickup hook
Reply With Quote #1

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:layerSpawn() ?

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
Misery is offline
pokemonmaster
princess milk
Join Date: Nov 2010
Location: Somewhere in this world
Old 06-24-2012 , 04:04   Re: Need a weapon pickup hook
Reply With Quote #2

Code:
// Maybe this? register_event("WeapPickUp", "fw_weappick", "a")
__________________
اَشْهَدُ اَنْ لَّآ اِلٰهَ اِلَّا اللہُ وَحْدَه لَا شَرِيْكَ لَه وَ اَشْهَدُ اَنَّ مُحَمَّدًا عَبْدُه وَرَسُوْلُه
No longer active in AMXX. Sorry.
pokemonmaster is offline
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 06-24-2012 , 04:15   Re: Need a weapon pickup hook
Reply With Quote #3

Try using Ham_Touch.
Backstabnoob is offline
Misery
Senior Member
Join Date: Dec 2010
Old 06-24-2012 , 04:25   Re: Need a weapon pickup hook
Reply With Quote #4

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...

Last edited by Misery; 06-24-2012 at 04:45.
Misery is offline
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 06-24-2012 , 04:49   Re: Need a weapon pickup hook
Reply With Quote #5

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.

Last edited by Backstabnoob; 06-24-2012 at 04:51.
Backstabnoob is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 06-24-2012 , 07:06   Re: Need a weapon pickup hook
Reply With Quote #6

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.
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
Misery
Senior Member
Join Date: Dec 2010
Old 06-24-2012 , 07:40   Re: Need a weapon pickup hook
Reply With Quote #7

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!
Misery is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 06-24-2012 , 09:56   Re: Need a weapon pickup hook
Reply With Quote #8

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.
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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