Raised This Month: $ Target: $400
 0% 

Regarding several Ham Functions


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Depresie
Veteran Member
Join Date: Nov 2013
Old 07-14-2017 , 13:16   Regarding several Ham Functions
Reply With Quote #1

Ham_RemovePlayerItem

- Isn't this hookable ?
- If it is hooked shouldn't it be triggered when a player drops or gets stripped of a weapon ?

Ham_Item_Drop

- Isn't this hookable ?
- If it is hooked shouldn't it be triggered when a player drops a weapon ?

Ham_Weapon_RetireWeapon

- Shouldn't this be triggered when player is switching or dropping weapons ?
__________________

Last edited by Depresie; 07-14-2017 at 13:17.
Depresie is offline
gabuch2
AlliedModders Donor
Join Date: Mar 2011
Location: Chile
Old 07-14-2017 , 13:39   Re: Regarding several Ham Functions
Reply With Quote #2

All Ham functions are hookable, but it doesn't mean it's safe to supercede them.

Ham_RemovePlayerItem happens when you strip an item from the player.

Ham_Item_Drop when you drop a weapon (unsure)

Ham_Weapon_RetireWeapon, in Half-Life you will automatically change to a "better weapon", determined by weight, after you ran out of ammo of certain weapons(throwables) thus calling this method.
__________________

Last edited by gabuch2; 07-14-2017 at 13:40.
gabuch2 is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 07-14-2017 , 14:25   Re: Regarding several Ham Functions
Reply With Quote #3

Ham_RemovePlayerItem
- Hooked, seems to be never called, even after calling it with ExecuteHamB

Ham_Item_Drop
- Hooked, seems to be never called

Ham_Weapon_RetireWeapon
- Hooked, seems to be called only when using it with ExecuteHamB

PHP Code:
public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)

    
//register_clcmd("say weapon", "cmdweapons")

    
register_clcmd("say 1""CommandGetWeapon")
    
register_clcmd("say 2""CommandWeaponStrip")

    
RegisterHam(Ham_Weapon_RetireWeapon"weapon_ak47""fw_HamWeaponRetire_Post"1)
    
RegisterHam(Ham_Item_Drop"weapon_ak47""fw_HamItemDrop_Post"1)
    
RegisterHam(Ham_RemovePlayerItem"weapon_ak47""fw_HamRemovePlayerItem_Post"1)

}

public 
CommandGetWeapon(iPlayer)
{
    
give_item(iPlayer"weapon_ak47")
}


public 
CommandWeaponStrip(iPlayer)
{
    new 
iWeaponID CSW_AK47

    
new iWeapon cs_get_user_weapon_entity(iPlayer)

    
ExecuteHamB(Ham_Weapon_RetireWeaponiWeapon)

    
ExecuteHamB(Ham_RemovePlayerItemiPlayeriWeapon)


    
ExecuteHamB(Ham_Item_KilliWeapon)
    
set_pev(iPlayerpev_weaponspev(iPlayerpev_weapons) & ~ (1<<iWeaponID))
}

public 
fw_HamWeaponRetire_Post(iWeapon)
{
    
client_print(0print_chat"RETIRE WEAPON")
}

public 
fw_HamItemDrop_Post(iWeapon)
{
    
client_print(0print_chat"DROP WEAPON")
}

public 
fw_HamRemovePlayerItem_Post(iWeapon)
{
    
client_print(0print_chat"REMOVE WEAPON")

__________________
Depresie is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 07-14-2017 , 15:24   Re: Regarding several Ham Functions
Reply With Quote #4

Ham_RemovePlayerItem is called on "player" entities when a client sends "drop" or when the game (in many different cases it looks like) forces a player to drop an item, like when a player dies.

Ham_Item_Drop is called only in a few cases it looks like and it actually destroys the weapon entity. There is CBasePlayerItem:Kill which does the same. I don't really get the logic behind this function, but it shouldn't be used to hook when a weapon is dropped.

Ham_Weapon_RetireWeapon is called when a weapon should be holstered and the next best weapon should be deployed. That happens for example when you throw a flashbang or run out of ammo.

Last edited by klippy; 07-14-2017 at 15:24.
klippy 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 22:45.


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