About message_const.inc
msg_type ware defined in mssage_const.inc
Code:
/* Destination types for message_begin() */
#define MSG_BROADCAST 0 // Unreliable to all
#define MSG_ONE 1 // Reliable to one (msg_entity)
#define MSG_ALL 2 // Reliable to all
#define MSG_INIT 3 // Write to the init string
#define MSG_PVS 4 // Ents in PVS of org
#define MSG_PAS 5 // Ents in PAS of org
#define MSG_PVS_R 6 // Reliable to PVS
#define MSG_PAS_R 7 // Reliable to PAS
#define MSG_ONE_UNRELIABLE 8 // Send to one client, but don't put in reliable stream, put in unreliable datagram (could be dropped)
#define MSG_SPEC 9 // Sends to all spectator proxies
I have some questions about that.
I show the sample cases first:
Case 1:
PHP Code:
new msg[128]
format(msg,127,"^x01test,^x03test,^x04test.")
msg_saytest(id)
public msg_saytext(id, text[]) {
message_begin(MSG_ONE, g_msgid_saytext, _, id)
write_byte(id)
write_string(text)
message_end()
}
Case 2:
PHP Code:
new msg[128]
format(msg,127,"^x01test,^x03test,^x04test.")
print_SayText(id)
public print_SayText(sender, receiver, const szMessage[])
{
static MSG_type, id;
if(receiver > 0)
{
MSG_type = MSG_ONE_UNRELIABLE;
id = receiver;
}
else
{
MSG_type = MSG_BROADCAST;
id = sender;
}
message_begin(MSG_type, sayText, _, id);
write_byte(sender);
write_string(szMessage);
message_end();
return 1;
}
First , if id > 0 , The goal of two different cases is the same ?
Second, if id = 0 , the case 2 will broadcast the msg to all ? But in message_const , that already defined MSG_ALL, what's different ?
|