Raised This Month: $ Target: $400
 0% 

Quick info about message_begin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hyphen
Senior Member
Join Date: Aug 2011
Old 08-16-2012 , 13:16   Quick info about message_begin
Reply With Quote #1

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()
}
hyphen is offline
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 08-17-2012 , 12:03   Re: Quick info about message_begin
Reply With Quote #2

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() }

Last edited by jimaway; 08-17-2012 at 12:08.
jimaway is offline
hyphen
Senior Member
Join Date: Aug 2011
Old 08-18-2012 , 14:39   Re: Quick info about message_begin
Reply With Quote #3

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 is offline
hyphen
Senior Member
Join Date: Aug 2011
Old 08-18-2012 , 14:51   Re: Quick info about message_begin
Reply With Quote #4

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()
hyphen is offline
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 08-19-2012 , 08:00   Re: Quick info about message_begin
Reply With Quote #5

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

Last edited by jimaway; 08-19-2012 at 08:04.
jimaway is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 08-19-2012 , 09:12   Re: Quick info about message_begin
Reply With Quote #6

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()

__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 08-19-2012 at 09:13.
ConnorMcLeod is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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