Raised This Month: $51 Target: $400
 12% 

GameEventListener2 callback in list that should NOT be - player_death!


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Ajaxx
Senior Member
Join Date: Oct 2009
Old 08-27-2012 , 18:32   GameEventListener2 callback in list that should NOT be - player_death!
Reply With Quote #1

I’m try to display messages to users when they kill someone or die. I’m adding a listener like so

Code:
gameevents->AddListener(this, "player_death", true);
When I test my plugin I don’t see the message and I see this in the server console

Quote:
GameEventListener2 callback in list that should NOT be - player_death!
Does anyone have any suggestions?
Ajaxx is offline
psychonic

BAFFLED
Join Date: May 2008
Old 08-27-2012 , 18:37   Re: GameEventListener2 callback in list that should NOT be - player_death!
Reply With Quote #2

Quote:
Originally Posted by psychonic @ MM:S Dev Wiki
Code:
[23:49] <psychon1c> oh, for events, IEventListener2 has an extra member, starting in swarm i think
[23:49] <MaxLap> good thing i wasn't aiming at being ready for release then!
[23:49] <psychon1c> GetDebugId or GetEventDebugId, something like that
[23:50] <psychon1c> and just return 42 in the impl. there's a define for it, but i don't remember the name
[23:50] <psychon1c> should be in the header
https://forums.alliedmods.net/showthread.php?t=194338
psychonic is offline
Ajaxx
Senior Member
Join Date: Oct 2009
Old 08-27-2012 , 19:15   Re: GameEventListener2 callback in list that should NOT be - player_death!
Reply With Quote #3

I have the latest HL2SDKCSGO and MMSOURCE19. When I implement GetEventDebugID() returning NULL like so

Code:
int	 StubPlugin::GetEventDebugID()
{
	return NULL;
}
I get the message
Quote:
GameEventListener2 callback in list that should NOT be - player_death!
When I implement GetEventDebugID() returning 42 like you suggest

Code:
int	 StubPlugin::GetEventDebugID()
{
	return 42;
}
The server crashes when the event is fired.
Ajaxx is offline
psychonic

BAFFLED
Join Date: May 2008
Old 08-27-2012 , 19:22   Re: GameEventListener2 callback in list that should NOT be - player_death!
Reply With Quote #4

Quote:
Originally Posted by Ajaxx View Post
The server crashes when the event is fired.
Well, debug it.

It sounds like your event handler wasn't firing before having the correct debug id set and it is firing now, and likely crashing inside of it.
psychonic is offline
Ajaxx
Senior Member
Join Date: Oct 2009
Old 08-27-2012 , 19:50   Re: GameEventListener2 callback in list that should NOT be - player_death!
Reply With Quote #5

You’re right, the event is firing now and has uncovered an issue elsewhere in my code. It seems to be throwing an exception here:

Code:
const char* StubPlugin::GetSteamIdOfUserId(int userId)
{
	#undef GetClassName

	edict_t* entity;

	for  (int i = 1; i < MAX_PLAYERS; i++)
	{
		entity = (edict_t *)(gpGlobals->pEdicts + i); <<<<<< exception thrown here

		if (entity && !entity->IsFree())
		{
			if (FStrEq(entity->GetClassName(), "player"))
			{
				if (engine->GetPlayerUserId(entity) == userId)
				{
					return engine->GetPlayerNetworkIDString(entity);
				}
			}
		}
	}

	#define GetClassName  GetClassNameA

	return NULL;
}

It might be helpful to note I’m testing this with bots.
Ajaxx is offline
psychonic

BAFFLED
Join Date: May 2008
Old 08-27-2012 , 20:06   Re: GameEventListener2 callback in list that should NOT be - player_death!
Reply With Quote #6

Have you confirmed that gpGlobals was properly populated? Also, what is MAX_PLAYERS set to?
psychonic is offline
Ajaxx
Senior Member
Join Date: Oct 2009
Old 08-27-2012 , 20:43   Re: GameEventListener2 callback in list that should NOT be - player_death!
Reply With Quote #7

Right again, thanks psychonic I have my messages working now!
Ajaxx is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 08-28-2012 , 09:08   Re: GameEventListener2 callback in list that should NOT be - player_death!
Reply With Quote #8

Suggestion: Use gpGlobals->maxClients instead of MAX_PLAYERS.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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