Chat commands

By default, the chat provides a few commands:


  • /slowchat (on|off) - Will enable or disable slowchat for the current session.

  • /ban (Username) (Time) (Reason) - Bans a player. Time is in days.

  • /gms-kick (Username) - Kicks a player

  • /mute (Username) - Mutes a player for 5 minutes



You can add more commands by using gms_script_set_chat_verify, like this:

//Before gms_settings

gms_script_set_chat_verify(scr_chat_verify)


In the script you receive the text the user just entered as argument0. You can use this text to pre-process the chat message before sending it. Finally the script should return true if the message should still be sent, or false if the message should be discarded.

For example, to check if a chat message starts with "/command", use this code:

if string_copy(argument0, 18) == "/command"
{
    show_message("A command!")
    return false
}
return true

Replies (11)

Last message on 17 Mar 2019

BigWhomas on 16 Mar 2019, 19:35:03
How do I actually set up the chat? I tried before but I did it wrong and it messed up the drawing of the login screen :(
vagrantwhale on 16 Mar 2019, 20:33:33
if you're using stuido 1.4...I had to enable and bind it

///create of GMS object
gms_chat_enable(1)

chat_bind_pos(x,y,xx,yy);
vagrantwhale on 16 Mar 2019, 20:34:55
gms_chat_toggle(1)

my bad
BigWhomas on 16 Mar 2019, 22:58:15
Thanks, I'll look into it :D
I've started on the toggle so I just need to sort out the bind.
Out of curiosity, did you put this into the Player step event or somewhere else?
vagrantwhale on 17 Mar 2019, 02:20:03
you can put it in the create event or the draw event...I usually do the draw event
(draw event runs like a step event)
vagrantwhale on 17 Mar 2019, 02:20:28
step event*** or draw event...these forums need an edit button
BigWhomas on 17 Mar 2019, 19:40:08
Sweet, I managed to get it all working thanks :D one quick question, any clue on how I can make it so that inputs are disabled during typing, so like if the user presses T when typing a message it doesn't close the chat?
vagrantwhale on 17 Mar 2019, 20:41:42
I think you could use the function:

gms_chat_istyping ( )

to check if the chat is open & being typed in
BigWhomas on 17 Mar 2019, 21:54:24
I'll have a look into it, thanks for the advice :D
LovaniaTheEntity on 7 Mar 2019, 14:05:33
What the hell!?
I banned a guest from my pc and it banned my whole pc even!.
HELP ME.
Size43 (Administrator) on 10 Mar 2019, 19:25:32
Just unban the account from the developer panel, and you'll be unbanned as well.