AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Get kill weapon (https://forums.alliedmods.net/showthread.php?t=215240)

Unkolix 05-05-2013 06:09

Get kill weapon
 
How to get the weapon with which user killed an enemy?

Blizzard_87 05-05-2013 06:14

Re: Get kill weapon
 
pick it up after they die?

Unkolix 05-05-2013 06:20

Re: Get kill weapon
 
Quote:

Originally Posted by Blizzard_87 (Post 1946137)
pick it up after they die?

No, I need to get it right after the kill, I am doing it on DeathMsg... It's kinda MIX stats plugin I am working on.

didoWEE 05-05-2013 06:30

Re: Get kill weapon
 
get_user_weapon(read_data(1))

Blizzard_87 05-05-2013 06:32

Re: Get kill weapon
 
Quote:

Originally Posted by Unkolix (Post 1946141)
No, I need to get it right after the kill, I am doing it on DeathMsg... It's kinda MIX stats plugin I am working on.

you will need a global variable to hold the weapon name from CurWeapon event. how you put it into your stats plugin is upto you.

hornet 05-05-2013 06:57

Re: Get kill weapon
 
Quote:

Originally Posted by didoWEE (Post 1946144)
get_user_weapon(read_data(1))

That won't work for all cases - such as grenade kill. He needs to read data 4 for weapon name. You can then reformat the name and use get_weaponid().

Quote:

Originally Posted by Blizzard_87 (Post 1946145)
you will need a global variable to hold the weapon name from CurWeapon event. how you put it into your stats plugin is upto you.

No, that would be inefficient and unnecessary.

Unkolix 05-05-2013 07:41

Re: Get kill weapon
 
Did it like this, everything works except he kill...
PHP Code:

    new WeaponName[20]
    new 
WeaponID get_weaponid(WeaponName)
   
    
read_data(4WeaponName19)

    if (
WeaponID == CSW_HEGRENADE)    gs_stats[attacker][GS_HE]++; 


.Dare Devil. 05-05-2013 07:48

Re: Get kill weapon
 
Quote:

Originally Posted by Unkolix (Post 1946180)
Did it like this, everything works except he kill...
PHP Code:

    new WeaponName[20]
    new 
WeaponID get_weaponid(WeaponName)
   
    
read_data(4WeaponName19)

    if (
WeaponID == CSW_HEGRENADE)    gs_stats[attacker][GS_HE]++; 


I think you need to check WeaponName before getting weapon id.
If weaponname == "grenade" then here is your grenade kill

Unkolix 05-05-2013 07:54

Re: Get kill weapon
 
Quote:

Originally Posted by .Dare Devil. (Post 1946184)
I think you need to check WeaponName before getting weapon id.
If weaponname == "grenade" then here is your grenade kill

Didn't quite get that...

ConnorMcLeod 05-05-2013 07:59

Re: Get kill weapon
 
Code:

/* Function is called after player death ,
* if player was killed by teammate TK is set to 1 */
forward client_death(killer,victim,wpnindex,hitplace,TK);



All times are GMT -4. The time now is 10:48.

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