Postado Março 23, 2016 9 anos Estou com esses dois scripts que não estou conseguindo ajeitar. Segue eles: O problema desse é que não remove de jeito nenhum o item quando ele é usado: Mostrar conteúdo oculto function onUse(cid, item, fromPosition, itemEx, toPosition) local rewarditems = { {id = 2492, chance = 5, count = 1}, -- start with the lowest chances {id = 2498, chance = 10, count = 1}, {id = 2488, chance = 15, count = 1}, {id = 2152, chance = 70, count = math.random(1, 10)} } local chance = math.random(1,100) for i = 1, #rewarditems, 1 do if(chance < rewarditems.chance) then local info = getItemInfo(rewarditems.id) if(rewarditems.count > 1) then text = rewarditems.count .. " " .. info.plural else text = info.article .. " " .. info.name end local item = doCreateItemEx(rewarditems.id, rewarditems.count) if(doPlayerAddItemEx(cid, item, false) ~= RETURNVALUE_NOERROR) then doSendMagicEffect(getThingPos(cid), CONST_ME_POFF) text = "You have failed to open your mystery box. The item is to heavy or you have not enough space to take it." else text = "You have received " .. text .. "." doRemoveItem(item.uid, 1) end doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, text) return true else chance = chance - rewarditems.chance end end end Esse eu não estou conseguindo por uma chance individual para cada item e nem estou conseguindo por um math.randon pra vir uma quantidade aleatória dos itens. Mostrar conteúdo oculto local stonesMinerar = { [5709] = {minerioid = 5944, count = math.random(1, 10)}, -- [id da pedra] = {minerioid = id do item que ganha, count = countidade que ganha} [5624] = {minerioid = 6277, count = math.random(1, 5)}, [8748] = {minerioid = 5880, count = math.random(1, 5)}, [5619] = {minerioid = 12700, count = math.random(1, 3)} } local config = { exhaustionMinutes = 60, -- exausted em minutos effectChar = 30, -- efeito no char. storageUse = 34542 -- storage usado/ não mude caso não entenda. } local chance = 50 function onUse(cid, item, fromPosition, itemEx, toPosition) local a = math.random if(exhaustion.check(cid, config.storageUse) == TRUE) then if (exhaustion.get(cid, config.storageUse) >= 60) then doPlayerSendCancel(cid, "Voçê só pode usar após [" .. math.floor(exhaustion.get(cid, config.storageUse) / 60 + 1) .."] minutos.") end if (exhaustion.get(cid, config.storageUse) <= 60) then doPlayerSendCancel(cid, "Voçê só pode usar após [" .. exhaustion.get(cid, config.storageUse).."] segundos.") end return true end if stonesMinerar[itemEx.itemid] then local a = math.random(1, 100) if a < chance then doPlayerAddItem(cid, stonesMinerar[itemEx.itemid].minerioid, stonesMinerar[itemEx.itemid].count) doPlayerSendTextMessage(cid, 19, "Você recebeu "..(stonesMinerar[itemEx.itemid].count).." "..getItemNameById(stonesMinerar[itemEx.itemid].minerioid).."!") doSendMagicEffect(getPlayerPosition(cid), config.effectChar) exhaustion.set(cid, config.storageUse, config.exhaustionMinutes*60) else doPlayerSendCancel(cid, "Você falhou.") end else doPlayerSendCancel(cid, "Você não pode minerar isso.") end return true end Se alguém puder ajudar, agradeço desde já. EDIT: Não estou conseguindo tirar o segundo script do primeiro spoiler. Editado Março 23, 2016 9 anos por gabriel28 (veja o histórico de edições)
Postado Março 23, 2016 9 anos O erro está aqui: doRemoveItem(item.uid, 1) Tente substituir por este: doRemoveItem(item.itemid, 1) Se tu for um gordo preguiçoso copia e cola tudo dentro: function onUse(cid, item, fromPosition, itemEx, toPosition) local rewarditems = { {id = 2492, chance = 5, count = 1}, -- start with the lowest chances {id = 2498, chance = 10, count = 1}, {id = 2488, chance = 15, count = 1}, {id = 2152, chance = 70, count = math.random(1, 10)} } local chance = math.random(1,100) for i = 1, #rewarditems, 1 do if(chance < rewarditems[i].chance) then local info = getItemInfo(rewarditems[i].id) if(rewarditems[i].count > 1) then text = rewarditems[i].count .. " " .. info.plural else text = info.article .. " " .. info.name end local item = doCreateItemEx(rewarditems[i].id, rewarditems[i].count) if(doPlayerAddItemEx(cid, item, false) ~= RETURNVALUE_NOERROR) then doSendMagicEffect(getThingPos(cid), CONST_ME_POFF) text = "You have failed to open your mystery box. The item is too heavy or you have not enough space to take it." else text = "You have received " .. text .. "." doRemoveItem(item.itemid, 1) end doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, text) return true else chance = chance - rewarditems[i].chance end end end Hasuhasuhasuha ╔══════════════════════════ҳ̸Ҳ̸ҳஜ۩۞۩ஜҳ̸Ҳ̸ҳ══════════════════════════╗ Te Ajudei? Rep + e ficamos Quits Precisando de ajuda? Discord: Yan Liima #3702 Programador Júnior de LUA, PHP e JavaScript Juntos somos lendas, separados somos Mitos! ╚══════════════════════════ҳ̸Ҳ̸ҳஜ۩۞۩ஜҳ̸Ҳ̸ҳ═════════════════════════════╝
Postado Março 24, 2016 9 anos Autor Em 23/03/2016 em 23:27, Yan Liima disse: O erro está aqui: kkkkkkk Não sou. Você tem solução pro segundo script? Ele ta dentro do spoiler, não consegui separar os dois.
Postado Março 24, 2016 9 anos Não querendo contrariá a menina que postou acima mas, se você quer remover o item que foi clicado nele, você tem que mudar essa parte do código: Citar local item = doCreateItemEx(rewarditems.id, rewarditems.count) if(doPlayerAddItemEx(cid, item, false) ~= RETURNVALUE_NOERROR) then Por essa: Citar local itemc = doCreateItemEx(rewarditems.id, rewarditems.count) if(doPlayerAddItemEx(cid, itemc, false) ~= RETURNVALUE_NOERROR) then Assim a função: Citar doRemoveItem(item.uid, 1) Vai usar a variável do item que foi clicado nele. No segundo caso, vai ser preciso fazer algumas alterações, muda essas sentenças: Citar count = math.random(1, 5) Por isso: Citar count = 5 --aqui fica o valor maximo de items Adiciona em todas as tabelas essa nova variável: Citar chance = 50 --chance maxima do item Modifique essa variável e ponha ela abaixo da função onUse (): Citar local chance = 50 Por essa: Citar local chance = stonesMinerar[itemEx.itemid].chance Modifique essa função: Citar doPlayerAddItem(cid, stonesMinerar[itemEx.itemid].minerioid, stonesMinerar[itemEx.itemid].count) Por essa: Citar doPlayerAddItem(cid, stonesMinerar[itemEx.itemid].minerioid, math.random (1,stonesMinerar[itemEx.itemid].count)) Existe um pequeno erro que deixei/criei de propósito que não compromete o sistema mas, não fica bom tê-lo, espero que você consiga resolver esse pequeno errinho. Acho que não esqueci de nada qualquer coisa me comunica. Boa sorte.
Postado Março 27, 2016 9 anos Autor Em 24/03/2016 em 12:16, dominus disse: N A segunda eu consegui arrumar, mas a primeira agora ta dando o seguinte erro: <luaDoPlayerAddItemEx> item not found
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.