umsg.Char
From GMod Wiki
Function | |
Syntax |
umsg.Char( integer value ) Where is this used? |
Description: | |
Includes an integer ranging from -128 to 127 in the usermessage. | |
Returns: | nil |
Part of Library: | umsg |
Realm: | |
BBCode Link: | [b][url=http://wiki.garrysmod.com/?title=Umsg.Char]Umsg.Char [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] |
Example
Description | Send a numeric character . |
---|---|
Used on | |
Code | umsg.Char(1) |
Output | N/A |
Additional Notes
- This is called umsg.Char because the C++ datatype "char" is used to send the data. "char" is used to store the individual characters in non-unicode strings - depending on what letter the char is storing, the character is set to a number that corresponds to that character. This suggests that characters such as "a", "B", "?", and "$" can be thought of as numbers, which is exactly what has been done here - char is being used as a number.
- Please note however, umsg.Char cannot take a string. The given number must be an integer from -128 to 127.
- You can pull a trick to get more space out of a char. You can actually send numbers ranging from 0 to 255 instead of -128 to 127 by sending n-128, where n is the number you want to send, and then doing msg:ReadChar()+128 when the message is received. This is called sending an unsigned char.
- Characters are smaller than short or long integers, so they take up less space.
- If character is nil, 0 will be sent in place of character.