Getting command sender
#1
Hi, i'm trying to get the player who sent the actual command, I searched around the api docs but couldn't find anything. Is there a way to do it? Thanks.
Reply
Thanks given by:
#2
Hi,
How are you intercepting commands? When you register the command (using cPluginManager:BindCommand, http://mc-server.xoft.cz/LuaAPI/cPluginM...#functions or using Info.lua file) you give it a handler function, that handler function receives two parameters, the text that the user has sent (split into individual words into a table of strings) and the cPlayer object for the player who sent the command. So a typical command handler does something like this:
function HandleCmdSomething(a_Split, a_Player)
  -- a_Split is the command, split into words; access like a_Split[1], a_Split[2] etc.
  -- a_Player is the cPlayer object of the player who sent the command

  -- Do something command-related

  -- Notify the player that the command has been done successfully:
  a_Player:SendMessage(cCompositeChat("Success!", mtInfo))  -- Here\'s your cPlayer object being used
  return true
end
Reply
Thanks given by:
#3
(04-24-2014, 07:26 AM)xoft Wrote: ...

Ah right in front of me, thank you!
Reply
Thanks given by:




Users browsing this thread: 1 Guest(s)