Chat system
Blitz3D Forums/Blitz3D Beginners Area/Chat system
| ||
| how can I get a chat system were a player can write on the bottom left corner and be visible to unother person playing?! |
| ||
| That's a big question with many possible answers. I don't know a lot about the networking side of Blitz but... First off, you would have to capture the keypresses with the KeyHit commands and then concatenate them into a string. Draw the string to the screen using the Text command, or Drawimage command. Send the string over the network (this is where I'm not totally familiar with) using a special 'code' that your program recognizes to mean that the following characters sent are a message. Once received on the other side, Draw it to their screen. Pretty simple, really, It's just the specifics that need to be worked out. |
| ||
| ;something like this? LoadImage id "" If KeyDown("a") DrawImage id EndIf ;dont understand the endif |
| ||
| Send the string over the network (this is where I'm not totally familiar with) using a special 'code' that your program recognizes to mean that the following characters sent are a message. I'd hazard a guess that this is the bit he's having trouble with.....? |
| ||
| snigger. |
| ||
| well i havent done it over a network and well im also haveing problems even puting images on the 3d game!! Im trying to have it where the user can input there text but in a print form and have it delete its self after a few seconds!?!! |
| ||
Heres an example
Dim key(50)
key(16) = 81
key(17) = 69
key(18) = 87
key(19) = 82
etc...
key(30) = 65
key(31) = 83
etc...
key(44) =
etc...
;loop
while not keyhit(1)
if keyhit(20) ;"T" go into text mode
inputmess = true
endif
if inputmess = true
for iter = 16 to 25 ;q to p
if keyhit(iter) then message$ = message$ + chr$(key(iter))
next
for iter = 30 to 38; a to l
if keyhit(iter) then message$ = message$ + chr$(key(iter))
next
for iter = 44 to 50; z to m
if keyhit(iter) then message$ = message$ + chr$(key(iter))
next
if keyhit(enter)
displaymess = true
inputmess = false
messdispstart = millisecs()
SendMessageOverNetwork(message$)
endif
endif
if inputmess = true or (displaymess = true and messdispstart + 5000 > millisecs())
text 50, 450, message$
endif
if displaymess = true and millisecs() > messdispstart + 5000
message$ = ""
displaymess = false
endif
wend |
| ||
| now how can i get it to auto delete |
| ||
if inputmess = true or (displaymess = true and messdispstart + 5000 > millisecs())
text 50, 450, message$
endifThat code already does it. |
| ||
| I updated the code some more. Check for differences. |
| ||
| I tried making a chat system. I was using NGUI to make the buttons because I wanted it to look like it didn't run in MSDOS. It didn't work. |
| ||
| Wouldnt it be esier to freeze the entire game while typing messages? That way other players can se a sign over the head of the one typing (or whatever it now is that is speaking). The function can then make the player invunerble or something similar... Also why not skip the timer (since to many can cause a lag) and just delete every fifth message that appears. Just some thoughts didn't mean to be a whise-ass. |
| ||
| yeah but you can You can't really freeze a Online game! and that was my other question how can I delete my print after 5 prints?! |
| ||
| how can I delete my print after 5 prints?! PLEASE try to explain better what you mean...For instance, (this is what I am assuming you meant) you could have said: "How can I get the previous messages that were printed to the screen to scroll up out of the way if more messages appear? Also, how do I get the previous messages to begin to disappear from the scrolling list if more than 5 messages are printed?" If you want someone to take the time to answer your question, then take the time to phrase it as best as you can. Is this what you are looking for?: Graphics 640, 480
Dim key(53)
key(2) = 49
key(3) = 50
key(4) = 51
key(5) = 52
key(6) = 53
key(7) = 54
key(8) = 55
key(9) = 56
key(10) = 57
key(11) = 48
key(16) = 81
key(17) = 87
key(18) = 69
key(19) = 82
key(20) = 84
key(21) = 89
key(22) = 85
key(23) = 73
key(24) = 79
key(25) = 80
key(30) = 65
key(31) = 83
key(32) = 68
key(33) = 70
key(34) = 71
key(35) = 72
key(36) = 74
key(37) = 75
key(38) = 76
key(44) = 90
key(45) = 88
key(46) = 67
key(47) = 86
key(48) = 66
key(49) = 78
key(50) = 77
key(51) = 44
key(52) = 46
key(53) = 63
Dim message$(5)
;loop
While Not KeyHit(1)
t_key = KeyHit(20)
If t_key And inputmess = False;"T" go into text mode
inputmess = True
message$(0) = ""
t_key = False
FlushKeys()
EndIf
If inputmess = True
For iter = 2 To 11 ;1 to 0
If KeyHit(iter) Then message$(0) = message$(0) + Chr$(key(iter))
Next
For iter = 16 To 25 ;q to p
If KeyHit(iter) Then message$(0) = message$(0) + Chr$(key(iter))
Next
If t_key Then message$(0) = message$(0) + Chr$(key(20))
For iter = 30 To 38; a to l
If KeyHit(iter) Then message$(0) = message$(0) + Chr$(key(iter))
Next
For iter = 44 To 53; z to ?
If KeyHit(iter) Then message$(0) = message$(0) + Chr$(key(iter))
Next
If KeyHit(57) Then message$(0) = message$(0) + Chr$(32) ;spacebar
If KeyHit(14) Then message$(0) = Left$(message$(0), Len(message$(0)) - 1) ;backspace
If KeyHit(28) ;enter
inputmess = False
For iter = 5 To 1 Step -1
message$(iter) = message$(iter - 1)
Next
;SendMessageOverNetwork(message$(0))
EndIf
EndIf
If MilliSecs() > messscroll + 5000
For iter = 5 To 2 Step -1
message$(iter) = message$(iter - 1)
Next
message$(1) = ""
messscroll = MilliSecs()
EndIf
;othermessage$ = CheckForMessageReceivedOverNetwork$()
If othermessage$ <> ""
For iter = 5 To 2 Step -1
message$(iter) = message$(iter - 1)
Next
message$(1) = othermessage$
othermessage$ = ""
messscroll = MilliSecs()
EndIf
Cls
Color 255, 255, 255
Rect 48, 373, 550, 79
Color 255, 0, 0
Rect 48, 453, 550, 19
Color 0, 0, 0
For iter = 0 To 5
If iter = 0
If Inputmess = True Then Text 50, 455, message$(0)
Else
Text 50, 450 - (15 * iter), message$(iter)
EndIf
Next
Flip
WendNote that you will have to supply the Network functions... |
| ||
| I have to admire your persistance, WolRon! |
| ||
| I didn't mean that you would freeze the network game only the game for the plyer that is typing the message... But non of that wreally matter now since im sure you know how to do it now. Good Job WolRon! But i still think you could just skip the timer, if it's a busy server the messages will still dissapear as soon as someone writes a new one. Ofcourse most modern game have som kind of timer on their chatsystem. |