I am currently working on a multiplayer based game. The chat is not only supposed to be there for conversation, but is also supposed to act like a server command line.
If the parser receives a chat input contain certain key words, it is supposed to treat it like a command, f.e.:
Hallo!
- should not trigger anything special
kick SomePlayer
tell Hey people, welcome to our server!
someotherCommand followed by multiple arguments
- they all are supposed to be caught by the parser
If some command is found (meaning one of they keywords is matched) it is supposed to divide the string following this markup:
A variable "command" is supposed to contain the key word (f.e. kick). An array "args" is supposed to contain all following words divided by a white space.
I know, I should be using regex for that, however, I am a little bit stuck on this problem. Can anyone help me?