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

Print to chat area...


Post New Thread Reply   
 
Thread Tools Display Modes
BeetleFart
SourceMod Donor
Join Date: Apr 2004
Old 12-13-2004 , 11:42  
Reply With Quote #11

Quote:
Originally Posted by Fruchtzwerg
You have to include bitbuf.cpp into your makefile to get it working. And yes, usermessages are working fine.
Cool thanks.
Ill give it a shot.
BeetleFart is offline
BeetleFart
SourceMod Donor
Join Date: Apr 2004
Old 12-13-2004 , 12:38  
Reply With Quote #12

Quote:
Originally Posted by Fruchtzwerg
You have to include bitbuf.cpp into your makefile to get it working. And yes, usermessages are working fine.

Im not too familiar with creating user messages,
would it go something like this?

bf_write *pWrite;
pWrite = engine->UserMessageBegin((IRecipientFilter *)&mrf,1);
pWrite->WriteString("SayText");
pWrite->WriteString("Text To Print");
engine->MessageEnd();
BeetleFart is offline
Fruchtzwerg
Member
Join Date: Dec 2004
Old 12-13-2004 , 13:03  
Reply With Quote #13

This should work. msg_type for SayText is 3 in CS:S. The format is:

Code:
pWrite->WriteByte(OwnerIndex);
pWrite->WriteString(message);
pWrite->WriteByte(bChat);
as you can see in the sdk.
I assume rmf is a valid recipient filter class. You have to write your own class for this. Get some sample stuff here: http://www.hl2coding.com/forums/viewtopic.php?t=31
__________________
Fruchtzwerg is offline
BeetleFart
SourceMod Donor
Join Date: Apr 2004
Old 12-13-2004 , 13:48  
Reply With Quote #14

Quote:
Originally Posted by Fruchtzwerg
This should work. msg_type for SayText is 3 in CS:S. The format is:

Code:
pWrite->WriteByte(OwnerIndex);
pWrite->WriteString(message);
pWrite->WriteByte(bChat);
as you can see in the sdk.
I assume rmf is a valid recipient filter class. You have to write your own class for this. Get some sample stuff here: http://www.hl2coding.com/forums/viewtopic.php?t=31

Thanks Alot!!!!
I will start testing this out tonight, and yeah the recipient class is the one I got from that thread.
BeetleFart is offline
Eradicator
Junior Member
Join Date: Dec 2004
Location: Canada
Old 12-13-2004 , 16:48  
Reply With Quote #15

Here is my code that works. This is in ClientPutInServer:
Code:
   char msg[128];
	int index = engine->IndexOfEdict(pEntity);
	if (index)
	{
		MRecipientFilter mrf;
		bf_write *pWrite; 
		sprintf(msg,"Server is running: %s", plugin_name);
		mrf.AddPlayer(index);
		pWrite = engine->UserMessageBegin((IRecipientFilter *)&mrf,3); 
		pWrite->WriteString(msg); 
		engine->MessageEnd();
	}
And the AddPlayer function that I added to mosca's MRecipientFilter class:
Code:
void MRecipientFilter::AddPlayer(int index) 
{ 
	edict_t *pPlayer = engine->PEntityOfEntIndex(index); 
	if ( !pPlayer || pPlayer->IsFree()) { 
		return; } 
	m_Recipients.AddToTail(index); 
}
That entity check is unnecesarry and I'll probably remove it as it doesn't even really check if its a player and I can do that (and should) before calling mrf.AddPlayer(index) anyway (if not in ClientPutInServer that is...).
Fruch, I don't know what those extra WriteBytes are for? I didn't need them.
[edit]
I noticed the first character of the message gets cut off. Anyone know why?
Eradicator is offline
Send a message via MSN to Eradicator
Manip
Senior Member
Join Date: Jan 2004
Old 12-13-2004 , 17:35  
Reply With Quote #16

The above returns - 'MESSAGE_END called with no active message' then the server crashes and burns.
Manip is offline
Send a message via AIM to Manip
Eradicator
Junior Member
Join Date: Dec 2004
Location: Canada
Old 12-13-2004 , 17:38  
Reply With Quote #17

My code? Erm... no, it doesn't. I have it compiling and I tested it ingame and it works. I copied bitbuff.cpp and bitbuff.h and included them in my project and I've included mosca's MRecipientFilter class .cpp and .h files (slightly modified).
Eradicator is offline
Send a message via MSN to Eradicator
Fruchtzwerg
Member
Join Date: Dec 2004
Old 12-13-2004 , 19:30  
Reply With Quote #18

Quote:
Originally Posted by Eradicator
I noticed the first character of the message gets cut off. Anyone know why?
Because you need the other parameters. Get rid of the IRecipientFilter cast in UserMessageBegin. If you derive your recipient filter class from IRecipientFilter correctly, then you dont need this freaky cast.
__________________
Fruchtzwerg is offline
Eradicator
Junior Member
Join Date: Dec 2004
Location: Canada
Old 12-13-2004 , 20:12  
Reply With Quote #19

Ok, I put those WriteBytes back in and now it cuts off the last letter when on the HUD, but is fine when in the console. Could you elaborate on properly "deriving" IRecipientFilter.
Eradicator is offline
Send a message via MSN to Eradicator
Fruchtzwerg
Member
Join Date: Dec 2004
Old 12-13-2004 , 20:56  
Reply With Quote #20

As you derive any other class in C++:

Code:
class CMyRecipientFilter : public IRecipientFilter
and then implement all functions from the interface.
__________________
Fruchtzwerg 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 12:26.


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