Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Sub HandleSetCanje(ByVal UserIndex As Integer)
- 1 If UserList(UserIndex).incomingData.length < 4 Then
- 2 Err.Raise UserList(UserIndex).incomingData.NotEnoughDataErrCode
- 3 Exit Sub
- 4 End If
- 5 On Error GoTo HandleSetCanje_Error
- 6 With UserList(UserIndex)
- Dim Buffer As New clsByteQueue
- 7 Set Buffer = New clsByteQueue
- 8 Call Buffer.CopyBuffer(.incomingData)
- 9 Call Buffer.ReadByte
- Dim UserName As String
- Dim Amount As Integer
- Dim TargetIndex As Integer
- Dim IndexGM As Boolean
- 10 UserName = Buffer.ReadASCIIString()
- 11 Amount = Buffer.ReadInteger()
- IndexGM = EsGm(UserIndex)
- 12 If Len(UserName) <= 0 Or Len(UserName) >= 30 Then
- 13 Call WriteConsoleMsg(UserIndex, "El nombre es invalido.", FontTypeNames.FONTTYPE_GUILD)
- 14 Call .incomingData.CopyBuffer(Buffer): Exit Sub
- 15 End If
- 16 If Not IndexGM Then
- 17 If Amount <= 0 Or (.Stats.PuntosDeCanje < Amount) Then
- 18 Call WriteConsoleMsg(UserIndex, "No tienes esa cantidad.", FontTypeNames.FONTTYPE_GUILD)
- 19 Call .incomingData.CopyBuffer(Buffer): Exit Sub
- 20 End If
- 21 End If
- 22 TargetIndex = NameIndex(UserName)
- 23 If TargetIndex > 0 Then
- 24 UserList(TargetIndex).Stats.PuntosDeCanje = (UserList(TargetIndex).Stats.PuntosDeCanje + Amount)
- 25 Call WriteSendPoints(TargetIndex)
- 26 Call WriteConsoleMsg(UserIndex, "Le has dado " & CStr(Amount) & " puntos de canje a " & UserName, FontTypeNames.FONTTYPE_GUILD)
- 27 Call WriteConsoleMsg(TargetIndex, .Name & " te ha dado " & CStr(Amount) & " puntos de canje.", FontTypeNames.FONTTYPE_GUILD)
- 28 Call LogCanjes(.Name & " le dio " & Amount & " canjes a " & UserName, 2)
- 29 If Not IndexGM Then
- 30 .Stats.PuntosDeCanje = .Stats.PuntosDeCanje - Amount
- 31 Call WriteSendPoints(UserIndex)
- 32 End If
- 33 Else
- Dim TargetCharPath As String
- 34 TargetCharPath = App.Path & "\Charfile\" & UserName & ".chr"
- 35 If (FileExist(TargetCharPath) = True) Then
- Dim LastAmount As Integer
- 36 LastAmount = val(GetVar(TargetCharPath, "STATS", "PuntosCanje"))
- 37 Call WriteVar(TargetCharPath, "STATS", "PuntosCanje", CStr(LastAmount + Amount))
- 38 Call LogCanjes(.Name & " le dio " & Amount & " canjes a " & UserName, 2)
- 39 Call WriteConsoleMsg(UserIndex, IIf(.flags.Privilegios <> PlayerType.User, "Usuario offline, escribiendo en charfile." & vbNewLine, "") & UserName & " ahora tiene " & CStr(Amount + LastAmount) & " puntos de canje.", FontTypeNames.FONTTYPE_GUILD)
- 40 If Not IndexGM Then
- 41 .Stats.PuntosDeCanje = .Stats.PuntosDeCanje - Amount
- 42 Call WriteSendPoints(UserIndex)
- 43 End If
- 44 Else
- 45 Call WriteConsoleMsg(UserIndex, "El personaje no existe.", FontTypeNames.FONTTYPE_GUILD)
- 46 End If
- 47 End If
- 48 Call .incomingData.CopyBuffer(Buffer)
- 49 End With
- 50 Exit Sub
- HandleSetCanje_Error:
- Dim Error As Long
- 51 Error = Err.Number
- 'Destroy auxiliar buffer
- 52 Set Buffer = Nothing
- 53 If Error <> 0 Then Err.Raise Error
- 54 Call LogError("Error " & Err.Number & " (" & Err.description & ") in procedure HandleSetCanje of Mรณdulo modProtocol" & Erl & ".")
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement