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:
//Right after 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, 1, 8) == "/command"
{
show_message("A command!")
return false
}
return true
Replies (19)
Last message on 18 Jun 2022
Hello, I have questions on customizing the chat and username. For the username, how can I make the username color rainbow? And for the chat, whenever the player presses Enter, a typeable chat box will appear on top of the player (With the username hidden) and whenever they send the message, the typed message will appear on the bottom of the player. I have a video reference on it if you don't understand.
Size43
(Administrator)
on
18 Jun 2022, 14:11:11
You can use
gms_script_set_drawchat to add custom code to draw the chat messages. But it sounds like you want a fully custom chat system. In that case, you can use gms_chat_num and the gms_chat_get_* functions to enumerate over all chat messages and draw them as you wish.
You can also use
gms_script_set_chat_receive to intercept incoming chat messages.
I want to know how to use that of / ban and / kick since I use it and it is useless also how do I limit the characters in the chat?
Size43
(Administrator)
on
17 Oct 2020, 17:03:30
Could you explain what you mean by "useless"? As far as I'm aware, these commands are working fine.
Usually, people limit the number of characters in the chat by limiting the number of characters in the keyboard_string variable.
I have 2 questions, How would i do more than one command and secondly how can i find a player id i want using commands so say if i wanted to make a log and i can give my self gold but i want to give someone else it
like /give gold 255 to "player_id"
Size43
(Administrator)
on
4 Apr 2020, 15:56:27
You can add an "else if"-branch after the first if to add more commands.
For giving something to someone else you will most likely want to use p2p messages to send the command to the player that is receiving something, and then update it on that player's client.
I got an error when gms_script_set_chat_verify(scr_chat_verify) was put before gms_settings. It worked when I put it after so I think that info should be updated in the doc above.
Size43
(Administrator)
on
18 Jun 2019, 13:17:55
Thanks, fixed!
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 :(
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);
gms_chat_toggle(1)
my bad
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?
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)
step event*** or draw event...these forums need an edit button
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?
I think you could use the function:
gms_chat_istyping ( )
to check if the chat is open & being typed in
I'll have a look into it, thanks for the advice :D
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.