Estava entediado,então resolvi fazer mais um tutorial para vocês...
Bom,isso fará com que as mensagens do servidor para o cliente apareçam na picScreen,para chamar mais a atenção dos jogadores...
Vamos começar...
Crie o seguinte: (no frmMain)
-Uma picturebox com nome de picNoticia
-Uma label dentro da picNoticia com o nome de lblNoticia
-Um timer com o nome de tmrNoticia
Começando no cliente.
No modHandleData,no final adicione:
Ainda no modHandleData,abaixo de:
Adicione:
Agora,no modEnumerations,abaixo de:
Adicione:
Agora vamos ao servidor.
No frmServer,abra o txtChat,e troque o que tiver nele por isso:
Em modEnumerations,abaixo de:
Adicione:
Agora,em modServerTcp,no final adicione:
Pronto,agora as mensagens do servidor vão aparecer na picScreen do cliente...
Bom,isso fará com que as mensagens do servidor para o cliente apareçam na picScreen,para chamar mais a atenção dos jogadores...
Vamos começar...
Crie o seguinte: (no frmMain)
-Uma picturebox com nome de picNoticia
-Uma label dentro da picNoticia com o nome de lblNoticia
-Um timer com o nome de tmrNoticia
Começando no cliente.
No modHandleData,no final adicione:
- Código:
Sub HandleNoticia(ByVal index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
Dim Msg As String
Dim color As Byte
If Options.Debug = 1 Then On Error GoTo errorhandler
If frmMain.picNoticia.Visible = False Then
frmMain.picNoticia.Visible = True
End If
If frmMain.tmrNoticia.Enabled = False Then
frmMain.tmrNoticia.Enabled = True
End If
Dim Buffer As clsBuffer
Set Buffer = New clsBuffer
Buffer.WriteBytes Data()
Msg = Buffer.ReadString
color = Buffer.ReadLong
frmMain.lblNoticia.Caption = Msg
' Error handler
Exit Sub
errorhandler:
HandleError "HandleNoticia", "modHandleData", Err.Number, Err.Description, Err.Source, Err.HelpContext
Err.Clear
Exit Sub
End Sub
Ainda no modHandleData,abaixo de:
- Código:
HandleDataSub(SPartyVitals) = GetAddress(AddressOf HandlePartyVitals)
Adicione:
- Código:
HandleDataSub(SNoticia) = GetAddress(AddressOf HandleNoticia)
Agora,no modEnumerations,abaixo de:
- Código:
SPartyVitals
Adicione:
- Código:
SNoticia
Agora vamos ao servidor.
No frmServer,abra o txtChat,e troque o que tiver nele por isso:
- Código:
Private Sub txtChat_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyReturn Then
If LenB(Trim$(txtChat.Text)) > 0 Then
Call SendNoticia(txtChat.Text)
Call GlobalMsg(txtChat.Text, White)
Call TextAdd("Server: " & txtChat.Text)
txtChat.Text = vbNullString
End If
KeyAscii = 0
End If
End Sub
Em modEnumerations,abaixo de:
- Código:
SPartyVitals
Adicione:
- Código:
SNoticia
Agora,em modServerTcp,no final adicione:
- Código:
Public Sub SendNoticia(ByVal Msg As String, ByVal color As Byte)
Dim Buffer As clsBuffer
Set Buffer = New clsBuffer
Buffer.WriteLong SNoticia
Buffer.WriteString Msg
SendDataToAll Buffer.ToArray
Set Buffer = Nothing
End Sub
Pronto,agora as mensagens do servidor vão aparecer na picScreen do cliente...