noxworld-dev / opennox

OpenNox main repository.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add TeamChat function.

Ephreaym opened this issue · comments

To support bot feedback only to their team.

Already implemented in NS v4.9.0: OnChat.

You can use it like this (after upcomming alpha release):

func OnEvent(typ string) { // called for global script events, similar to OnFrame 
   switch typ {
   // map is ready; init() is too early, so we wait for MapInitialize instead
   case "MapInitialize":
      // register callback for chat
      ns4.OnChat(onChat)
   }
}

func onChat(t ns4.Team, p ns4.Player, obj ns4.Obj, msg string) string {
   // t - team for this message; nil for global chat
   // p - contains a player that sent a message; may be nil for chat sent from scripts!
   // obj - an object that sent this message 
   if t != nil {
      // Team is set - it's a team chat!
   } else {
      // Team is not set - global message
   }
   return msg // allow the message to be seen; or return "" to hide it
}