Raised This Month: $7 Target: $400
 1% 

register_event("DeathMsg", ...) question


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
KWo
AMX Mod X Beta Tester
Join Date: Jul 2004
Location: Poland
Old 03-04-2010 , 09:15   register_event("DeathMsg", ...) question
Reply With Quote #1

Can anybody with C++ knowledge tell me when exactly the DetahMsg (in register_event function) is triggered? I mean is this at the begining of the DeathMsg, at the end of it, just after is sent, just it is about to be send?
I'm refering to this version of pingfaker plugin:
http://forums.alliedmods.net/showpos...7&postcount=46
(it makes the "virtual" ping i.e. for bots - by using SVC_PING messages).
I wanted to put the same function in podbot mm C++ code, but that part to call again SVC_PINGS messages (for those people they are pressing IN_SCORE buttons) when a DeathMsg is sent is impossible for me to write correctly (because of my poor C++ knowledge).
When I was trying to add that just in pfnMessage_End (when I have before captured it comes from DeatMSg) - it of course had to crash, because I cannot start to send any new message (MESSAGE_BEGIN, WRITE_BYTE...MESSAGE_END) before that one (DeathMsg) was not finished yet.
I was even trying to update ClientData with those SVC_PINGS calls in StartFrame (just first after the DeathMsg was finished), but it didn't work like it does in this plugin (the pings for bots were disapearing still for a second after any kill; the plugin using register_event("DeathMsg"...) works with this perfectly - no any disappearing pings for bots). So I really don't know what I can do to make it correctly and get it finally 100% working as it should.
Anybody can help?
__________________
The Fullpack of podbot mm V3B22 - 24 apr 2012!!! is available here.
The All-In-One 3.2a package - 02 jun 2013 (AMX X 1.8.2 [with ATAC 3.0.1b , CSDM2.1.3c beta, CM OE 0.6.5, podbot mm V3B22c and mm 1.20) is available here.
The newest Beta V3B23a (rel. 28 august 2018!!!) is available here.

Last edited by KWo; 03-04-2010 at 09:20.
KWo is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 03-04-2010 , 11:37   Re: register_event("DeathMsg", ...) question
Reply With Quote #2

From meta_api.cpp, events callback are forwarded when MessageEnd has just been sent.

Code:
void C_MessageEnd_Post(void)
{
	g_events.executeEvents();
	if (endfunction) (*endfunction)(NULL);
	
	RETURN_META(MRES_IGNORED);
}
A thing i can't explain (i have no knowledge at all in c++) is that code in emsg.cpp

Code:
void Client_DamageEnd(void* mValue)
{
	CPlayer* dead = mPlayer;

	if (dead && dead->death_killer)
	{
		g_events.parserInit(CS_DEATHMSG, &gpGlobals->time, mPlayer = 0, mPlayerIndex = 0);
		g_events.parseValue(dead->death_killer);
		g_events.parseValue(dead->index);
		g_events.parseValue(dead->death_headshot);
		g_events.parseValue(dead->death_weapon.c_str());
		g_events.parseValue(dead->death_tk ? 1 : 0);
		g_events.executeEvents();
		dead->death_killer = 0;
	}
}
But obviously an event can't be sent before MessageEnd.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
joropito
AlliedModders Donor
Join Date: Mar 2009
Location: pfnAddToFullPack
Old 03-04-2010 , 14:59   Re: register_event("DeathMsg", ...) question
Reply With Quote #3

Reading the code (meta_api.cpp / emsg.cpp / CEvent.cpp) when event it's ready to be sent to client/s (after messageEnd), amxx calls every registered forwards.

So the answer is, its called when event it's ready to be sent.

C_MessageEnd_Post it's registered as post as it's registered using at pfnGetEngineFunctions_Post call.

In fact, if I'm right, you can't block the event.
__________________

Divide et vinces
approved plugins | steam account

I don't accept PM for support. Just ask on forums.
If you're looking for private work, PM me.
joropito is offline
Send a message via MSN to joropito
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 03-04-2010 , 15:37   Re: register_event("DeathMsg", ...) question
Reply With Quote #4

Quote:
Originally Posted by joropito View Post
In fact, if I'm right, you can't block the event.
You are right, because an event is no a single call, it's the store of all messages arguments.
That's also the reason why with register_message you can't hook/alter the original message but the one resent by amxx, but that's a bit offtopic now.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
KWo
AMX Mod X Beta Tester
Join Date: Jul 2004
Location: Poland
Old 03-04-2010 , 16:08   Re: register_event("DeathMsg", ...) question
Reply With Quote #5

OK. Thank You, guys. That means I have to make C_Messge_End_Post function and check if it was after DeathMsg. That should let me do the same what the forward for the event does. The only thing I have to figure out is how to build those _post functions in C++ (from meta api).
__________________
The Fullpack of podbot mm V3B22 - 24 apr 2012!!! is available here.
The All-In-One 3.2a package - 02 jun 2013 (AMX X 1.8.2 [with ATAC 3.0.1b , CSDM2.1.3c beta, CM OE 0.6.5, podbot mm V3B22c and mm 1.20) is available here.
The newest Beta V3B23a (rel. 28 august 2018!!!) is available here.
KWo is offline
joropito
AlliedModders Donor
Join Date: Mar 2009
Location: pfnAddToFullPack
Old 03-04-2010 , 16:21   Re: register_event("DeathMsg", ...) question
Reply With Quote #6

Quote:
Originally Posted by KWo View Post
OK. Thank You, guys. That means I have to make C_Messge_End_Post function and check if it was after DeathMsg. That should let me do the same what the forward for the event does. The only thing I have to figure out is how to build those _post functions in C++ (from meta api).
In metamod you have a call like this to register C_MessageEnd_Post as post.

PHP Code:
C_DLLEXPORT     int     GetEngineFunctions_Post(enginefuncs_t *pengfuncsFromEngine,     int     *interfaceVersion)
{
        
memset(&meta_engfuncs_post0sizeof(enginefuncs_t));
        
meta_engfuncs_post.pfnMessageEnd C_MessageEnd_Post;
        
memcpy(pengfuncsFromEngine, &meta_engfuncs_postsizeof(enginefuncs_t));
        return 
1;

But you should read about using metamod, registering events/forwards.
Take a look also at meta_api.cpp on some metamod plugin to understand how it register those functions.
__________________

Divide et vinces
approved plugins | steam account

I don't accept PM for support. Just ask on forums.
If you're looking for private work, PM me.
joropito is offline
Send a message via MSN to joropito
KWo
AMX Mod X Beta Tester
Join Date: Jul 2004
Location: Poland
Old 03-05-2010 , 13:42   Re: register_event("DeathMsg", ...) question
Reply With Quote #7

PHP Code:
C_DLLEXPORT     int     GetEngineFunctions_Post(enginefuncs_t *pengfuncsFromEngine,     int     *interfaceVersion)
{
        
memset(&meta_engfuncs_post0sizeof(enginefuncs_t));
        
meta_engfuncs_post.pfnMessageEnd C_MessageEnd_Post;
        
memcpy(pengfuncsFromEngine, &meta_engfuncs_postsizeof(enginefuncs_t));
        return 
1;

I have found in podbot mm similar lines with GetEngineFunctions_Post, I have added that C_MessageEnd_Post function with needed code and now it works perfectly.
Once again big thanks!

The next build of podbot mm will fully support showing pings for bots.
__________________
The Fullpack of podbot mm V3B22 - 24 apr 2012!!! is available here.
The All-In-One 3.2a package - 02 jun 2013 (AMX X 1.8.2 [with ATAC 3.0.1b , CSDM2.1.3c beta, CM OE 0.6.5, podbot mm V3B22c and mm 1.20) is available here.
The newest Beta V3B23a (rel. 28 august 2018!!!) is available here.
KWo is offline
Reply


Thread Tools
Display Modes

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 07:48.


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