CUICUI
Inmortal Lvl 8
Ya está aportado esto pero yo lo hice tipo TDS.
¿Cómo funciona?
EXTRA: Agregué una validación simple para evitar que modifiquen el formato del mensaje (RGB, bold e italic.)
SERVIDOR
CLIENTE
¿Cómo funciona?
- El servidor al iniciar prende el sistema de mensajes globales.
- El usuario al loguear no puede leer o escribir mensajes globales a no ser que use el comando /ACTIVAR.
- Cualquier GM puede habilitar o deshabilitar los mensajes globales mediante /ActivarGlobal
EXTRA: Agregué una validación simple para evitar que modifiquen el formato del mensaje (RGB, bold e italic.)
SERVIDOR
Agregamos 3 paquetes en el ClientPacketID:
Debajo de
Poner
Al final de protocol poner:
Buscar
y debajo poner
En el sub connectnewuser debajo de:
Poner
En el sub connectuser debajo de:
Poner
En el sub ResetUserFlags, debajo de:
Poner
Buscar
Debajo poner:
En Declaraciones ponemos:
Buscar
Debajo poner:
Buscar
Debajo poner:
Buscar
Debajo poner:
Código:
Activar
GlobalMessage
GlobalStatus
Código:
Case ClientPacketID.ShareNpc
Call HandleShareNpc(UserIndex)
Código:
Case ClientPacketID.GlobalMessage
Call HandleGlobalMessage(UserIndex)
Case ClientPacketID.GlobalStatus
Call HandleGlobalStatus(UserIndex)
Case ClientPacketID.Activar
Call HandleActivar(UserIndex)
Código:
Private Sub HandleGlobalMessage(ByVal UserIndex As Integer)
'***************************************************
'Author: Martín Gomez (Samke)
'Last Modification: 10/03/2012
'
'***************************************************
Dim buffer As New clsByteQueue
With UserList(UserIndex)
Call buffer.CopyBuffer(.incomingData)
'Remove packet ID
Call buffer.ReadByte
Dim message As String
message = buffer.ReadASCIIString()
If .flags.LeerGlobal Then
If Not (GetTickCount() - .UltimoGlobal) < (INTERVALO_GLOBAL * 1000) Then
If GlobalActivado = 1 And .flags.Silenciado = 0 Then
If .flags.Muerto <> 0 Or .death Then
Call WriteConsoleMsg(UserIndex, "Tu estado no te permite enviar un mensaje global.", FontTypeNames.FONTTYPE_INFO)
Else 'Not flagmuerto or Death
Call SendData(SendTarget.toAll, 0, PrepareMessageConsoleMsg("[" & .name & "] " & message, FontTypeNames.FONTTYPE_GLOBAL))
.UltimoGlobal = GetTickCount()
End If
' @@ El /Silenciar también te mutea prro
ElseIf GlobalActivado = 1 And .flags.Silenciado = 1 Then Call WriteConsoleMsg(UserIndex, "Estás silenciado..", FontTypeNames.FONTTYPE_INFO)
Else ' @@ Not globalActivado
Call WriteConsoleMsg(UserIndex, "En estos momentos el sistema de global se encuentra desactivado..", FontTypeNames.FONTTYPE_INFO)
End If
Else ' puto
Call WriteConsoleMsg(UserIndex, "Debes esperar unos segundos para enviar otro mensaje global.", FontTypeNames.FONTTYPE_INFO)
End If
End If
Call .incomingData.CopyBuffer(buffer)
End With
Set buffer = Nothing
End Sub
Private Sub HandleGlobalStatus(ByVal UserIndex As Integer)
'***************************************************
'Author: Martín Gomez (Samke)
'Last Modification: 10/03/2012
'
'***************************************************
With UserList(UserIndex)
'Remove packet ID
Call .incomingData.ReadByte
If .flags.Privilegios > PlayerType.Consejero Then
If GlobalActivado = 1 Then
GlobalActivado = 0
Call SendData(SendTarget.toAll, 0, PrepareMessageConsoleMsg("Global> Global Desactivado.", FontTypeNames.FONTTYPE_SERVER))
Else
GlobalActivado = 1
Call SendData(SendTarget.toAll, 0, PrepareMessageConsoleMsg("Global> Global Activado.", FontTypeNames.FONTTYPE_SERVER))
End If
End If
End With
End Sub
Public Sub HandleActivar(ByVal UserIndex As Integer)
'***************************************************
'Author: Cuicui
'***************************************************
With UserList(UserIndex)
'Remove packet ID
Call .incomingData.ReadByte
' @@ Tiene que estar vivo
If .flags.Muerto Then Call WriteConsoleMsg(UserIndex, "Debes estar vivo para realizar esta acción.", FontTypeNames.FONTTYPE_INFO): Call FlushBuffer(UserIndex): Exit Sub
If .Counters.Pena <> 0 Then Call WriteConsoleMsg(UserIndex, "Debes estar vivo para realizar esta acción.", FontTypeNames.FONTTYPE_INFO): Call FlushBuffer(UserIndex): Exit Sub
If .flags.LeerGlobal = 0 Then
.flags.LeerGlobal = 1
Call WriteConsoleMsg(UserIndex, "Empiezas a leer el chat global.", FontTypeNames.FONTTYPE_INFO)
Else
.flags.LeerGlobal = 0
Call WriteConsoleMsg(UserIndex, "Dejas de leer el chat global.", FontTypeNames.FONTTYPE_INFO)
End If
End With
End Sub
Buscar
Código:
Public Type UserFlags
Código:
LeerGlobal As Boolean
En el sub connectnewuser debajo de:
Código:
.flags.Escondido = 0
Código:
.flags.LeerGlobal = 0
En el sub connectuser debajo de:
Código:
.flags.TargetUser = 0
Código:
.flags.LeerGlobal = 0
UserList(UserIndex).ultimoGlobal = GetTickCount()
En el sub ResetUserFlags, debajo de:
Código:
.Ignorado = False
Código:
.LeerGlobal = False
Buscar
Código:
Public Type User
Código:
ultimoGlobal As Long
En Declaraciones ponemos:
Código:
Public Const INTERVALO_GLOBAL As Integer = 5 'segundos
Public GlobalActivado As byte 'porq no lo dejamos en boolean?
Buscar
Código:
DatPath = App.Path & "\Dat\"
Código:
GlobalActivado = 1
Buscar
Código:
Public Enum FontTypeNames
Código:
FONTTYPE_GLOBAL
Buscar
Código:
Public Const FONTTYPE_INFO As String = "~65~190~156~0~0"
Código:
Public Const FONTTYPE_GLOBAL As String = "~139~248~244~0~1" ' Pongale el que quieran
CLIENTE
Agregar 3 paquetes:
Al final del Protocol poner:
Debajo de:
Poner:
Código:
GlobalMessage
GlobalStatus
Activar
Al final del Protocol poner:
Código:
Public Sub WriteGlobalStatus()
'***************************************************
'Writes the "GlobalStatus" message to the outgoing data buffer
'***************************************************
Call outgoingData.WriteByte(ClientPacketID.GlobalStatus)
End Sub
Public Sub WriteGlobalMessage(ByVal Message As String)
'***************************************************
'Writes the "GlobalMessage" message to the outgoing data buffer
'***************************************************
With outgoingData
Call .WriteByte(ClientPacketID.GlobalMessage)
Call .WriteASCIIString(Message)
End With
End Sub
Public Sub WriteActivar()
'***************************************************
'En realidad activa y desactiva :v
'***************************************************
Call outgoingData.WriteByte(ClientPacketID.Activar)
End Sub
Debajo de:
Código:
Case "/TELEPLOC"
Call WriteWarpMeToTarget
Código:
Case "/ACTIVARGLOBAL"
Call WriteGlobalStatus
Case "/GLOBAL"
If notNullArguments Then
Call WriteGlobalMessage(ArgumentosRaw)
Else
'Avisar que falta el parametro
Call ShowConsoleMsg("Escriba un mensaje.")
End If
Case "/ACTIVAR"
If UserEstado = 1 Then 'Muerto
With FontTypes(FontTypeNames.FONTTYPE_INFO)
Call ShowConsoleMsg("¡¡Estás muerto!!", .red, .green, .blue, .bold, .italic)
End With
Exit Sub
End If
Call WriteActivar
Última edición: