Kami wrote:This works in CS:GO, but you will need to add color codes to the message, as I couldn't find the corresponding team color codes (In sourcemod \x03 seems to be the team color, but in SourcePython \x03 is purple)
That is because you are not passing in the player's index for the \x03 color to be the team's color. And, instead of looping through all players to send the message, just don't pass in anything or pass in PlayerIter() to the send method:
Syntax: Select all
SayText2('\x03{0}\x01: {1}'.format(player_names[player.userid], message), index).send()
iPlayer wrote:What if you use SayText instead of SayText2?
SayText2 and SayText work exactly the same in CS:GO except for \x0D:
http://forums.sourcepython.com/showthread.php?586&p=3062&viewfull=1#post3062For CS:S, if I remember correctly, the work the same except for \x03 doesn't display team colors in SayText.
iPlayer wrote:I believe you need to use PreEvent from events.hooks, not regular Event
This is definitely true. You cannot use EventAction inside Event, only PreEvent. However, I did test myself, and it still didn't stop the message from displaying. I tested EventAction.BLOCK, as well, with no effect. You will probably need to use a user message hook to block the specific user message from being sent. We haven't added that functionality directly to SP itself, yet, but you can still accomplish it using the memory package:
http://forums.sourcepython.com/showthread.php?980