Realtime Chat Input

Advanced game related topics
kawasaki
Enthusiast
Enthusiast
Posts: 182
Joined: Thu Oct 16, 2003 8:09 pm

Realtime Chat Input

Post by kawasaki »

In games like Half Life 2: Deathmatch, or any other multiplayer game, you can press a key combination to enter text, to send to other players... How do i go about updating a string with new keys entered, and control for backspace etc...

Ive tried using a thread with the following code (partial), but it crashes for some reason...

Code: Select all

Procedure ControlInput(a)

Repeat
ExamineKeyboard()
In$=KeyboardInkey()
If In$
TextInput$+In$
Debug In$
If KeyboardReleased(#PB_Key_Delete)
TextInput$=Left(TextInput$,Len(TextInput$)-1)
EndIf
EndIf

Until KeyboardPushed(#PB_Key_Return)
AddChat(UCase(Username)+": "+TextInput$,1)
Chat=0
Keylock=0
TextInput$=""
EndProcedure
This function is called into a seperate thread when Control + C are pressed on the kryboard... "AddChat" points to another procedure which runs fine.

The Examine keyboard only runs once, either in the main loop or in this loop, depending on the value KeyLock.

Any suggestions?

Thanks

Mike
Derek
Addict
Addict
Posts: 2354
Joined: Wed Apr 07, 2004 12:51 am
Location: England

Post by Derek »

You need a window event handler in your loop.

Try putting

e=windowevent()

after your repeat command. The program is getting bogged down with all the events that are being dealt with.
Derek
Addict
Addict
Posts: 2354
Joined: Wed Apr 07, 2004 12:51 am
Location: England

Post by Derek »

Also, I would change the KeyboardReleased(#PB_Key_Delete) to KeyboardReleased(#PB_Key_Back) or at least include both.

Most people use the backspace key to delete. :)
kawasaki
Enthusiast
Enthusiast
Posts: 182
Joined: Thu Oct 16, 2003 8:09 pm

Post by kawasaki »

Thanks :D
Derek
Addict
Addict
Posts: 2354
Joined: Wed Apr 07, 2004 12:51 am
Location: England

Post by Derek »

That's ok
Post Reply