How do you get a player from their name.
#3
As usual, due to multithreading, you cannot get the cPlayer object directly, you can only have a callback be called on it, exactly as STR wrote.
There's even a hackier way to write this in Lua:
cRoot:Get():DoWithPlayer("PlayerName", 
  function(a_Player)
    a_Player:SendMessage("Info");
  end
);

Note that there are two similar functions, DoWithPlayer() and FindAndDoWithPlayer(). The first one requires an exact username match, the second one uses the closest username (you might want to check the username in the callback). I'm not sure now what exactly matches, but I believe substrings do, maybe even one-letter typos.

Oh, wait, the DoWithPlayer() seems to be implemented only on cWorld, not on cRoot. But you should be calling them on a cWorld anyway, since you probably know, which world the player is at.
Reply
Thanks given by: bearbin


Messages In This Thread
RE: How do you get a player from their name. - by xoft - 08-07-2013, 01:12 AM



Users browsing this thread: 1 Guest(s)