AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Ham_Weapon_Reload Problem. (https://forums.alliedmods.net/showthread.php?t=75801)

shine771 08-12-2008 12:29

Ham_Weapon_Reload Problem.
 
I'm making a new, cool mod... but i'm having problems with Ham_Weapon_Reload. I'm trying to hook it.. but nothing happens.
PHP Code:

//plugin_init {
 
RegisterHam(Ham_Weapon_Reload,"player","player_reloaded")
//}
public player_reloaded(idlog_amx("RELOADED"

Maybe i am doing something wrong? Can anyone give me an code snippet/example how to hook this event properly?
Mod: cstrike, but didn't work on HL too. I've found only one topic where Ham_Weapon_Reload was involved... but there i didn't find anything useful.
I don't want to catch the After-Reload event in the Messy way... i would like to use this method if it's possible. Thanks.

Arkshine 08-12-2008 12:42

Re: Ham_Weapon_Reload Problem.
 
I think you should register this forward with the weapons class and not the player class.

What I'm using for a coming plugin :

Code:
    RegisterHamsItemDeploy ()     {         new s_WeaponName[ 24 ];         for ( new i_Wpn = 1; i_Wpn <= MAX_WEAPONS; i_Wpn++ )         {             get_weaponname ( i_Wpn, s_WeaponName, charsmax ( s_WeaponName ) );             if ( s_WeaponName[ 0 ] ) RegisterHam ( Ham_Item_Deploy, s_WeaponName, "fwd_Item_Deploy", 1 );         }     }

It should the same for 'Ham_Weapon_Reload'.

shine771 08-12-2008 12:50

Re: Ham_Weapon_Reload Problem.
 
Mm... i used "weapon_glock18"... nothing happened. If it would work... should i register ~20-30 forwards.. because there are ~20-30 weapon in CS. Of course i can do for loop... but isn't there a better way.. like "weapon_" >>> All entities with classname containing/starting(with) "weapon_" would be hooked/included... anyway... it doesn't work... :(. Thanks for your help anyway.

Arkshine 08-12-2008 12:55

Re: Ham_Weapon_Reload Problem.
 
Sawce has already said there is not any others ways than that.

[edit] Just tested and it works fine.

"weapon_glock18" should work. Try as post.

danielkza 08-12-2008 13:09

Re: Ham_Weapon_Reload Problem.
 
Quote:

Originally Posted by shine771 (Post 668578)
Mm... i used "weapon_glock18"... nothing happened. If it would work... should i register ~20-30 forwards.. because there are ~20-30 weapon in CS. Of course i can do for loop... but isn't there a better way.. like "weapon_" >>> All entities with classname containing/starting(with) "weapon_" would be hooked/included... anyway... it doesn't work... :(. Thanks for your help anyway.

You can hook Ham_Player_AddItem and use RegisterHamFromEntity in the just added weapon. Then when the item is removed you can disable the hook.

shine771 08-12-2008 14:16

Re: Ham_Weapon_Reload Problem.
 
Thanks arkshine! I just wrote "weapon_glock18" in the wrong RegisterHam(one above). Now i fixed it. :).
Thanks danielkza for trying to help :). I'll stick to my method... btw it just catches when you start reloading the weapon.. even if you've got full clip it still calls this event when you press the R(reload key). I fixed it using Cur weapon.. anyway.. thanks all :).


All times are GMT -4. The time now is 03:16.

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