Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.79 KB | None | 0 0
  1. function getPlayerPokeballs(cid) --alterado v1.9 \/
  2. local ret = {}
  3. local container = 0
  4.  
  5. if isCreature(cid) then
  6. container = getPlayerSlotItem(cid, 3).uid
  7. local myball = getPlayerSlotItem(cid, 8)
  8. if myball.uid > 0 then
  9. table.insert(ret, myball)
  10. end
  11. else
  12. container = cid
  13. end
  14.  
  15. if isContainer(container) and getContainerSize(container) > 0 then
  16. for slot = 0, (getContainerSize(container) - 1) do
  17. local item = getContainerItem(container, slot)
  18. if isContainer(item.uid) then
  19. local itemsbag = getPlayerPokeballs(item.uid)
  20. if itemsbag and #itemsbag > 0 then
  21. for i = 0, #itemsbag do
  22. table.insert(ret, itemsbag[i])
  23. end
  24. end
  25. elseif isPokeball(item.itemid) then
  26. table.insert(ret, item)
  27. end
  28. end
  29. end
  30. return ret
  31. end
  32.  
  33. function doUpdatePokemonsBar(cid)
  34. if not isCreature(cid) then return true end
  35. if getPlayerStorageValue(cid, 656494) > 0 then
  36. return true
  37. end
  38. setPlayerStorageValue(cid, 656494, 1000)
  39. addEvent(setPlayerStorageValue, 100, cid, 656494, -1)
  40.  
  41. local ret = {}
  42. table.insert(ret, "p#,")
  43. local balls = getPlayerPokeballs(cid)
  44. local times = 0
  45. for a = 1, #balls do
  46. local item = balls[a]
  47. local hp = math.ceil(getItemAttribute(item.uid, "hp") * 100)
  48. local name = getItemAttribute(item.uid, "poke")
  49. local port = getPlayerSlotItem(cid, CONST_SLOT_LEGS)
  50. if fotos[name] >= 11137 and fotos[name] <= 11387 then
  51. times = times + 1
  52. local foto = fotos[name] - 911
  53. doItemSetAttribute(item.uid, "ballorder", times)
  54. table.insert(ret, foto..","..name..""..times..","..hp..",")
  55. elseif fotos[name] >= 12605 then
  56. times = times + 1
  57. local foto = fotos[name] - 1178 --alterado v1.9
  58. doItemSetAttribute(item.uid, "ballorder", times)
  59. table.insert(ret, foto..","..name..""..times..","..hp..",")
  60. else
  61. times = times + 1
  62. local foto = fotos[name] - 928
  63. doItemSetAttribute(item.uid, "ballorder", times)
  64. table.insert(ret, foto..","..name..""..times..","..hp..",")
  65. end
  66. end
  67. doPlayerSendCancel(cid, table.concat(ret))
  68. end
  69.  
  70. function getNewMoveTable(table, n)
  71. if table == nil then
  72. return false
  73. end
  74. local moves = {table.move1, table.move2, table.move3, table.move4, table.move5, table.move6, table.move7, table.move8, table.move9, table.move10, table.move11, table.move12}
  75. local returnValue = moves
  76. if n then
  77. returnValue = moves[n]
  78. end
  79. return returnValue
  80. end
  81.  
  82.  
  83. function doUpdateMoves(cid)
  84. if not isCreature(cid) then return true end
  85. local summon = getCreatureSummons(cid)[1]
  86. local ret = {}
  87. table.insert(ret, "12&,")
  88. if not summon then
  89. for a = 1, 12 do
  90. table.insert(ret, "n/n,")
  91. end
  92. doPlayerSendCancel(cid, table.concat(ret))
  93. addEvent(doUpdateCooldowns, 100, cid)
  94. return true
  95. end
  96. if isTransformed(summon) then --alterado v1.9
  97. moves = movestable[getPlayerStorageValue(summon, 1010)]
  98. else
  99. moves = movestable[getCreatureName(summon)]
  100. end
  101. for a = 1, 12 do
  102. local b = getNewMoveTable(moves, a)
  103. if b then
  104. table.insert(ret, b.name..",")
  105. else
  106. local mEvolve
  107. if not getCreatureName(summon):find("Mega") and getItemAttribute(getPlayerSlotItem(cid, 8).uid, "megaStone") then
  108. if not isInArray(ret, "Mega Evolution,") then
  109. table.insert(ret, "Mega Evolution,")
  110. mEvolve = true
  111. end
  112. end
  113. if not mEvolve then
  114. table.insert(ret, "n/n,")
  115. end
  116. end
  117. end
  118. doPlayerSendCancel(cid, table.concat(ret))
  119. addEvent(doUpdateCooldowns, 100, cid)
  120. end
  121.  
  122. function doUpdateCooldowns(cid)
  123. if not isCreature(cid) then return true end
  124. local a = getPlayerSlotItem(cid, 8)
  125. local ret = {}
  126. table.insert(ret, "12|,")
  127. if a.uid <= 0 or #getCreatureSummons(cid) <= 0 then
  128. for cds = 1, 12 do
  129. if useOTClient then table.insert(ret, "-1|0,") else table.insert(ret, "-1,") end
  130. end
  131. doPlayerSendCancel(cid, table.concat(ret))
  132. return true
  133. end
  134. for cds = 1, 12 do
  135. ----
  136. local summon = getCreatureSummons(cid)[1]
  137. if summon and getPlayerStorageValue(summon, 212123) >= 1 then
  138. cdzin = "cm_move"..cds
  139. else
  140. cdzin = "move"..cds
  141. end
  142. ----
  143. if isTransformed(summon) then --alterado v1.9
  144. moves = movestable[getPlayerStorageValue(summon, 1010)]
  145. else
  146. moves = movestable[getCreatureName(summon)]
  147. end
  148. local b = getNewMoveTable(moves, cds)
  149. if not b then
  150. for cds = 1, 12 do
  151. if useOTClient then table.insert(ret, "-1|0,") else table.insert(ret, "-1,") end --alterado v1.9
  152. end
  153. doPlayerSendCancel(cid, table.concat(ret))
  154. return true
  155. end
  156. ----
  157. if getCD(a.uid, cdzin) > 0 then
  158. if (useOTClient and b) then table.insert(ret, (getCD(a.uid, cdzin)).."|"..b.level..",") else table.insert(ret, (getCD(a.uid, cdzin))..",") end
  159. else
  160. if (useOTClient and b) then table.insert(ret, "0|"..b.level..",") else table.insert(ret, "0,") end
  161. end
  162. end
  163. doPlayerSendCancel(cid, table.concat(ret))
  164. end
  165.  
  166. function getBallsAttributes(item)
  167. local t = {"poke", "gender", "nick", "boost", "happy", "hp", "description", "transBegin", "hunger", "transLeft", "transTurn", "transOutfit", "transName",
  168. "trans", "light", "blink", "move1", "move2", "move3", "move4", "move5", "move6", "move7", "move8", "move9", "move10", "move11", "move12", "ballorder",
  169. "hands", "aura", "burn", "burndmg", "poison", "poisondmg", "confuse", "sleep", "miss", "missSpell", "missEff", "fear", "fearSkill", "silence",
  170. "silenceEff", "stun", "stunEff", "stunSpell", "paralyze", "paralyzeEff", "slow", "slowEff", "leech", "leechdmg", "Buff1", "Buff2", "Buff3", "Buff1skill",
  171. "Buff2skill", "Buff3skill", "control", "unique", "task", "lock"}
  172. local ret = {}
  173. for a = 1, #t do
  174. if getItemAttribute(item, t[a]) == "hands" then
  175. return
  176. end
  177. ret[t[a]] = getItemAttribute(item, t[a]) or false
  178. end
  179. return ret
  180. end
  181.  
  182. function doChangeBalls(cid, item1, item2)
  183. if not isCreature(cid) then return true end
  184. if item1.uid == item2.uid then
  185. if #getCreatureSummons(cid) <= 0 then
  186. doGoPokemon(cid, getPlayerSlotItem(cid, 8))
  187. else
  188. doReturnPokemon(cid, getCreatureSummons(cid)[1], getPlayerSlotItem(cid, 8), pokeballs[getPokeballType(getPlayerSlotItem(cid, 8).itemid)].effect)
  189. end
  190. return true
  191. end
  192.  
  193. if item1.uid > 0 and item2.uid > 0 then
  194. local io = getBallsAttributes(item1.uid)
  195. local it = getBallsAttributes(item2.uid)
  196. for a, b in pairs (io) do
  197. if b then
  198. doItemSetAttribute(item2.uid, a, b)
  199. else
  200. doItemEraseAttribute(item2.uid, a)
  201. end
  202. end
  203. for a, b in pairs (it) do
  204. if b then
  205. doItemSetAttribute(item1.uid, a, b)
  206. else
  207. doItemEraseAttribute(item1.uid, a)
  208. end
  209. end
  210. local id = item2.itemid
  211. doTransformItem(item2.uid, item1.itemid)
  212. doTransformItem(item1.uid, id)
  213. doGoPokemon(cid, getPlayerSlotItem(cid, 8))
  214. else
  215. local id = item2.itemid
  216. local b = getBallsAttributes(item2.uid)
  217. local a = doPlayerAddItem(cid, 2643, false)
  218. for c, d in pairs (b) do
  219. if d then
  220. doItemSetAttribute(a, c, d)
  221. else
  222. doItemEraseAttribute(a, c)
  223. end
  224. end
  225. doRemoveItem(item2.uid, 1)
  226. doTransformItem(a, id)
  227. doGoPokemon(cid, getPlayerSlotItem(cid, 8))
  228. end
  229. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement