Advertisement
Guest User

Untitled

a guest
Aug 11th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Private Sub HandleSetCanje(ByVal UserIndex As Integer)
  2.  
  3. 1   If UserList(UserIndex).incomingData.length < 4 Then
  4. 2       Err.Raise UserList(UserIndex).incomingData.NotEnoughDataErrCode
  5. 3       Exit Sub
  6. 4   End If
  7.  
  8. 5   On Error GoTo HandleSetCanje_Error
  9.  
  10. 6   With UserList(UserIndex)
  11.  
  12.         Dim Buffer As New clsByteQueue
  13. 7       Set Buffer = New clsByteQueue
  14.  
  15. 8       Call Buffer.CopyBuffer(.incomingData)
  16.  
  17. 9       Call Buffer.ReadByte
  18.  
  19.         Dim UserName As String
  20.         Dim Amount As Integer
  21.         Dim TargetIndex As Integer
  22.         Dim IndexGM As Boolean
  23.  
  24. 10      UserName = Buffer.ReadASCIIString()
  25. 11      Amount = Buffer.ReadInteger()
  26.  
  27.         IndexGM = EsGm(UserIndex)
  28.  
  29. 12      If Len(UserName) <= 0 Or Len(UserName) >= 30 Then
  30. 13          Call WriteConsoleMsg(UserIndex, "El nombre es invalido.", FontTypeNames.FONTTYPE_GUILD)
  31. 14          Call .incomingData.CopyBuffer(Buffer): Exit Sub
  32. 15      End If
  33.  
  34. 16      If Not IndexGM Then
  35. 17          If Amount <= 0 Or (.Stats.PuntosDeCanje < Amount) Then
  36. 18              Call WriteConsoleMsg(UserIndex, "No tienes esa cantidad.", FontTypeNames.FONTTYPE_GUILD)
  37. 19              Call .incomingData.CopyBuffer(Buffer): Exit Sub
  38. 20          End If
  39. 21      End If
  40.  
  41. 22      TargetIndex = NameIndex(UserName)
  42.  
  43. 23      If TargetIndex > 0 Then
  44.  
  45. 24          UserList(TargetIndex).Stats.PuntosDeCanje = (UserList(TargetIndex).Stats.PuntosDeCanje + Amount)
  46. 25          Call WriteSendPoints(TargetIndex)
  47.  
  48. 26          Call WriteConsoleMsg(UserIndex, "Le has dado " & CStr(Amount) & " puntos de canje a " & UserName, FontTypeNames.FONTTYPE_GUILD)
  49. 27          Call WriteConsoleMsg(TargetIndex, .Name & " te ha dado " & CStr(Amount) & " puntos de canje.", FontTypeNames.FONTTYPE_GUILD)
  50. 28          Call LogCanjes(.Name & " le dio " & Amount & " canjes a " & UserName, 2)
  51.  
  52. 29          If Not IndexGM Then
  53. 30              .Stats.PuntosDeCanje = .Stats.PuntosDeCanje - Amount
  54. 31              Call WriteSendPoints(UserIndex)
  55. 32          End If
  56.  
  57. 33      Else
  58.  
  59.             Dim TargetCharPath As String
  60. 34          TargetCharPath = App.Path & "\Charfile\" & UserName & ".chr"
  61.  
  62. 35          If (FileExist(TargetCharPath) = True) Then
  63.  
  64.                 Dim LastAmount As Integer
  65. 36              LastAmount = val(GetVar(TargetCharPath, "STATS", "PuntosCanje"))
  66.  
  67. 37              Call WriteVar(TargetCharPath, "STATS", "PuntosCanje", CStr(LastAmount + Amount))
  68. 38              Call LogCanjes(.Name & " le dio " & Amount & " canjes a " & UserName, 2)
  69.  
  70. 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)
  71.  
  72. 40              If Not IndexGM Then
  73. 41                  .Stats.PuntosDeCanje = .Stats.PuntosDeCanje - Amount
  74. 42                  Call WriteSendPoints(UserIndex)
  75. 43              End If
  76.  
  77. 44          Else
  78. 45              Call WriteConsoleMsg(UserIndex, "El personaje no existe.", FontTypeNames.FONTTYPE_GUILD)
  79. 46          End If
  80.  
  81. 47      End If
  82.  
  83. 48      Call .incomingData.CopyBuffer(Buffer)
  84.  
  85. 49  End With
  86.  
  87. 50  Exit Sub
  88.  
  89. HandleSetCanje_Error:
  90.  
  91.     Dim Error As Long
  92.  
  93. 51  Error = Err.Number
  94.  
  95.     'Destroy auxiliar buffer
  96. 52  Set Buffer = Nothing
  97.  
  98. 53  If Error <> 0 Then Err.Raise Error
  99.  
  100. 54  Call LogError("Error " & Err.Number & " (" & Err.description & ") in procedure HandleSetCanje of Mรณdulo modProtocol" & Erl & ".")
  101.  
  102. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement