Postado Março 29, 2017 8 anos Solução --nothing -------------- editei uma parte local t = { [{100,105}] = {{5,"Water Elemental",400}}, -- chance, name, min level [{106,110}] = {{5,"Massive Water Elemental",400}, {10,"Water Elemental",500}}, [{111,119}] = {{5,"Blood Crab",500},{10,"Massive Water Elemental",520},{15,"Water Elemental",540}}, [{120,129}] = {{5,"Quara Constrictor",550},{10,"Blood Crab",555},{15,"Massive Water Elemental",560},{20,"Water Elemental",580}}, [{130,math.huge}] = {{5,"Quara Predator Scout",600},{10,"Quara Constrictor",650},{15,"Blood Crab",700}, {20,"Massive Water Elemental",700},{25,"Water Elemental",700}} } local lvl, fish_level = 400, 100 local useWorms = true local waterIds = {493, 4608, 4609, 4610, 4611, 4612, 4613, 4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625} function onUse(cid, item, fromPosition, itemEx, toPosition) if isInArray(waterIds, itemEx.itemid) == TRUE then if itemEx.itemid ~= 493 then if getPlayerLevel(cid) >= lvl and getPlayerSkill(cid, SKILL_FISHING) >= fish_level then for v , r in pairs(t) do if getPlayerSkill(cid, SKILL_FISHING) >= v[1] and getPlayerSkill(cid, SKILL_FISHING) <= v[2] then for _ , var in pairs(r) do if getPlayerLevel(cid) >= var[3] and var[1] > math.random(1, 100) then doCreateMonster(var[2], getPlayerPosition(cid)) return true end end end end end if math.random(1, (100 + (getPlayerSkill(cid, SKILL_FISHING) / 10))) <= getPlayerSkill(cid, SKILL_FISHING) then if useWorms then if getPlayerItemCount(cid, ITEM_WORM) > 0 then doPlayerRemoveItem(cid, ITEM_WORM, 1) doPlayerAddItem(cid, ITEM_FISH, 1) end else doPlayerAddItem(cid, ITEM_FISH, 1) end end doPlayerAddSkillTry(cid, SKILL_FISHING, 1) end doSendMagicEffect(toPosition, CONST_ME_LOSEENERGY) return true end return false end
Postado Março 29, 2017 8 anos Autor Deu certo cara muito obrigado Deus te pague muito obrigado mesmo mais uma duvida quanto maio a chance mais dificil de pega? o
Postado Março 29, 2017 8 anos 5 = 5% chance de pegar quanto maior ali, maior vai ser a chance de pegar se for 50, vai ser 50% de chance de pegar!
Postado Março 29, 2017 8 anos Autor to testando aqui ver se pega os outro bichos pq ta pegando so wanter elemental e massive water elemental. Deu certo aqui vlw msm muito obrigado Editado Março 29, 2017 8 anos por Thenebrozo (veja o histórico de edições)
Postado Março 29, 2017 8 anos não é por nada não mas achei que a pessoa que fosse te ajudar seguiria meu modelo de algoritmo. Já que o vod praticamente ignorou meu código eu decidi fazer um script de pesca com base no que eu já havia feito; Spoiler -- tabela de nivel -- [nivel] = {level, fishing} local tablelevel = { [1] = {400, 100}, [2] = {500, 105}, [3] = {600, 110}, [4] = {700, 120}, [5] = {800, 130} } -- tabela de monstros -- [nivel] = monstro adicionado -- note que se voce for nivel 3 vc tera os monstros do 2 e do 1 tambem. local tablemonsters = { [1] = "Water Elemental", [2] = "Massive Water Elemental", [3] = "Blood Crab", [4] = "Quara Constrictor", [5] = "Quara Predator Scout" } local useWorms = true local waterIds = {493, 4608, 4609, 4610, 4611, 4612, 4613, 4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625} function onUse(cid, item, fromPosition, itemEx, toPosition) if getTilePzInfo(getCreaturePosition(cid)) then doPlayerSendCancel(cid, "You can't fish in a protection zone!") return true end if isInArray(waterIds, itemEx.itemid) then if useWorms then if getPlayerItemCount(cid, ITEM_WORM) > 0 then doPlayerRemoveItem(cid, ITEM_WORM, 1) else doPlayerSendCancel(cid, "You don't have any worm to fish.") return true end end doPlayerAddSkillTry(cid, SKILL_FISHING, 1) local plvl, fishing = getPlayerLevel(cid), getPlayerSkill(cid, SKILL_FISHING) -- aqui fazemos o algoritmo para definir qual o level de pesca o player sera local level = 0 for i, lvl in ipairs(tablelevel) do if plvl >= lvl[1] and fishing >= lvl[2] then level = i else break end end -- a partir daqui o level do player pode ser pego atraves da variavel "level" -- aqui nos retornamos a tabela de monstros pescaveis pelo player local fishable = {} -- partimos de uma tabela vazia for i, mob in ipairs(tablemonsters) do if level >= i then fishable[#fishable + 1] = {chance = 5 * (level - i + 1), monster = mob} else break end end -- pra cada monstro temos uma chance associada que vai variar do nivel do player e da dificuldade do monstro -- retornando oque vai pescar local get = false -- nao vai pescar nada de inicio for i = 1, #fishable do if fishable[i].chance >= math.random(1, 100) then get = fishable[i].monster break end end if not get then -- se nao pescou nada, da peixe doPlayerAddItem(cid, ITEM_FISH, 1) else -- se pescou algo, falar oque pescou/criar a criatura doCreateMonster(get, fromPosition) end doSendMagicEffect(toPosition, CONST_ME_LOSEENERGY) return true end return false end não tem melhor ou pior, ambos devem funcionar e se vc já tá usando o dele, continue usando. O meu só tá nos moldes da minha linha de raciocínio anterior. Editado Março 29, 2017 8 anos por xWhiteWolf (veja o histórico de edições)
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.