Chat System Problem

Posted by MrMunchyGaming
I set up a little chat system earlier, but it keeps glitching out and is pretty much useless. Here's the code I used:

Create:
chat = 0;
gms_chat_keys("T",vk_enter,0);
gms_chat_draw();
gms_chat_colors(c_white,c_dkgray,0.35);
gms_chat_set_font(fnt_terminus);
gms_chat_bind_view(0,cp_bottom,640);

Press T-key:
if chat = 0{
gms_chat_toggle(true);
chat = 1;
}else{
gms_chat_toggle(false);
chat = 0;
}

Replies (4)

Last message on 29 Dec 2017

Size43 (Administrator) on 29 Dec 2017, 12:56:26
Note that you'll need to use ord('T') instead of just "T" for gms_chat_keys.

Can you try to describe (or make a screenshot / gif) of the glitching?
MrMunchyGaming (Topicstarter) on 29 Dec 2017, 18:17:15
Thanks, I believe that that was why it was glitching, as it is working perfectly now. Thanks!
Pick on 29 Dec 2017, 11:49:30
Hi,

I've just come up with some new code and hopefully a a solution for your issue. Put this code in your obj_player Step Event.

[code]
if chat == 0 && keyboard_check_pressed(ord('T)) {
obj_chat.visible = true;
chat == 1;
} else if (chat == 1 && keyboard_check_pressed(ord('T)) {
obj_chat.visible = false;
chat == 0;
}

This new code doesn't loop through and do something unless the defined variable AND the letter T has been pressed. Let me know if you have any issues!
Pick on 29 Dec 2017, 11:33:09
Hi,

After looking at your code I think I know the issue here - but I might be mistaken.

You are setting it to make the chat visible when the user has pressed T, but the else statement is also checking if the user hasn't pressed T, so from what I can see you need to organize your code better as it's just looping through them.

You can also use code like this to make chat visible and invisible instead of toggling the chat, which I think is the main issue here.
obj_chat.visible = false;
obj_chat.visible = true;