AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Quick info about message_begin (https://forums.alliedmods.net/showthread.php?t=193099)

hyphen 08-16-2012 13:16

Quick info about message_begin
 
I'm not sure whether I can pass 0 as id to message_begin to send a chat message to all players instead of using loop with below code.

Code:

print_color_message(id, msg[])
{
        message_begin(MSG_ONE, gmsgSayText, {0,0,0}, id)
        write_byte(id)
        write_string(msg)
        message_end()
}


jimaway 08-17-2012 12:03

Re: Quick info about message_begin
 
Code:

#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_ONE_UNRELIABLE          8        // Send to one client, but don't put in reliable stream, put in unreliable datagram (could be dropped)

Code:
print_color_message(msg[]) {     message_begin(MSG_ALL, gmsgSayText)     write_string(msg)     message_end() }

hyphen 08-18-2012 14:39

Re: Quick info about message_begin
 
Good info buddy. Another thing.. What is difference between unreliable channel and reliable channel ?. What if I use MSG_BROADCAST instead MSG_ALL.

Is it something like reliable channel is guaranteed to reach to client ?

hyphen 08-18-2012 14:51

Re: Quick info about message_begin
 
Below code seems to be not working with colors where MSG_ONE with a loop for all players works.

Code:

    new szPrintTxt[120]
    format(szPrintTxt, 119, "^x04%s ^x01%s", "TAG", "Some Txt")
    message_begin(MSG_ALL, gmsgSayText)
    write_string(msg)
    message_end()


jimaway 08-19-2012 08:00

Re: Quick info about message_begin
 
you still need write_byte(id), my bad

when players recieve too many messages on reliable channel once they might get disconnected with "reliable channel overflow" error

ConnorMcLeod 08-19-2012 09:12

Re: Quick info about message_begin
 
PHP Code:

print_color_message(0"^x04%s ^x01%s""TAG""Some Txt"

PHP Code:

print_color_message(id"^x04%s ^x01%s""TAG""Some Txt"

PHP Code:

print_color_message(idfmt[], any:...)
{
    static 
saytext 0fake_user
    
if( !saytext )
    {
        
saytext get_user_msgid("SayText")
        
fake_user get_maxplayers() + 1
    
}

    new 
msg[192]
    
vformat(msgcharsmax(msg), fmt3)

    
message_begin(id MSG_ONE_UNRELIABLE MSG_BROADCASTsaytext_id)
    
write_byte(id id fake_user)
    
write_string(msg)
    
message_end()




All times are GMT -4. The time now is 05:49.

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