Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.15 KB | None | 0 0
  1. Function Char_Save(ByVal UserIndex As Integer, ByVal EsNuevoChar As Boolean) As Boolean
  2. '***************************************************
  3. '@ Autor: Lain
  4. '@ Fecha: 02/08/12
  5. '@ Desc: Guardamos un char en la base de datos.
  6. '***************************************************
  7.  
  8. On Error GoTo ErrHandler
  9.  
  10. ' @@ Declaramos
  11. Dim LoopC As Integer
  12. Dim RepuProm As Long
  13. Dim tmpQuery As String 'About
  14. Dim tmpStr As String
  15.  
  16. With UserList(UserIndex)
  17.  
  18. ' @@ Si es nuevo, creamos la row
  19. If EsNuevoChar Then
  20. ' @@ Asignamos Nombre y cuenta.
  21. CN.Execute ("INSERT INTO `" & DATABASE_TABLE_CHARS & "` (" & CHAR_NAME & "," & CHAR_ACCID & ") VALUES ('" & UCase$(.Name) & "'," & .flags.AccountID & ")"), , adCmdText ' MarianF
  22. ' @@ Obtenemos el ID de la row que acabamos de crear.
  23. .ID = Char_Get_Index(.Name)
  24. End If
  25.  
  26. ' @@ Si llegó aca con un indice no valido, ¡Hay un problema! 'Comentario fix '[/About]
  27. If .ID = INVALID_INDEX Then GoTo ErrHandler
  28.  
  29. ' Basicos
  30. tmpQuery = "UPDATE `" & DATABASE_TABLE_CHARS & "` SET"
  31. tmpQuery = tmpQuery & " " & CHAR_CLASS & "=" & .clase
  32. tmpQuery = tmpQuery & "," & CHAR_RACE & "=" & .raza
  33. tmpQuery = tmpQuery & "," & CHAR_GENRE & "=" & .Genero
  34. tmpQuery = tmpQuery & "," & CHAR_DESC & "='" & .Desc & "'"
  35. tmpQuery = tmpQuery & "," & CHAR_ACC_SLOT & "='" & .Slot & "'"
  36.  
  37. ' Atributos
  38. ' @@ Guardamos los atributos que tiene sin confundirnos por si se drogó
  39.  
  40. If Not .flags.TomoPocion Then '[/About]
  41. tmpQuery = tmpQuery & "," & CHAR_ATR_CELERITY & "=" & CStr(.STATS.UserAtributos(1))
  42. tmpQuery = tmpQuery & "," & CHAR_ATR_STRENGTH & "=" & CStr(.STATS.UserAtributos(2))
  43. tmpQuery = tmpQuery & "," & CHAR_ATR_INTELLIGENCE & "=" & CStr(.STATS.UserAtributos(3))
  44. tmpQuery = tmpQuery & "," & CHAR_ATR_CHARISMA & "=" & CStr(.STATS.UserAtributos(4))
  45. tmpQuery = tmpQuery & "," & CHAR_ATR_CONSTITUTION & "=" & CStr(.STATS.UserAtributos(5))
  46. Else
  47. tmpQuery = tmpQuery & "," & CHAR_ATR_CELERITY & "=" & CStr(.STATS.UserAtributosBackUP(1))
  48. tmpQuery = tmpQuery & "," & CHAR_ATR_STRENGTH & "=" & CStr(.STATS.UserAtributosBackUP(2))
  49. tmpQuery = tmpQuery & "," & CHAR_ATR_INTELLIGENCE & "=" & CStr(.STATS.UserAtributosBackUP(3))
  50. tmpQuery = tmpQuery & "," & CHAR_ATR_CHARISMA & "=" & CStr(.STATS.UserAtributosBackUP(4))
  51. tmpQuery = tmpQuery & "," & CHAR_ATR_CONSTITUTION & "=" & CStr(.STATS.UserAtributosBackUP(5))
  52. End If
  53.  
  54. ' Stats
  55. tmpQuery = tmpQuery & "," & CHAR_MAXHIT & "=" & .STATS.MaxHIT
  56. tmpQuery = tmpQuery & "," & CHAR_MINHIT & "=" & .STATS.MinHIT
  57. tmpQuery = tmpQuery & "," & CHAR_MAXMANA & "=" & .STATS.MaxMAN
  58. tmpQuery = tmpQuery & "," & CHAR_MINMANA & "=" & .STATS.MinMAN
  59. tmpQuery = tmpQuery & "," & CHAR_MAXHP & "=" & .STATS.MaxHP
  60. tmpQuery = tmpQuery & "," & CHAR_MINHP & "=" & .STATS.MinHP
  61. tmpQuery = tmpQuery & "," & CHAR_MINSTA & "=" & .STATS.MinSta
  62. tmpQuery = tmpQuery & "," & CHAR_MAXSTA & "=" & .STATS.MaxSta
  63. tmpQuery = tmpQuery & "," & CHAR_MINSED & "=" & .STATS.MinAGU
  64. tmpQuery = tmpQuery & "," & CHAR_MINHAM & "=" & .STATS.MinHam
  65. tmpQuery = tmpQuery & "," & CHAR_SKILLSFREE & "=" & .STATS.SkillPts
  66.  
  67. ' Flags
  68. tmpQuery = tmpQuery & "," & CHAR_BANNED & "=" & .flags.BAN
  69. tmpQuery = tmpQuery & "," & CHAR_NAKED & "=" & .flags.Desnudo
  70. tmpQuery = tmpQuery & "," & CHAR_NAVIGATING & "=" & .flags.Navegando
  71. tmpQuery = tmpQuery & "," & CHAR_PARALIZED & "=" & .flags.Paralizado
  72. tmpQuery = tmpQuery & "," & CHAR_POISON & "=" & .flags.Envenenado
  73.  
  74. ' Currency
  75. tmpQuery = tmpQuery & "," & CHAR_GOLD & "=" & .STATS.GLD
  76. tmpQuery = tmpQuery & "," & CHAR_ELU & "=" & .STATS.ELU
  77. tmpQuery = tmpQuery & "," & CHAR_ELV & "=" & .STATS.ELV
  78. tmpQuery = tmpQuery & "," & CHAR_EXP & "=" & .STATS.EXP
  79.  
  80. ' Apariencia
  81. tmpQuery = tmpQuery & "," & CHAR_HEAD & "=" & .OrigChar.Head
  82. ' @@ Si no está muerto entonces le guardo el body
  83.  
  84. If .flags.Muerto = 0 Then
  85. tmpQuery = tmpQuery & "," & CHAR_BODY & "=" & .Char.Body
  86. End If
  87.  
  88. tmpQuery = tmpQuery & "," & CHAR_WEAPON & "=" & .Char.WeaponAnim
  89. tmpQuery = tmpQuery & "," & CHAR_HELMET & "=" & .Char.CascoAnim
  90. tmpQuery = tmpQuery & "," & CHAR_SHIELD & "=" & .Char.ShieldAnim
  91.  
  92. ' Posicion
  93. tmpQuery = tmpQuery & "," & CHAR_POSITION_MAP & "=" & CStr(.Pos.Map) & "," & CHAR_POSITION_X & "=" & CStr(.Pos.X) & "," & CHAR_POSITION_Y & "=" & CStr(.Pos.Y)
  94.  
  95. ' Counters
  96. tmpQuery = tmpQuery & "," & CHAR_PUNISH_TIME & "=" & .Counters.PenaCarcel
  97. tmpQuery = tmpQuery & "," & CHAR_NPCKILLED & "=" & .Faccion.NPCsMuertos
  98. tmpQuery = tmpQuery & "," & CHAR_USERKILLED & "=" & .Faccion.UsuariosMatados
  99.  
  100. ' Reputacion
  101. tmpQuery = tmpQuery & "," & CHAR_NOBLEREP & "=" & .Reputacion.NobleRep
  102. tmpQuery = tmpQuery & "," & CHAR_BURGUESREP & "=" & .Reputacion.BurguesRep
  103. tmpQuery = tmpQuery & "," & CHAR_PLEBEREP & "=" & .Reputacion.PlebeRep
  104. tmpQuery = tmpQuery & "," & CHAR_LADRONREP & "=" & .Reputacion.LadronesRep
  105. tmpQuery = tmpQuery & "," & CHAR_BANDIDOREP & "=" & .Reputacion.BandidoRep
  106. tmpQuery = tmpQuery & "," & CHAR_ASESINOREP & "=" & .Reputacion.AsesinoRep
  107. ' Calculo el Promedio
  108. RepuProm = (-.Reputacion.AsesinoRep) + (-.Reputacion.BandidoRep) + .Reputacion.BurguesRep + (-.Reputacion.LadronesRep) + .Reputacion.NobleRep + .Reputacion.PlebeRep
  109. RepuProm = RepuProm / 6
  110.  
  111. ' Faccion
  112. If .Faccion.CaosArmy <> 0 Then
  113. tmpQuery = tmpQuery & "," & CHAR_FACTION & "=2"
  114. ElseIf .Faccion.RoyalArmy <> 0 Then
  115. tmpQuery = tmpQuery & "," & CHAR_FACTION & "=1"
  116. Else
  117. tmpQuery = tmpQuery & "," & CHAR_FACTION & "=0"
  118. End If
  119.  
  120. 'tmpQuery = tmpQuery & "," & CHAR_Horda & "=" & .Faccion.CaosArmy
  121. tmpQuery = tmpQuery & "," & CHAR_RANGECAOS & "=" & .Faccion.RangeCaos
  122. tmpQuery = tmpQuery & "," & CHAR_RANGEROYAL & "=" & .Faccion.RangeRoyal
  123. tmpQuery = tmpQuery & "," & CHAR_CRIMINALS_KILLED & "=" & .Faccion.CiudadanosMatados
  124. tmpQuery = tmpQuery & "," & CHAR_CITIZENS_KILLED & "=" & .Faccion.CriminalesMatados
  125.  
  126. If Not .guild Is Nothing Then 'Si tiene el objeto guild entonces guardamos el id del clan.
  127. tmpQuery = tmpQuery & "," & CHAR_GUILDINDEX & "=" & .guild.getGuildID
  128. End If
  129.  
  130. tmpQuery = tmpQuery & "," & ACC_VAULT & "='"
  131. LoopC = 1
  132.  
  133. Do While LoopC <= MAX_BANCO_SLOTS
  134. tmpQuery = tmpQuery & CStr(.BancoInvent.Object(LoopC).objIndex) & "-" & CStr(.BancoInvent.Object(LoopC).amount) & IIf(LoopC = MAX_BANCO_SLOTS, "'", "-")
  135. LoopC = LoopC + 1
  136. Loop
  137.  
  138. tmpQuery = tmpQuery & CHAR_SPELLS & "='"
  139. LoopC = 1
  140.  
  141. Do While LoopC <= MAX_SPELLS_SLOTS
  142. tmpStr = tmpStr & "-" & CStr(.STATS.UserHechizos(LoopC))
  143. LoopC = LoopC + 1
  144. Loop
  145.  
  146. tmpQuery = tmpQuery & tmpStr
  147.  
  148. tmpStr = tmpStr & "," & CHAR_RINGSLOT & "=" & .Invent.AnilloEqpSlot
  149. tmpStr = tmpStr & "," & CHAR_ARMORSLOT & "=" & .Invent.ArmourEqpSlot
  150. tmpStr = tmpStr & "," & CHAR_BARCASLOT & "=" & .Invent.BarcoSlot
  151. tmpStr = tmpStr & "," & CHAR_HELMETSLOT & "=" & .Invent.CascoEqpSlot
  152. tmpStr = tmpStr & "," & CHAR_SHIELDSLOT & "=" & .Invent.EscudoEqpSlot
  153. tmpStr = tmpStr & "," & CHAR_MUNITIONSLOT & "=" & .Invent.MunicionEqpSlot
  154. tmpStr = tmpStr & "," & CHAR_WEAPONSLOT & "=" & .Invent.WeaponEqpSlot
  155.  
  156. tmpQuery = tmpQuery & tmpStr
  157.  
  158. tmpStr = CHAR_INVOBJS & "='"
  159.  
  160. LoopC = 1
  161.  
  162. Do While LoopC <= MAX_INVENTARIO_SLOTS
  163. tmpStr = tmpStr & CStr(.Invent.Object(LoopC).objIndex) & "-" & CStr(.Invent.Object(LoopC).amount) & "-" & CStr(.Invent.Object(LoopC).Equipped) & IIf(LoopC = MAX_INVENTARIO_SLOTS, "'", "-")
  164. LoopC = LoopC + 1
  165. Loop
  166.  
  167. tmpQuery = tmpQuery & tmpStr
  168.  
  169. tmpStr = CHAR_SKILLS & "='"
  170.  
  171. Do While LoopC <= MAX_SKILLS
  172. tmpStr = tmpStr & CStr(.STATS.UserSkills(LoopC)) & IIf(LoopC = MAX_SKILLS, "'", "-")
  173. LoopC = LoopC + 1
  174. Loop
  175.  
  176. tmpQuery = tmpQuery & tmpStr
  177.  
  178. tmpStr = CHAR_SKILLS_ASSIGNED & "='"
  179. LoopC = 1
  180. Do While LoopC <= MAX_SKILLS
  181. tmpStr = tmpStr & CStr(.STATS.UserAsignedSkills(LoopC)) & IIf(LoopC >= MAX_SKILLS, "'", "-")
  182. LoopC = LoopC + 1
  183. Loop
  184.  
  185. tmpQuery = tmpQuery & tmpStr
  186.  
  187. ' @@ Guardamos los stats
  188. 'If Not SQL.Char_Save_Stats(UserIndex) Then GoTo ErrHandler
  189.  
  190. ' @@ Guardamos los datos de la guild
  191. 'If Not SQL.Char_Save_Guild(UserIndex) Then GoTo ErrHandler
  192.  
  193. ' @@ Guardamos los datos del banco
  194. 'If Not SQL.Account_Save_Bank(UserIndex) Then GoTo ErrHandler
  195.  
  196. ' @@ Guardamos los datos de los hechizos
  197. 'If Not SQL.Char_Save_Spells(UserIndex) Then GoTo ErrHandler
  198.  
  199. ' @@ Guardamos los datos del inventario
  200. 'If Not SQL.Char_Save_Inventory(UserIndex) Then GoTo ErrHandler
  201.  
  202. ' @@ Guardamos los skills del personaje
  203. 'If Not SQL.Char_Save_Skills(UserIndex) Then GoTo ErrHandler
  204.  
  205. End With
  206.  
  207. ' @@ Seteamos true
  208. Char_Save = True
  209.  
  210. ' @@ Nos vamos.
  211. Exit Function
  212.  
  213. ErrHandler:
  214. Char_Save = False
  215. Call LogDBError("Error en Char_Save. Personaje: " & UserList(UserIndex).Name & ". Error: " & err.Number & " " & err.Description & " Línea: " & Erl())
  216. Char_Save = False
  217.  
  218. End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement