AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   [TF2] halloween_skeleton_killed Event Not Firing? (https://forums.alliedmods.net/showthread.php?t=319933)

Cryotheum 11-27-2019 04:27

[TF2] halloween_skeleton_killed Event Not Firing?
 
1 Attachment(s)
I am trying to make a PVE gamemode and I wanted to use skeletons (tf_zombie) as the enemies. One necessary step, is rewarding players for killing the skeletons but the only event I found that had any relation was halloween_skeleton_killed. When I tired to use it, I noticed it never fired. I had spawned in the skeleton using ent_create and thought that might have something to do with it. So I went to the map plr_hightower_event to see if the skeletons spawned on that map would cause the event to fire; and it did not. So, I tried searching for other events and found npc_hurt but that did not affect skeletons only the halloween bosses. I wanted to make sure the event was getting hooked, so I used HookEventEx to check, and it is. I've attached the code below and if anyone knows anything about why this is happening, please shed some light. Thanks.

PC Gamer 11-29-2019 00:44

Re: [TF2] halloween_skeleton_killed Event Not Firing?
 
I couldn't get it to fire either using the code below. I was on koth_lakeside_event, spawned all bosses and skeletons using bossspawns.

Hook Events not working: "halloween_skeleton_killed" and "halloween_boss_killed"
Hook Event working: "escaped_loot_island"

PHP Code:

#pragma semicolon 1

public Plugin:myinfo = {
    
name         "Test of Skeleton Death",
    
author         "PC Gamer",
    
description "Tests the firing of events",
    
version     "1.0",
    
url         "http://www.sourcemod.net"
};

public 
OnPluginStart()
{
    
HookEvent("halloween_skeleton_killed"OnSkeletonDeathEventHookMode_Post);
    
HookEvent("halloween_boss_killed"OnBossDeathEventHookMode_Post);
    
HookEvent("escaped_loot_island"OnEscapeIslandEventHookMode_Post);        
}

public 
OnMapEnd()
{
    
UnhookEvent("halloween_skeleton_killed"OnSkeletonDeath);
    
UnhookEvent("halloween_boss_killed"OnBossDeath);
    
UnhookEvent("escaped_loot_island"OnEscapeIsland);    
}

public 
Action:OnSkeletonDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event,"player"));
    
PrintToChatAll("Event Fired: halloween_skeleton_killed");
    
PrintToChatAll("Event Notice: Skeleton was killed by %N"client);
    
PrintToServer("Event Notice: Skeleton was killed by %N"client);    
}


public 
Action:OnBossDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event,"killer"));
    
int bosstype GetEventInt(event,"boss");
    
PrintToChatAll("Event Fired: halloween_boss_killed");    
    
PrintToChatAll("Event Notice: Boss Type: %i was killed by %N"bosstypeclient);
    
PrintToServer("Event Notice: Boss Type: %i was killed by %N"bosstype,client);    
}

public 
Action:OnEscapeIsland(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event,"player"));
    
PrintToChatAll("Event Fired: escaped_loot_island");    
    
PrintToChatAll("Event Notice: %N Escaped Loot Island"client);
    
PrintToServer("Event Notice: %N Escaped Loot Island"client);    



Mitchell 12-03-2019 10:38

Re: [TF2] halloween_skeleton_killed Event Not Firing?
 
I think I had this issue also back in like 2014. Event didn't fire so I had to use SDKHooks OnTakeDamage and just do some quick math of the damage the skeleton was taking and it's current HP to determine who the killer was. OnEntityDestroyed() might also give you something also but not as much as just hooking the damage of the skeleton entities after they spawn.

Cryotheum 12-03-2019 11:18

Re: [TF2] halloween_skeleton_killed Event Not Firing?
 
Quote:

Originally Posted by Mitchell (Post 2675515)
I think I had this issue also back in like 2014. Event didn't fire so I had to use SDKHooks OnTakeDamage and just do some quick math of the damage the skeleton was taking and it's current HP to determine who the killer was. OnEntityDestroyed() might also give you something also but not as much as just hooking the damage of the skeleton entities after they spawn.

Yeah, that's how I dealt with the problem but the event would have been perfect as I just needed to know who killed the skeleton. Supposedly I could detour CZombie::Event_Killed but honestly this is much easier.


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

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