AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Get entity killer. (https://forums.alliedmods.net/showthread.php?t=209978)

urban_ninja 03-04-2013 15:09

Get entity killer.
 
How can I hook the death of an entity and get its attacker? I've tried
PHP Code:

RegisterHamHam_Killed"func_wall""Killed"); 

but it crashes the engine upon killing a monster.

Is ham really the only way to do this?

I've looks at some other examples on here but none of them work at all. At least this one can detect monster killed even tho it results in a crash.

hleV 03-04-2013 16:06

Re: Get entity killer.
 
Show your Killed() function.

urban_ninja 03-04-2013 16:17

Re: Get entity killer.
 
PHP Code:

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
RegisterHamHam_Killed"func_wall""Killed");
}
public 
Killed( const monster, const attacker)
{
    
set_user_frags(attackerget_user_frags(attacker) + 1);


EDIT: I've just read in some other thread that team fortress classic has issues with Ham_Killed. Cant this be done without using ham?

hleV 03-04-2013 17:52

Re: Get entity killer.
 
Try
PHP Code:

public Killed(entityattacker)
{
    if (
is_user_connected(attacker))
        
set_user_frags(attackerget_user_frags(attacker) + 1);


and see if it helps.

urban_ninja 03-04-2013 18:51

Re: Get entity killer.
 
Nope. Still crashes.

Arkshine 03-04-2013 19:02

Re: Get entity killer.
 
It stills happens with the unofficial version of Ham ?

It might crash because in TFC Killed could has different params count. But it's most likely not the case.

Is there a crash only when hooking on "func_wall" ? Or it crashes for all, "player", etc. ?

urban_ninja 03-04-2013 19:12

Re: Get entity killer.
 
Crash happens with any entity.

Arkshine 03-04-2013 19:16

Re: Get entity killer.
 
Checked and it's actually one param in more: Killed(entvars_s *, entvars_s *, int). if it crashes it's most likely because it uses the wrong handler (HL uses (entvars_s *, int)). Will fix that tomorrow. I would need to add a specific constant Ham_TFC_Killed.

Arkshine 03-05-2013 04:13

Re: Get entity killer.
 
2 Attachment(s)
Tell me if it works. You have to use Ham_TFC_Killed. Updated include is provided.

urban_ninja 03-05-2013 16:54

Re: Get entity killer.
 
L 03/05/2013 - 16:50:24: [AMXX] Plugin ("MosterKiller.amxx") is setting itself as failed.
L 03/05/2013 - 16:50:24: [AMXX] Plugin says: Function tfc_killed is not configured in hamdata.ini.
L 03/05/2013 - 16:50:24: [AMXX] Displaying debug trace (plugin "MosterKiller.amxx")
L 03/05/2013 - 16:50:24: [AMXX] Run time error 1: forced exit
L 03/05/2013 - 16:50:24: [AMXX] [0] hamsandwich.inc::__fatal_ham_error (line 376)


All times are GMT -4. The time now is 21:42.

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