Raised This Month: $ Target: $400
 0% 

loop through all players


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 02-14-2013 , 00:28   Re: loop through all players
Reply With Quote #1

If you don't plain to add color, use client_print native
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
hypheni
Senior Member
Join Date: Jul 2011
Location: India
Old 02-13-2013 , 12:29   Re: loop through all players
Reply With Quote #2

Quote:
print_message(id, const msg[])
{
message_begin(id ? MSG_ONE : MSG_ALL, gmsgSayText, _, id)
write_byte(id)
write_string(msg)
message_end()
}
So for sending message to all players I need to pass 0 as 1st param and actual message as 2nd.

Actually I don't understand this write_byte() function. It says write bytes to message. In C char is 1 byte. So how these bytes are calculated here for particular message which need to be sent to client.
hypheni is offline
Send a message via Skype™ to hypheni
hypheni
Senior Member
Join Date: Jul 2011
Location: India
Old 02-14-2013 , 01:43   Re: loop through all players
Reply With Quote #3

^^. For normal text print client_print works well with 0 for all player, I did this without any issues. I need color message. And also need to understand write_byte()
hypheni is offline
Send a message via Skype™ to hypheni
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 02-14-2013 , 02:17   Re: loop through all players
Reply With Quote #4

http://wiki.alliedmods.net/Half-Life...Events#SayText
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
hypheni
Senior Member
Join Date: Jul 2011
Location: India
Old 02-14-2013 , 04:02   Re: loop through all players
Reply With Quote #5

From AMX documentation

write_byte - Writes a single byte to a message.

So does it mean write required bytes for required message. Like for the example YamiKaitou showed is for SayText, and for SayText the byte is SenderID which will be 0 in case server sends the message to all.
hypheni is offline
Send a message via Skype™ to hypheni
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 02-14-2013 , 12:01   Re: loop through all players
Reply With Quote #6

http://forums.alliedmods.net/showthread.php?p=851160
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
hypheni
Senior Member
Join Date: Jul 2011
Location: India
Old 02-16-2013 , 03:58   Re: loop through all players
Reply With Quote #7

I'm still having difficulties. Anyone can give me a short example of sending any message to client with write_byte()
hypheni is offline
Send a message via Skype™ to hypheni
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-16-2013 , 11:05   Re: loop through all players
Reply With Quote #8

Quote:
Originally Posted by hypheni View Post
I'm still having difficulties. Anyone can give me a short example of sending any message to client with write_byte()
write_byte() doesn't send messages to clients. Look at existing examples to see how it is properly used. Or, better yet, use existing functions instead of trying to create your own since you don't know what you are doing.
__________________
fysiks is offline
hypheni
Senior Member
Join Date: Jul 2011
Location: India
Old 02-16-2013 , 11:13   Re: loop through all players
Reply With Quote #9

Well, I'm quite familiar with Windows messaging and here the thing is same. Server sends messages to client. In WinAPI we use SendMessage() here we use message_begin() ... message_end().

What I understand is depending on message type the required byte is different. Now lets say I want send SayText type message to all user.

message_begin(MSG_ALL, get_user_msgid("SayText"), _, 0)

now for write_byte() I need to send sender's ID so that is 0 here as 0 means server. Am I correct ?
hypheni is offline
Send a message via Skype™ to hypheni
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-16-2013 , 21:57   Re: loop through all players
Reply With Quote #10

Quote:
Originally Posted by hypheni View Post
What I understand is depending on message type the required byte is different.
Clearly. The page that Yami has linked to shows you what you need.

Quote:
Originally Posted by hypheni View Post
Now lets say I want send SayText type message to all user.

message_begin(MSG_ALL, get_user_msgid("SayText"), _, 0)

now for write_byte() I need to send sender's ID so that is 0 here as 0 means server. Am I correct ?
You need to start answering your own questions. Just freakin' try it! If it doesn't work then find existing working code that does what you want and try it their way. It's really not that hard to do and does not warrant a new post.

But still, I've not see any reason good reason why you don't just use client_print() or ColorChat().
__________________

Last edited by fysiks; 02-16-2013 at 22:00.
fysiks is offline
Reply



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 11:11.


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