AlliedModders

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

v3x 03-20-2005 04:01

Get killers weapon
 
How would I go by getting the weapon of the person who just killed me?

xeroblood 03-20-2005 10:57

From amxmodx.inc:
Code:
/* If player is not attacked function returns 0, in other * case returns index of attacking player. On second and third * parameter you may get info about weapon and body hit place. */ native get_user_attacker(index,...);

Example:
Code:
public SomeFunc( id ) // Maybe the Damage Event? {     new iWeapon, iBody     new iAttacker = get_user_attacker( id, iWeapon, iBody )     // blah blah blah }

The weapon will be an index # of the constant weapon types from amxconst.inc....

knekter 03-20-2005 15:16

easy
 
Code:
register_event("DeathMsg", "event_DeathMsg", "a") public event_DeathMsg(id) {     new weapon = read_data(4)     // code }

XxAvalanchexX 03-20-2005 15:33

Some mods don't even use the DeathMsg event, knekter.

xeroblood 03-20-2005 16:01

and that would only work when the player dies... but it was good to point out none the less! there is more than one way, of course, so im sure people like to see the other ways too!

v3x 03-20-2005 16:15

Thanks, I'll try it out..

Edit: Xero, does that do it for when the victim is already dead, or when he's being attacked?

xeroblood 03-20-2005 18:06

whenever you choose to call the function (generally only after being damaged/killed)..

So you could call it in a DeathMsg Event function or a Damaga Event function...

v3x 03-20-2005 18:14

So..
Code:
public plugin_init() {     // ..     register_event("DeathMsg", "event_DeathMsg", "a") } public event_DeathMsg(id) {     new iWeapon, iBody     new iAttacker = get_user_attacker(id, iWeapon, iBody)     // blah blah blah }
:?:

xeroblood 03-20-2005 20:42

Exactly! You got it!!

(But return PLUGIN_CONTINUE too)

v3x 03-20-2005 21:02

Quote:

Originally Posted by xeroblood
(But return PLUGIN_CONTINUE too)

Yea, kinda figured that. :)


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

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