AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   About message_const.inc (https://forums.alliedmods.net/showthread.php?t=85525)

aarons 02-12-2009 02:55

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(idtext[]) {
    
message_begin(MSG_ONEg_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(senderreceiver, const szMessage[])

{
    static 
MSG_typeid;
    if(
receiver 0)
    {
        
MSG_type MSG_ONE_UNRELIABLE;
        
id receiver;
    }
    else
    {
        
MSG_type MSG_BROADCAST;
        
id sender;
    }
    
message_begin(MSG_typesayText_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 ?


All times are GMT -4. The time now is 17:00.

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