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?