Send message to a single player

Please post any questions about developing your plugin here. Please use the search function before posting!
Grimston
Junior Member
Posts: 2
Joined: Thu Oct 09, 2014 11:47 am

Send message to a single player

Postby Grimston » Thu Oct 09, 2014 2:31 pm

Greetings,

I was wondering what the equivalent of es.tell is?

Syntax: Select all

#BuildMessage wraps a colored prefix to the message, that works fine
def Tell(self, msg, *target):
for t in target:
SayText2(BuildMessage(msg), 0, t).send()

#This event is in my own class, the GameEvent var is passed straight from the actual EventHook
def OnPlayerJump(self, GameEvent):
self.Tell("You have jumped!", index_from_userid(GameEvent.get_int("userid")))


As I understand its
SayText2(Message, [Index], [Users]) - Little confused as to what the index is about... from what i can tell, the player saying the message? (Kind of want to get the same result as es.tell and es.msg)

This works but is viewable by everyone

I have tried TextMsg but this results in instant crashing when attempting to call it.

Regards, Grimston
Tuck
Global Moderator
Posts: 205
Joined: Sat Jul 14, 2012 9:35 pm
Location: Copenhagen

Postby Tuck » Thu Oct 09, 2014 4:11 pm

Index for a player on CT will give blue "team color" and so on for t and spec, just put the users index

this bellow is how i would do it For example:

Syntax: Select all

Saytext2(msg, user.index, user)
-Tuck
Grimston
Junior Member
Posts: 2
Joined: Thu Oct 09, 2014 11:47 am

Postby Grimston » Thu Oct 09, 2014 4:58 pm

Ah okay, so it allows for doing both.

What exactly are you passing in for the user, the userid, index or steamid?

As I'm still getting every message show to all (Testing with bots in mimic mode to create the events)
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Thu Oct 09, 2014 5:53 pm

You can pass in a player's index, a list of indexes, a PlayerIter instance, or a RecipientFilter instance.
Image
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Postby L'In20Cible » Fri Oct 10, 2014 12:38 am

Your Tell function could also be:

Syntax: Select all

def Tell(self, msg, *target): 
SayText2(BuildMessage(msg)).send(*target)
That way you are not creating multiple messages while sending it to multiple users.

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 152 guests