I want to send global chat message.
Now I am truing this code.
Quote:
void CEmptyServerPlugin::SayTextMsg(int PlayerIndexN, char const *Message)
{
MRecipientFilter filter;
if(PlayerIndexN == 0)
{
filter.AddAllPlayers(MaxClients); // we grab the maxclients at the ServerActivate Void
}
else
{
filter.AddRecipient(PlayerIndexN);//adds the player
}
bf_write *pWrite=engine->UserMessageBegin(&filter, 3);//3 for Say_Text
if( !pWrite )
{
//TODO: Action to perform when something goes wrong
}
else
{
pWrite->WriteByte(PlayerIndexN);// Players index, to send a global message from the server make it 0
pWrite->WriteString(Message);//the message itself
pWrite->WriteByte(0);//0 to phrase for colour 1 to ignore it
engine->MessageEnd();//finish off
}
}
|
But now it sayes
use of undefined type 'bf_write'
Why is it undeclared? Should I include something
I am sorry but I am new to the source engine
EDIT1: OK I included bitbuf.h and that is ok but I have another error.
'MRecipientFilter' : undeclared identifier
What should I include now?
Thanks.
EDIT2: Ok so I've write down MRecipientFilter.cpp and MRecipientFilter.h and now it compiles ok. The messaging system is working but the loop is not.
Please help me with the loop. Why it doesn't loops?
This is my code for the loop
Quote:
void CEmptyServerPlugin::GameFrame( bool simulating )
{
time_t curTime;
curTime = time(NULL);
if(difftime(originalTime, curTime) > 5.0)
{
SayTextMsg(0, "IT WORKS");
originalTime = time(NULL);
}
}
|
originalTime is initialized at LevelInit with
originalTime = time(NULL);
What am I doing wrong?