Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Option Explicit
- Public Enum tEventos
- DeathMatch = 1
- End Enum
- Private MAX_EVENTS As Byte
- Private Type tUsers
- UI As Integer
- WinnerID As Integer
- PreviousPos As WorldPos
- End Type
- Private Type tEvent
- Active As Boolean
- Quotas As Byte
- Entered As Byte
- Inscription As Long
- Prize As Long
- EventStarted As Boolean
- Users() As tUsers
- EventName As String
- MapEvent As Integer
- End Type
- Private Events() As tEvent
- Private Sub LoadEvents()
- Dim Leer As clsIniManager, LoopC As Long
- Set Leer = New clsIniManager
- Call Leer.Initialize(DatPath & "EVENTOS.DAT")
- MAX_EVENTS = CInt(Leer.GetValue("INIT", "EVENTOS"))
- If MAX_EVENTS > 0 Then
- ReDim Events(1 To MAX_EVENTS) As tEvent
- For LoopC = 1 To MAX_EVENTS
- With Events(LoopC)
- .EventName = CStr(Leer.GetValue("INIT", "EVENTO" & LoopC))
- .MapEvent = CInt(Leer.GetValue("INIT", "MAPA" & LoopC))
- End With
- Next LoopC
- End If
- Set Leer = Nothing
- End Sub
- Public Sub CreateEvent(ByVal UI As Integer, ByVal NumEvent As Byte, ByVal Quotas As Byte, ByVal Inscription As Long, ByVal Prize As Long)
- If NumEvent < 1 Or NumEvent > MAX_EVENTS Then Exit Sub
- If Quotas > 60 Then Quotas = 60
- If Quotas < 2 Then Quotas = 2
- If Prize < 0 Then Prize = 0
- If Inscription < 0 Then Inscription = 0
- With Events(NumEvent)
- If .Active Then
- Call WriteConsoleMsg(UI, "El evento " & .EventName & " ya esta en curso.", FontTypeNames.FONTTYPE_INFO)
- Exit Sub
- End If
- .Active = True
- .Quotas = Quotas
- .Inscription = Inscription
- .Prize = Prize
- ReDim .Users(1 To .Quotas) As tUsers
- Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg(.EventName & Quotas & " Cupos, Inscripción" & IIf(.Inscription > 0, " de: " & Inscription & " monedas de oro, ", " Gratis, ") & IIf(.Prize > 0, "Premio de: " & Prize & " monedas de oro.", " No hay premio.") & " Si desean participar manden /PARTICIPAR", FontTypeNames.FONTTYPE_DIOS))
- End With
- End Sub
- Public Sub CancelEvent(ByVal UI As Integer, ByVal NumEvent As Byte)
- If NumEvent < 1 Or NumEvent > MAX_EVENTS Then Exit Sub
- Dim LoopC As Long, N As Integer
- With Events(NumEvent)
- If Not .Active Then
- Call WriteConsoleMsg(UI, "El evento " & .EventName & " no esta en curso.", FontTypeNames.FONTTYPE_INFO)
- Exit Sub
- End If
- For LoopC = 1 To .Quotas
- N = .Users(LoopC).UI
- If N > 0 Then
- Call WarpUserCharX(N, .Users(LoopC).PreviousPos.Map, .Users(LoopC).PreviousPos.X, .Users(LoopC).PreviousPos.Y, True)
- If .Inscription > 0 Then
- UserList(N).Stats.GLD = UserList(N).Stats.GLD + .Inscription
- Call WriteUpdateGold(N)
- Call WriteConsoleMsg(N, "El evento ha sido cancelado, se te ha devuelto el costo de la inscripción.", FontTypeNames.FONTTYPE_INFO)
- End If
- UserList(N).Slot_ID = 0
- UserList(N).Event_ID = 0
- End If
- Next LoopC
- .Active = False
- .Quotas = 0
- .Inscription = 0
- .Prize = 0
- Erase .Users()
- Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg(.EventName & "El evento ha sido cancelado.", FontTypeNames.FONTTYPE_DIOS))
- End With
- End Sub
- Private Function FindFreeSlot(ByVal NumEvent As Byte) As Byte
- Dim LoopC As Long
- With Events(NumEvent)
- For LoopC = 1 To .Quotas
- If .Users(LoopC).UI < 1 Then
- FindFreeSlot = LoopC
- Exit Function
- End If
- Next LoopC
- End With
- FindFreeSlot = 0
- End Function
- Public Sub EnterEvent(ByVal UI As Integer, ByVal NumEvent As Byte)
- If NumEvent < 1 Or NumEvent > MAX_EVENTS Then Exit Sub
- If Not CanEnterEvent(UI, NumEvent) Then Exit Sub
- Dim FreeSlot As Byte
- FreeSlot = FindFreeSlot(NumEvent)
- If FreeSlot < 1 Then Exit Sub
- If FreeSlot Mod 2 = 0 Then
- Call WriteConsoleMsg(UI, "Has ingresado para el equipo rojo.", FontTypeNames.FONTTYPE_INFO)
- Else
- Call WriteConsoleMsg(UI, "Has ingresado para el equipo azul.", FontTypeNames.FONTTYPE_INFO)
- End If
- UserList(UI).Slot_ID = FreeSlot
- UserList(UI).Event_ID = NumEvent
- Call WarpUserCharX(UI, 1, 50, 50)
- With Events(NumEvent)
- .Entered = .Entered + 1
- .Users(FreeSlot).UI = UI
- If .Entered >= .Quotas Then
- Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg(.EventName & "El cupo ha sido completado!.", FontTypeNames.FONTTYPE_DIOS))
- Exit Sub
- End If
- End With
- End Sub
- Private Function CanEnterEvent(ByVal UI As Integer, ByVal NumEvent As Byte) As Boolean
- CanEnterEvent = False
- With UserList(UI)
- If .Slot_ID > 0 Then
- Call WriteConsoleMsg(UI, "Ya te encuentras en un evento.", FontTypeNames.FONTTYPE_INFO)
- Exit Function
- End If
- If .Event_ID > 0 Then
- Call WriteConsoleMsg(UI, "Ya estas en otro evento.", FontTypeNames.FONTTYPE_INFO)
- Exit Function
- End If
- If Not Events(NumEvent).Active Then
- Call WriteConsoleMsg(UI, "El evento no está en curso.", FontTypeNames.FONTTYPE_DIOS)
- Exit Function
- End If
- If Events(NumEvent).Entered >= Events(NumEvent).Quotas Then
- Call WriteConsoleMsg(UI, "El evento ya no tiene cupos disponibles.", FontTypeNames.FONTTYPE_DIOS)
- Exit Function
- End If
- If .Stats.GLD < Events(NumEvent).Inscription Then
- Call WriteConsoleMsg(UI, "No tienes el oro suficiente.", FontTypeNames.FONTTYPE_DIOS)
- Exit Function
- End If
- End With
- CanEnterEvent = True
- End Function
- Private Sub EventDie(ByVal UI As Integer)
- Dim NumEvent As Byte
- With UserList(UI)
- If .Slot_ID < 1 Then Exit Sub
- NumEvent = .Event_ID
- If NumEvent < 1 Or NumEvent > MAX_EVENTS Then Exit Sub
- Events(NumEvent).Users(.Slot_ID).UI = 0
- If .Slot_ID Mod 2 = 0 Then
- Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg(Events(NumEvent).EventName & .Name & " ha sido derrotado.", FontTypeNames.FONTTYPE_DIOS))
- Else
- Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg(Events(NumEvent).EventName & .Name & " ha sido derrotado.", FontTypeNames.FONTTYPE_DIOS))
- End If
- .Slot_ID = 0
- .Event_ID = 0
- End With
- End Sub
- Private Sub EventDisconnect(ByVal UI As Integer)
- Dim NumEvent As Byte
- With UserList(UI)
- If .Slot_ID < 1 Then Exit Sub
- NumEvent = .Event_ID
- If NumEvent < 1 Or NumEvent > MAX_EVENTS Then Exit Sub
- Events(NumEvent).Users(.Slot_ID).UI = 0
- If .Slot_ID Mod 2 = 0 Then
- Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg(Events(NumEvent).EventName & .Name & " abandona el equipo rojo.", FontTypeNames.FONTTYPE_DIOS))
- Else
- Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg(Events(NumEvent).EventName & .Name & " abandona el equipo azul.", FontTypeNames.FONTTYPE_DIOS))
- End If
- .Slot_ID = 0
- .Event_ID = 0
- End With
- End Sub
- Public Sub WarpUserCharX(ByVal UI As Integer, ByVal Map As Integer, ByVal X As Integer, ByVal Y As Integer, Optional ByVal FX As Boolean = False)
- If InMapBounds(Map, X, Y) Then
- If MapData(Map, X, Y).UserIndex <> UI Then
- Dim NuevaPos As WorldPos
- Dim FuturePos As WorldPos
- FuturePos.Map = Map
- FuturePos.X = X
- FuturePos.Y = Y
- Call ClosestLegalPos(FuturePos, NuevaPos, True)
- If NuevaPos.X <> 0 And NuevaPos.Y <> 0 Then
- Call WarpUserChar(UI, NuevaPos.Map, NuevaPos.X, NuevaPos.Y, FX)
- End If
- End If
- End If
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement