AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Weapon Id get WeaponName (https://forums.alliedmods.net/showthread.php?t=106086)

uxMal 10-11-2009 14:08

Weapon Id get WeaponName
 
Uhhmm don't know why i cant find a solution but i have a weaponID and i want to get the weapon name...
pev_classname and pev_viewmodel are not working ...

pev_weaponmodel returns a huge number...

toader_octavian 10-11-2009 14:10

Re: Weapon Id get WeaponName
 
PHP Code:

new name[32]
get_weaponname WEP_IDname31 


uxMal 10-11-2009 14:20

Re: Weapon Id get WeaponName
 
Hmm thanks but thats not working either

and now i know why...

I use RegisterHam(Ham_TakeDamage,"player","dmg_func ")

ham_const.inc says

Code:

/**
    * Description:        Usually called whenever an entity takes any kind of damage.
    *                    Inflictor is the entity that caused the damage (such as a gun).
    *                    Attacker is the entity that tirggered the damage (such as the gun's owner).
    * Forward params:    function(this, idinflictor, idattacker, Float:damage, damagebits);
    * Return type:        Integer.
    * Execute params:    ExecuteHam(Ham_TakeDamage, this, idinflictor, idattacker, Float:damage, damagebits);
    */
    Ham_TakeDamage,

But idinflictor and idattacker are the SAME ...

I dont want to use get_user_attacker because that returns the weapon the attacker is holding currently! if i throw a he and switch to an other weapon not the he is registered as an attacker but the other weapon

toader_octavian 10-11-2009 14:28

Re: Weapon Id get WeaponName
 
The best way is to hook CurWeapon event and remember the weapon each player has. When a player takes damage and (damagebits & DMG_BULLET && inflictor == attacker) is true that means that our user is shooted. Then you can get the weapon that he was shot.
PHP Code:

public fw_takedamage(victiminflictorattackerFloat:dambits)
{
 if (!(
bits DMG_BULLET && inflictor == attacker))
  return 
HAM_IGNORED

 client_print
(victimprint_chat"[TAKEDAM] Weap:%d Damage:%f"get_weapon(attacker), dam)
 return 
HAM_IGNORED



Jon 10-11-2009 14:29

Re: Weapon Id get WeaponName
 
pev_classname or get_weaponname( cs_get_weapon_id( idinflictor ) ...... )

ConnorMcLeod 10-11-2009 14:34

Re: Weapon Id get WeaponName
 
Also, when damage is made by a hegrenade, in that case inflictor is the grenade entity, attacker is the player, and damagebit is (or contains) 1<<24

uxMal 10-11-2009 14:58

Re: Weapon Id get WeaponName
 
Thanks for the help i got it working now but tell me is Ham_TakeDamage bugged ?

Why is idinflictor and idattacker the same ?

toader_octavian 10-11-2009 15:00

Re: Weapon Id get WeaponName
 
No, it is not bugged.
Infilctor and attacker are the same when the damage is done by the player entity, (when you are shot by a weapon or knife).
If you are hurt by a grenade then the attacker will be the owner of the grenade and the inflictor the grenade.


All times are GMT -4. The time now is 22:41.

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