Topic: [TUTORIAL] Coding: Broadcast commands and MOTD commands

Hello dear Tees!
Today we're going to see how to add broadcast
commands and MOTD (message of the day) commands!

Note that this tutorial has been made and tested in Teeworlds 0.6.4!
If you haven't compiled your Teeworlds yet, see the Teeworlds help.

If you have previously seen my Commands tutorial then you'll be able to make this very quickly. big_smile

1. Go to src/game/server/chatcmds.cpp.
2. See the example below.
3. Compile the source and test them.

See this example for how to make it look like MOTD:

      CNetMsg_Sv_Motd Msg;
      Msg.m_pMessage = "---------Rules-------\nDon't insult people!\nDon't share accounts! Don't use bots!
      \nDon't cheat, exploit, or anything related\nabout cheating!\nDo not bother or troll people!\n"

      Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, ClientID);
How to make it send a broadcast?

That's pretty easy to code. Just register your command and do:

if(!str_comp_nocase(pMsg, "hello_world"))

SendBroadcast("Hello world!", ClientID);


Compile the source and test your MOTD command. Type /rules and also try /hello_world, or the command you added.
This was a very short tutorial, but if you want to use MOTD or broadcast commands, this'll be very helpful to you. smile

Thanks for your attention! smile

Old Teeworlds ex-gamer | Teeworlds ex-tutorial maker


Re: [TUTORIAL] Coding: Broadcast commands and MOTD commands


Teeworlds [ friends ] clan
Some YouTube Stuff about Teeworlds