ChatChannel

There are many types of events for the ChatChannel interface, here is a list.

<channel id="8" name="GodChannel" script="godchat.lua" />
  • Alternatively you can use revscript method to register via lua, by saving a .lua file in data/scripts folder.

Please keep in mind you can name your script whatever you want as long as it ends in .lua, and its full name is in the xml, with script="scriptname.lua"

canJoin(player)

  • player -- 1st arg/parameter /userdata/ = The player who is trying to join the channel

canJoin is called whenever any player attempts to open the registered channel.

You can register your event in movement.xml like so:

<channel id="8" name="GodChannel" script="godchat.lua" />

You can then call the event in a script like so:

Example: godchat.lua

Always remember to return true if you wish to allow player to join the channel, false if not!

onJoin(player)

  • player -- 1st arg/parameter /userdata/ = The player whom has just joined the channel

onJoin is called whenever any player joins the registered chatchannel

You can register your event in creaturescripts.xml like so:

You can then call the event in a script like so:

Example: godchat.lua

onJoin will execute its logic everytime a player joins the channel, returns don't matter for this event!

onLeave(player)

  • player -- 1st arg/parameter /userdata/ = The player who has left the registered chatchannel

onLeave is called whenever a player leaves the registered chatchannel

You can register your event in creaturescripts.xml like so:

You can then call the event in a script like so:

Example: godchat.lua

onLeave will execute its logic everytime a player leaves the channel, returns don't matter for this event!

onSpeak(player, type, message)

  • player -- 1st arg/parameter /userdata/ = The player that is removing the item

  • type -- 2nd arg/parameter /integer/ = a constant value representing the TALK_TYPE

  • message -- 3rd arg/parameter /string/ = the text that player has sent

onSpeak runs everytime a player in the chatchannel sends a message.

You can register your event in creaturescripts.xml like so:

You can then call the event in a script like so:

Example: godchat.lua

onSpeak executes everytime a player speaks in registered channel, returns don't matter here

Here is a complete example including all the events in one file

Example in xml:

Example: godchat.lua

Last updated

Was this helpful?