Advertisement
Guest User

Untitled

a guest
May 30th, 2021
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.35 KB | None | 0 0
  1. CaughtWindow = {
  2. storage_catched = 30000,
  3. pokemons = {
  4. -- 500 EXP
  5. ["caterpie"] = {portrait = 11998, experience = 500, storage_balls = 15050},
  6. ["weedle"] = {portrait = 12001, experience = 500, storage_balls = 15051},
  7. ["rattata"] = {portrait = 12007, experience = 500, storage_balls = 15052},
  8. }
  9. }
  10.  
  11. CaughtWindow.ballcount = function(cid, pokename, ballid)
  12. local poketab = CaughtWindow.pokemons[pokename:lower()]
  13. if poketab then
  14. local pokecount = {}
  15. if type(getPlayerStorageValue(cid, poketab.storage_balls)) == "string" then
  16. pokecount = loadstring("return " .. getPlayerStorageValue(cid, poketab.storage_balls))()
  17. end
  18. if pokecount[ballid] then
  19. pokecount[ballid] = pokecount[ballid] + 1
  20. else
  21. pokecount[ballid] = 1
  22. end
  23. setPlayerStorageValue(cid, poketab.storage_balls, table.string(pokecount))
  24. end
  25. end
  26.  
  27. CaughtWindow.sendcaught = function(cid, pokename)
  28. local poketab = CaughtWindow.pokemons[pokename:lower()]
  29. if poketab and not getPlayerStorageValue(cid, CaughtWindow.storage_catched):find(pokename) then
  30. local send = "$CaughtWindow&" .. getItemInfo(poketab.portrait).clientId .. "&" .. pokename .. "&" .. poketab.experience
  31.  
  32. local pokecount = loadstring("return " .. getPlayerStorageValue(cid, poketab.storage_balls))()
  33. for ballid, count in pairs(pokecount) do
  34. send = send .. "&" .. getItemInfo(ballid).clientId .. "@" .. count .. "x " .. getItemInfo(ballid).name
  35. end
  36. if type(getPlayerStorageValue(cid, CaughtWindow.storage_catched)) == "string" then
  37. setPlayerStorageValue(cid, CaughtWindow.storage_catched, getPlayerStorageValue(cid, CaughtWindow.storage_catched) .. pokename)
  38. else
  39. setPlayerStorageValue(cid, CaughtWindow.storage_catched, pokename)
  40. end
  41. setPlayerStorageValue(cid, poketab.storage_balls, -1)
  42. return doPlayerSendCancel(cid, send)
  43. end
  44. end
  45.  
  46. table.string = function(tab)
  47. local tableStr = "{"
  48. for i, info in pairs(tab) do
  49. local index = "[".. i .. "]"
  50. if (type(i) == "string") then
  51. index = '["'.. i ..'"]'
  52. end
  53. if (type(info) == "table") then
  54. value = table.string(info)
  55. elseif (type(info) == "string") then
  56. value = '"'.. info .. '"'
  57. else
  58. value = info
  59. end
  60. tableStr = tableStr .. index .. " = " .. value .. ", "
  61. end
  62. tableStr = "{" .. tableStr:sub(2, #tableStr)
  63. return (#tableStr < 3) and "{}" or (tableStr:sub(1, #tableStr - 2) .. "}")
  64. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement