Messaging system changes
Posted: Tue Nov 27, 2012 3:38 pm
Just a heads up for future changes to the messaging system. We are no longer simply using functions for messages. They are now utilizing class objects:
The "users" arguments has been moved in all usermessages from the first argument to either the last or next to last argument, so take special note of that. Here are the arguments, which are also attributes, for the current classes (note that <> around an argument means it is "required" when getting an instance, and [] around an argument means it is optional when getting an instance):
There is still quite a bit of work to be done on this new system, including adding in the ability to use tokens and lang strings (though a "rough" lang string implementation has been added, for now).
Once we get some Linux build issues resolved, we will post another release build for CS:GO and a build that will work for Valve OrangeBox games!!
Satoon
Syntax: Select all
from events import Event
from messages import SayText2
from players.helpers import index_from_userid
# Create a message to send to non-living terrorists
# Could also use [['t'], ['alive']] for the [users] argument
message = SayText2('\x01This\x02 is\x03 a\x04 test.', users=['t', 'alive'])
@Event
def player_say(GameEvent):
# Get the player's index
userid = GameEvent.GetInt('userid')
index = index_from_userid(userid)
# Set the message's index
# Note that this index will remain the same if you send it again without changing the index
# If you never set an index, it will always use 0
message.index = index
message.send()
Syntax: Select all
from events import Event
from messages import SayText2
# Create a message without any [users] being passed
message = SayText2('\x01This\x02 is\x03 another\x04 test.')
@Event
def player_say(GameEvent):
# Pass the users when sending
message.send(['t', 'alive'])
Syntax: Select all
from events import Event
from messages import SayText2
# Create a message without any [users] being passed
message = SayText2('\x01This\x02 is\x03 another\x04 test.')
# Set the [users]
message.users = ['t', 'alive']
@Event
def player_say(GameEvent):
message.send()
The "users" arguments has been moved in all usermessages from the first argument to either the last or next to last argument, so take special note of that. Here are the arguments, which are also attributes, for the current classes (note that <> around an argument means it is "required" when getting an instance, and [] around an argument means it is optional when getting an instance):
- Fade
- <fade_type>
- <fade_time>
- <hold_time>
- <red>
- <green>
- <blue>
- [alpha]
- [users]
- HintText
- <message>
- [users]
- [tokens]
- KeyHintText
- <message>
- [users]
- [tokens]
- SayText2
- <message>
- [index]
- [users]
- [tokens]
- Shake
- <magnitude>
- <time>
- [users]
- TextMsg
- <message>
- [type]
- [users]
- [tokens]
Syntax: Select all
from events import Event
from messages import TextMsg
example1 = TextMsg('This is a test')
# The types are class attributes
example1.type = TextMsg.CenterMsg
# You can also pass it in as the second argument (only as a class attribute)
example2 = TextMsg('This is a test', TextMsg.Echo)
example3 = TextMsg('This is a test')
# Once you have an instance, you can also set using the instance's attribute
example3.type = example3.Echo
There is still quite a bit of work to be done on this new system, including adding in the ability to use tokens and lang strings (though a "rough" lang string implementation has been added, for now).
Once we get some Linux build issues resolved, we will post another release build for CS:GO and a build that will work for Valve OrangeBox games!!
Satoon