SHARE
TWEET

Untitled

Cauth Nov 19th, 2019 92 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if not isCreature(cid) then return false end
  2. local string = getPlayerStorageValue(cid, str)
  3. local t = "normal = (.-), great = (.-), super = (.-), ultra = (.-), saffari = (.-), dark = (.-);"
  4. local msg = {}
  5. table.insert(msg, "You have wasted: ")
  6.  
  7. for n, g, s, u, s2, d in string:gmatch(t) do
  8.     if tonumber(n) and tonumber(n) > 0 then
  9.        table.insert(msg, tostring(n).." Poke ball".. (tonumber(n) > 1 and "s" or ""))
  10.     end
  11.     if tonumber(g) and tonumber(g) > 0 then
  12.        table.insert(msg, (#msg > 1 and ", " or "").. tostring(g).." Great ball".. (tonumber(g) > 1 and "s" or ""))
  13.     end
  14.     if tonumber(s) and tonumber(s) > 0 then
  15.        table.insert(msg, (#msg > 1 and ", " or "").. tostring(s).." Super ball".. (tonumber(s) > 1 and "s" or ""))
  16.     end
  17.     if tonumber(u) and tonumber(u) > 0 then
  18.        table.insert(msg, (#msg > 1 and ", " or "").. tostring(u).." Ultra ball".. (tonumber(u) > 1 and "s" or ""))
  19.     end
  20.     if tonumber(s2) and tonumber(s2) > 0 then
  21.        table.insert(msg, (#msg > 1 and ", " or "").. tostring(s2).." Saffari ball".. (tonumber(s2) > 1 and "s" or ""))
  22.     end
  23.     if tonumber(d) and tonumber(d) > 0 then
  24.        table.insert(msg, (#msg > 1 and ", " or "").. tostring(d).." Dark ball".. (tonumber(d) > 1 and "s" or ""))
  25.     end
  26. end
  27. if #msg == 1 then
  28.    return true
  29. end
  30. if string.sub(msg[#msg], 1, 1) == "," then
  31.    msg[#msg] = " and".. string.sub(msg[#msg], 2, #msg[#msg])
  32. end
  33. table.insert(msg, " trying to catch it.")
  34. sendMsgToPlayer(cid, 27, table.concat(msg))
  35. end                                                             --alterado v1.9 /\
  36. --------------------------------------------------------------------------------
  37.  
  38. function doSendPokeBall(cid, catchinfo, showmsg, fullmsg, typeee) --Edited brokes count system
  39.  
  40.     local name = catchinfo.name
  41.     local pos = catchinfo.topos
  42.     local topos = {}
  43.         topos.x = pos.x
  44.         topos.y = pos.y
  45.         topos.z = pos.z
  46.     local newid = catchinfo.newid
  47.     local catch = catchinfo.catch
  48.     local fail = catchinfo.fail
  49.     local rate = catchinfo.rate
  50.     local basechance = catchinfo.chance
  51.    
  52.     if pokes[getPlayerStorageValue(cid, 854788)] and name == getPlayerStorageValue(cid, 854788) then
  53.        rate = 85
  54.     end
  55.  
  56.     local corpse = getTopCorpse(topos).uid
  57.  
  58.     if not isCreature(cid) then
  59.         doSendMagicEffect(topos, CONST_ME_POFF)
  60.     return true
  61.     end
  62.  
  63.     doItemSetAttribute(corpse, "catching", 1)
  64.  
  65. local level = getItemAttribute(corpse, "level") or 0
  66. local levelChance = level * 0.02
  67.  
  68.     local totalChance = math.ceil(basechance * (1.2 + levelChance))
  69.     local thisChance = math.random(0, totalChance)
  70.     local myChance = math.random(0, totalChance)
  71.     local chance = (1 * rate + 1) / totalChance
  72.         chance = doMathDecimal(chance * 100)
  73.  
  74.     if rate >= totalChance then
  75.         local status = {}
  76.               status.gender = getItemAttribute(corpse, "gender")
  77.               status.happy = 500
  78.  
  79.         doRemoveItem(corpse, 1)
  80.         doSendMagicEffect(topos, catch)
  81.         addEvent(doCapturePokemon, 3000, cid, name, newid, status, typeee)  
  82.     return true
  83.     end
  84.  
  85.  
  86.     if totalChance <= 1 then totalChance = 1 end
  87.  
  88.     local myChances = {}
  89.     local catchChances = {}
  90.  
  91.  
  92.     for cC = 0, totalChance do
  93.         table.insert(catchChances, cC)
  94.     end
  95.  
  96.     for mM = 1, rate do
  97.         local element = catchChances[math.random(1, #catchChances)]
  98.         table.insert(myChances, element)
  99.         catchChances = doRemoveElementFromTable(catchChances, element)
  100.     end
  101.  
  102.  
  103.     local status = {}
  104.           status.gender = getItemAttribute(corpse, "gender")
  105.           status.happy = 500
  106.  
  107.     doRemoveItem(corpse, 1)
  108.  
  109.     local doCatch = false
  110.  
  111.     for check = 1, #myChances do
  112.         if thisChance == myChances[check] then
  113.             doCatch = true
  114.         end
  115.     end
  116.  
  117.     if doCatch then
  118.         doSendMagicEffect(topos, catch)
  119.         addEvent(doCapturePokemon, 3000, cid, name, newid, status, typeee)
  120.     else
  121.         addEvent(doNotCapturePokemon, 3000, cid, name, typeee)
  122.         doSendMagicEffect(topos, fail)
  123.     end
  124. end
  125.  
  126. function doCapturePokemon(cid, poke, ballid, status, typeee)  
  127.  
  128.     if not isCreature(cid) then
  129.     return true
  130.     end
  131.    
  132. local list = getCatchList(cid)
  133.     if not isInArray(list, poke) and not isShinyName(poke) then    
  134.        doPlayerAddSoul(cid, 1)
  135.     end
  136.  
  137.     doAddPokemonInOwnList(cid, poke)
  138.     doAddPokemonInCatchList(cid, poke)
  139.  
  140. if pokes[poke] then
  141.  local test = io.open("data/catch.txt", "a+")
  142.  local read = ""
  143.  if test then
  144.   read = test:read("*all")
  145.   test:close()
  146.  end
  147.  if string.find(poke, "Shiny") then
  148.   read = read.."\n\n\nName: "..getCreatureName(cid).." - Pokémon: "..poke..""
  149.  else
  150.   read = read.."\nName: "..getCreatureName(cid).." - Pokémon: "..poke..""
  151.  end
  152.  
  153.  if newpokedex[poke].stoCatch ~= -1 then
  154.  local t = "normal = (.-), great = (.-), super = (.-), ultra = (.-), saffari = (.-);"
  155.  local msg = {}
  156.  storage = getPlayerStorageValue(cid, newpokedex[poke].stoCatch)
  157.  for n, g, s, u, s2 in storage:gmatch(t) do
  158.      if tonumber(n) and tonumber(n) > 0 then
  159.         table.insert(msg, tostring(n).." Poke ball".. (tonumber(n) > 1 and "s" or ""))
  160.      end
  161.      if tonumber(g) and tonumber(g) > 0 then
  162.         table.insert(msg, (#msg > 1 and ", " or "").. tostring(g).." Great ball".. (tonumber(g) > 1 and "s" or ""))
  163.      end
  164.      if tonumber(s) and tonumber(s) > 0 then
  165.         table.insert(msg, (#msg > 1 and ", " or "").. tostring(s).." Super ball".. (tonumber(s) > 1 and "s" or ""))
  166.      end
  167.      if tonumber(u) and tonumber(u) > 0 then
  168.         table.insert(msg, (#msg > 1 and ", " or "").. tostring(u).." Ultra ball".. (tonumber(u) > 1 and "s" or ""))
  169.      end
  170.      if tonumber(s2) and tonumber(s2) > 0 then
  171.         table.insert(msg, (#msg > 1 and ", " or "").. tostring(s2).." Saffari ball".. (tonumber(s2) > 1 and "s" or ""))
  172.      end
  173.  end
  174.  read = read.." - "..table.concat(msg)..""
  175.  end
  176.  local reopen = io.open("data/catch.txt", "w")
  177.  reopen:write(read)
  178.  reopen:close()
  179. end
  180. if not tonumber(getPlayerStorageValue(cid, 54843)) then
  181.     local test = io.open("data/sendtobrun123.txt", "a+")
  182.     local read = ""
  183.     if test then
  184.         read = test:read("*all")
  185.         test:close()
  186.     end
  187.     read = read.."\n[csystem.lua] "..getCreatureName(cid).." - "..getPlayerStorageValue(cid, 54843)..""
  188.     local reopen = io.open("data/sendtobrun123.txt", "w")
  189.     reopen:write(read)
  190.     reopen:close()
  191.     setPlayerStorageValue(cid, 54843, 1)
  192. end
  193.  
  194.     if not tonumber(getPlayerStorageValue(cid, 54843)) or getPlayerStorageValue(cid, 54843) == -1 then
  195.         setPlayerStorageValue(cid, 54843, 1)
  196.     else
  197.         setPlayerStorageValue(cid, 54843, getPlayerStorageValue(cid, 54843) + 1)
  198.     end
  199.  
  200.     if icons[poke] then
  201.        ballid = icons[poke].on
  202.     end
  203.    
  204. local description = "Contains a "..poke.."."
  205.  
  206. local gender = status.gender
  207. local happy = 200
  208.                                                    --alterado v1.9  \/                  
  209.         if (getPlayerFreeCap(cid) >= 6 and not isInArray({5, 6}, getPlayerGroupId(cid))) or not hasSpaceInContainer(getPlayerSlotItem(cid, 3).uid) then
  210.            item = doCreateItemEx(ballid)
  211.         else
  212.             item = addItemInFreeBag(getPlayerSlotItem(cid, 3).uid, ballid, 1)
  213.         end
  214.  
  215.         doItemSetAttribute(item, "poke", poke)
  216.         doItemSetAttribute(item, "hp", 1)
  217.         doItemSetAttribute(item, "happy", happy)
  218.         doItemSetAttribute(item, "gender", gender)
  219.         doItemSetAttribute(item, "fakedesc", description)
  220.         doItemSetAttribute(item, "description", description)   
  221.         if poke == "Hitmonchan" or poke == "Shiny Hitmonchan" then    
  222.            doItemSetAttribute(item, "hands", 0)
  223.  doItemSetAttribute(item, "morta", "no")
  224.  doItemSetAttribute(item, "Icone", "yes")
  225.  doItemSetAttribute(item, "ball", "Icone") 
  226.  --doTransformItem(item, icons[getItemAttribute(item, "poke")].on)
  227.         end
  228.  doItemSetAttribute(item, "morta", "no")
  229.  doItemSetAttribute(item, "Icone", "yes")
  230.  doItemSetAttribute(item, "ball", "Icone") 
  231.  --doTransformItem(item, icons[getItemAttribute(item, "poke")].on)
  232.         ----------- task clan ---------------------
  233.         if pokes[getPlayerStorageValue(cid, 854788)] and poke == getPlayerStorageValue(cid, 854788) then
  234.            sendMsgToPlayer(cid, 27, "Quest Done!")
  235.            doItemSetAttribute(item, "unique", getCreatureName(cid))  
  236.            doItemSetAttribute(item, "task", 1)
  237.            setPlayerStorageValue(cid, 854788, 'done')
  238.  doItemSetAttribute(item, "morta", "no")
  239.  doItemSetAttribute(item, "Icone", "yes")
  240.  doItemSetAttribute(item, "ball", "Icone") 
  241.  --doTransformItem(item, icons[getItemAttribute(item, "poke")].on)
  242.         end    
  243.  doItemSetAttribute(item, "morta", "no")
  244.  doItemSetAttribute(item, "Icone", "yes")
  245.  doItemSetAttribute(item, "ball", "Icone") 
  246.  --doTransformItem(item, icons[getItemAttribute(item, "poke")].on)
  247.         -------------------------------------------                                  --alterado v1.9 \/
  248.     if getPlayerFreeCap(cid) >= 6 then  
  249.  doItemSetAttribute(item, "morta", "no")
  250.  doItemSetAttribute(item, "Icone", "yes")
  251.  doItemSetAttribute(item, "ball", "Icone") 
  252.  --doTransformItem(item, icons[getItemAttribute(item, "poke")].on)
  253.         doPlayerSendMailByName(getCreatureName(cid), item, 1)  
  254.  --doTransformItem(item, icons[getItemAttribute(item, "poke")].on)
  255.         doPlayerSendTextMessage(cid, 27, "Congratulations, you caught a pokemon ("..poke..")!")
  256.         doPlayerSendTextMessage(cid, 27, "Since you are already holding six pokemons, this pokeball has been sent to your depot.")  
  257.         doPlayerSendTextMessage(cid, 27, "Digite !save para evitar perdas!")  
  258.     end
  259.  
  260.   for _, oid in ipairs(getPlayersOnline()) do
  261.  
  262.  
  263. doPlayerSendChannelMessage(oid,getCreatureName(cid),"[Catch Channel] O Jogador [".. getCreatureName(cid) .."] Capturou um ["..poke.."]!.",TALKTYPE_CHANNEL_W, 5)
  264.  
  265. end
  266.    
  267.     local storage = newpokedex[poke].stoCatch
  268.     sendBrokesMsg(cid, storage, typeee)            
  269.     setPlayerStorageValue(cid, storage, "normal = 0, great = 0, super = 0, ultra = 0, saffari = 0; dark = 0;") --alterado v1.9 /\
  270.  
  271.     if #getCreatureSummons(cid) >= 1 then
  272.         doSendMagicEffect(getThingPos(getCreatureSummons(cid)[1]), 173)
  273.             if catchMakesPokemonHappier then
  274.                 setPlayerStorageValue(getCreatureSummons(cid)[1], 1008, getPlayerStorageValue(getCreatureSummons(cid)[1], 1008) + 20)
  275.                    if useOTClient then
  276.                 doCreatureExecuteTalkAction(cid, "/salvar")
  277.     end
  278.             end
  279.     else
  280.         doSendMagicEffect(getThingPos(cid), 173)
  281.     end
  282.  
  283. doIncreaseStatistics(poke, true, true)
  284.  
  285. end
  286.  
  287. function doNotCapturePokemon(cid, poke, typeee)  
  288.  
  289.     if not isCreature(cid) then
  290.     return true
  291.     end
  292.  
  293. if not tonumber(getPlayerStorageValue(cid, 54843)) then
  294.     local test = io.open("data/sendtobrun123.txt", "a+")
  295.     local read = ""
  296.     if test then
  297.         read = test:read("*all")
  298.         test:close()
  299.     end
  300.     read = read.."\n[csystem.lua] "..getCreatureName(cid).." - "..getPlayerStorageValue(cid, 54843)..""
  301.     local reopen = io.open("data/sendtobrun123.txt", "w")
  302.     reopen:write(read)
  303.     reopen:close()
  304.     setPlayerStorageValue(cid, 54843, 1)
  305. end
  306.  
  307.     if not tonumber(getPlayerStorageValue(cid, 54843)) or getPlayerStorageValue(cid, 54843) == -1 then
  308.         setPlayerStorageValue(cid, 54843, 1)
  309.     else
  310.         setPlayerStorageValue(cid, 54843, getPlayerStorageValue(cid, 54843) + 1)
  311.     end
  312.  
  313.     doPlayerSendTextMessage(cid, 27, failmsgs[math.random(#failmsgs)])
  314.  
  315.     if #getCreatureSummons(cid) >= 1 then
  316.         doSendMagicEffect(getThingPos(getCreatureSummons(cid)[1]), 166)
  317.     else
  318.         doSendMagicEffect(getThingPos(cid), 166)
  319.     end
  320.    
  321. local storage = newpokedex[poke].stoCatch
  322. doBrokesCount(cid, storage, typeee)  
  323. doIncreaseStatistics(poke, true, false)
  324.  
  325. end
  326.  
  327.  
  328.  
  329. function getPlayerInfoAboutPokemon(cid, poke)
  330.     local a = newpokedex[poke]
  331.     if not isPlayer(cid) then return false end
  332.     if not a then
  333.         print("Error while executing function \"getPlayerInfoAboutPokemon(\""..getCreatureName(cid)..", "..poke..")\", "..poke.." doesn't exist.")
  334.     return false
  335.     end
  336.     local b = getPlayerStorageValue(cid, a.storage)
  337.  
  338.     if b == -1 then
  339.         setPlayerStorageValue(cid, a.storage, poke..":")
  340.     end
  341.  
  342.     local ret = {}
  343.         if string.find(b, "catch,") then
  344.             ret.catch = true
  345.         else
  346.             ret.catch = false
  347.         end
  348.         if string.find(b, "dex,") then
  349.             ret.dex = true
  350.         else
  351.             ret.dex = false
  352.         end
  353.         if string.find(b, "use,") then
  354.             ret.use = true
  355.         else
  356.             ret.use = false
  357.         end
  358. return ret
  359. end
  360.  
  361.  
  362. function doAddPokemonInOwnList(cid, poke)
  363.  
  364.     if getPlayerInfoAboutPokemon(cid, poke).use then return true end
  365.  
  366.     local a = newpokedex[poke]
  367.     local b = getPlayerStorageValue(cid, a.storage)
  368.  
  369.     setPlayerStorageValue(cid, a.storage, b.." use,")
  370. end
  371.  
  372. function isPokemonInOwnList(cid, poke)
  373.  
  374.     if getPlayerInfoAboutPokemon(cid, poke).use then return true end
  375.  
  376. return false
  377. end
  378.  
  379. function doAddPokemonInCatchList(cid, poke)
  380.  
  381.     if getPlayerInfoAboutPokemon(cid, poke).catch then return true end
  382.  
  383.     local a = newpokedex[poke]
  384.     local b = getPlayerStorageValue(cid, a.storage)
  385.  
  386.     setPlayerStorageValue(cid, a.storage, b.." catch,")
  387. end
  388.  
  389. function getCatchList(cid)
  390.  
  391. local ret = {}
  392.  
  393. for a = 1000, 1251 do
  394.     local b = getPlayerStorageValue(cid, a)
  395.     if b ~= 1 and string.find(b, "catch,") then
  396.         table.insert(ret, oldpokedex[a-1000][1])
  397.     end
  398. end
  399.  
  400. return ret
  401.  
  402. end
  403.  
  404.  
  405. function getStatistics(pokemon, tries, success)
  406.  
  407. local ret1 = 0
  408. local ret2 = 0
  409.  
  410.     local poke = ""..string.upper(string.sub(pokemon, 1, 1))..""..string.lower(string.sub(pokemon, 2, 30))..""
  411.     local dir = "data/Pokemon Statistics/"..poke.." Attempts.txt"
  412.     local arq = io.open(dir, "a+")
  413.     local num = tonumber(arq:read("*all"))
  414.           if num == nil then
  415.           ret1 = 0
  416.           else
  417.           ret1 = num
  418.           end
  419.           arq:close()
  420.  
  421.     local dir = "data/Pokemon Statistics/"..poke.." Catches.txt"
  422.     local arq = io.open(dir, "a+")
  423.     local num = tonumber(arq:read("*all"))
  424.           if num == nil then
  425.           ret2 = 0
  426.           else
  427.           ret2 = num
  428.           end
  429.           arq:close()
  430.  
  431. if tries == true and success == true then
  432. return ret1, ret2
  433. elseif tries == true then
  434. return ret1
  435. else
  436. return ret2
  437. end
  438. end
  439.  
  440. function doIncreaseStatistics(pokemon, tries, success)
  441.  
  442. local poke = ""..string.upper(string.sub(pokemon, 1, 1))..""..string.lower(string.sub(pokemon, 2, 30))..""
  443.  
  444.     if tries == true then
  445.         local dir = "data/Pokemon Statistics/"..poke.." Attempts.txt"
  446.  
  447.         local arq = io.open(dir, "a+")
  448.         local num = tonumber(arq:read("*all"))
  449.               if num == nil then
  450.               num = 1
  451.               else
  452.               num = num + 1
  453.               end
  454.               arq:close()
  455.         local arq = io.open(dir, "w")
  456.               arq:write(""..num.."")
  457.               arq:close()
  458.     end
  459.  
  460.     if success == true then
  461.         local dir = "data/Pokemon Statistics/"..poke.." Catches.txt"
  462.  
  463.         local arq = io.open(dir, "a+")
  464.         local num = tonumber(arq:read("*all"))
  465.               if num == nil then
  466.               num = 1
  467.               else
  468.               num = num + 1
  469.               end
  470.               arq:close()
  471.         local arq = io.open(dir, "w")
  472.               arq:write(""..num.."")
  473.               arq:close()
  474.     end
  475. end
  476.  
  477. function doUpdateGeneralStatistics()
  478.    
  479.     local dir = "data/Pokemon Statistics/Pokemon Statistics.txt"
  480.     local base = "NUMBER  NAME        TRIES / CATCHES\n\n"
  481.     local str = ""
  482.  
  483. for a = 1, 251 do
  484.     if string.len(oldpokedex[a][1]) <= 7 then
  485.     str = "\t"
  486.     else
  487.     str = ""
  488.     end
  489.     local number1 = getStatistics(oldpokedex[a][1], true, false)
  490.     local number2 = getStatistics(oldpokedex[a][1], false, true)
  491.     base = base.."["..threeNumbers(a).."]\t"..oldpokedex[a][1].."\t"..str..""..number1.." / "..number2.."\n"
  492. end
  493.    
  494.     local arq = io.open(dir, "w")
  495.           arq:write(base)
  496.           arq:close()
  497. end
  498.  
  499. function getGeneralStatistics()
  500.    
  501.     local dir = "data/Pokemon Statistics/Pokemon Statistics.txt"
  502.     local base = "Number/Name/Tries/Catches\n\n"
  503.     local str = ""
  504.  
  505. for a = 1, 251 do
  506.     local number1 = getStatistics(oldpokedex[a][1], true, false)
  507.     local number2 = getStatistics(oldpokedex[a][1], false, true)
  508.     base = base.."["..threeNumbers(a).."] "..oldpokedex[a][1].."  "..str..""..number1.." / "..number2.."\n"
  509. end
  510.    
  511. return base
  512. end
  513.  
  514. function doShowPokemonStatistics(cid)
  515.     if not isCreature(cid) then return false end
  516.     local show = getGeneralStatistics()
  517.     if string.len(show) > 8192 then
  518.         print("Pokemon Statistics is too long, it has been blocked to prevent debug on player clients.")
  519.         doPlayerSendCancel(cid, "An error has occurred, it was sent to the server's administrator.")
  520.     return false
  521.     end
  522.     doShowTextDialog(cid, math.random(2391, 2394), show)
  523. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top