Advertisement
Guest User

CatchWindow_lib.lua

a guest
Oct 23rd, 2014
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. CW_Pokes = {
  2. ["bulbasaur"] = {DB_Balls = 10001, DB_PK = 20001, DE_Portrait = 7593, P_Experience = 5000},
  3. ["ivysaur"] = {DB_Balls = 10002, DB_PK = 20002, DE_Portrait = 7594, P_Experience = 10000},
  4. ["venusaur"] = {DB_Balls = 10003, DB_PK = 20003, DE_Portrait = 7595, P_Experience = 15000},
  5. }
  6.  
  7. CW_Balls = {
  8. ["normal"] = "pb",
  9. ["great"] = "gb",
  10. ["super"] = "sb",
  11. ["ultra"] = "ub",
  12. }
  13.  
  14. -------- Functions ----------
  15.  
  16. function CW_Setup(cid, pokeName)
  17. local name = nil
  18. if tostring(pokeName) then
  19.  
  20. name = pokeName:lower()
  21. else
  22.  
  23. name = getCreatureName(pokeName):lower()
  24. end
  25.  
  26. local pk = CW_Pokes[name]
  27.  
  28. if pk then
  29. if getPlayerStorageValue(cid, pk.DB_Balls) <= 0 then
  30.  
  31. setPlayerStorageValue(cid, pk.DB_Balls, "pb=0,gb=0,sb=0,ub=0,")
  32. end
  33. end
  34. return true
  35. end
  36.  
  37. function CW_Count(cid, pokeName, ball)
  38. local name = nil
  39. if tostring(pokeName) then
  40.  
  41. name = pokeName:lower()
  42. else
  43.  
  44. name = getCreatureName(pokeName):lower()
  45. end
  46.  
  47. local txt = getPlayerStorageValue(cid, CW_Pokes[name].DB_Balls)
  48. local change = txt:match(CW_Balls[ball].."=(.-),")
  49. local num = tonumber(change)
  50.  
  51. local ret = string.gsub(txt, CW_Balls[ball].."="..num, CW_Balls[ball].."="..num+1)
  52. return setPlayerStorageValue(cid, CW_Pokes[name].DB_Balls, ret) and true
  53. end
  54.  
  55. function CW_Caught(cid, pokeName)
  56. local name = nil
  57. if tostring(pokeName) then
  58.  
  59. name = pokeName:lower()
  60. else
  61.  
  62. name = getCreatureName(pokeName):lower()
  63. end
  64.  
  65. local pk = CW_Pokes[name]
  66.  
  67. if pk then
  68. if getPlayerStorageValue(cid, pk.DB_PK) <= 0 then
  69.  
  70. doPlayerSendCancel(cid, "%#CatchWindow@"..pk.DE_Portrait.."@"..pokeName.."@"..pk.P_Experience.."@"..getPlayerStorageValue(cid, pk.DB_Balls))
  71. setPlayerStorageValue(cid, pk.DB_Balls, "pb=0,gb=0,sb=0,ub=0,")
  72. doPlayerAddExp(cid, pk.P_Experience)
  73. setPlayerStorageValue(cid, pk.DB_PK, 1)
  74. end
  75. end
  76. return true
  77. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement