Postado Outubro 15, 2017 7 anos Abir a box, se receber o item id 2160 (configuravel para add novos itens) aparece um broadcast para todos do servidor: Ricardo acabou de receber "quantidade" "nome do item" da mystery box. Exemplo: doBroadcastMessage(""..getCreatureName(cid).." acabou de ganhar: "..i.quant.." item(s) "..getItemNameById(_).." na Mystery Box.") mysterybox.lua Mostrar conteúdo oculto local items = { {itemId = 2160, count = 1, chance = 50}, -- ITEM, QUANTIDADE, CHANCE {itemId = 2152, count = 1, chance = 50}, {itemId = 2148, count = 1, chance = 70}, } function onUse(cid, item, frompos, item2, topos) local config = { pos = getCreaturePosition(cid), -- posição do player exhaustionSeconds = 3600, -- exausted em segundos storageUse = 44231, -- storage usado. } if(exhaustion.check(cid, config.storageUse)) then if (exhaustion.get(cid, config.storageUse) >= 60) then doPlayerSendCancel(cid, "Voce so poderar abrir o bau novamente em " .. math.floor(exhaustion.get(cid, config.storageUse) / 60 + 1) .." minutos.") end if (exhaustion.get(cid, config.storageUse) <= 60) then doPlayerSendCancel(cid, "Voce precisa esperar " .. exhaustion.get(cid, config.storageUse).." segundos.") end return true end local totalChance, randomTable, randomNumber = 0, {}, 0 addEvent(doPlayerSendTextMessage, 1*1000, cid, 27, "Procurando algo...") addEvent(doPlayerSendTextMessage, 2*1000, cid, 27, "Procurando algo...") addEvent(doPlayerSendTextMessage, 3*1000, cid, 27, "Procurando algo...") addEvent(doPlayerSendTextMessage, 4*1000, cid, 27, "Procurando algo...") addEvent(doPlayerSendTextMessage, 5*1000, cid, 27, "Procurando algo...") addEvent(doSendAnimatedText, 1*1000, config.pos, "[5]", 180) addEvent(doSendAnimatedText, 2*1000, config.pos, "[4]", 180) addEvent(doSendAnimatedText, 3*1000, config.pos, "[3]", 180) addEvent(doSendAnimatedText, 4*1000, config.pos, "[2]", 180) addEvent(doSendAnimatedText, 5*1000, config.pos, "[1]", 180) addEvent(doSendAnimatedText, 6*1000, config.pos, "DONE!", 180) for _, itemInfo in pairs (items) do randomTable[itemInfo.itemId] = {min = totalChance + 1, max = itemInfo.chance, count = itemInfo.count or 1} totalChance = totalChance + itemInfo.chance end randomNumber = math.random(1, totalChance) for itemId, itemInfo in pairs (randomTable) do local min, max = itemInfo.min, itemInfo.min + itemInfo.max if randomNumber >= min and randomNumber <= max then local newItem = addEvent(doPlayerAddItem, 6*1000, cid, itemId, itemInfo.count, false) if not newItem then return doPlayerSendCancel(cid, "Voce nao tem espaco para receber o item!") end doRemoveItem(item.uid, 0) exhaustion.set(cid, config.storageUse, config.exhaustionSeconds) local iInfo = getItemInfo(itemId) addEvent(doPlayerSendTextMessage, 6*1000, cid, 27, "Voce achou ("..iInfo.name..")!") break end end return true end
Postado Outubro 15, 2017 7 anos mysterybox.lua: Mostrar conteúdo oculto local items = { {itemId = 2160, count = 1, chance = 50}, -- ITEM, QUANTIDADE, CHANCE {itemId = 2152, count = 1, chance = 50}, {itemId = 2148, count = 1, chance = 70}, } function onUse(cid, item, frompos, item2, topos) local config = { pos = getCreaturePosition(cid), -- posição do player exhaustionSeconds = 3600, -- exausted em segundos storageUse = 44231, -- storage usado. } if(exhaustion.check(cid, config.storageUse)) then if (exhaustion.get(cid, config.storageUse) >= 60) then doPlayerSendCancel(cid, "Voce so poderar abrir o bau novamente em " .. math.floor(exhaustion.get(cid, config.storageUse) / 60 + 1) .." minutos.") end if (exhaustion.get(cid, config.storageUse) <= 60) then doPlayerSendCancel(cid, "Voce precisa esperar " .. exhaustion.get(cid, config.storageUse).." segundos.") end return true end local totalChance, randomTable, randomNumber = 0, {}, 0 addEvent(doPlayerSendTextMessage, 1*1000, cid, 27, "Procurando algo...") addEvent(doPlayerSendTextMessage, 2*1000, cid, 27, "Procurando algo...") addEvent(doPlayerSendTextMessage, 3*1000, cid, 27, "Procurando algo...") addEvent(doPlayerSendTextMessage, 4*1000, cid, 27, "Procurando algo...") addEvent(doPlayerSendTextMessage, 5*1000, cid, 27, "Procurando algo...") addEvent(doSendAnimatedText, 1*1000, config.pos, "[5]", 180) addEvent(doSendAnimatedText, 2*1000, config.pos, "[4]", 180) addEvent(doSendAnimatedText, 3*1000, config.pos, "[3]", 180) addEvent(doSendAnimatedText, 4*1000, config.pos, "[2]", 180) addEvent(doSendAnimatedText, 5*1000, config.pos, "[1]", 180) addEvent(doSendAnimatedText, 6*1000, config.pos, "DONE!", 180) for _, itemInfo in pairs (items) do randomTable[itemInfo.itemId] = {min = totalChance + 1, max = itemInfo.chance, count = itemInfo.count or 1} totalChance = totalChance + itemInfo.chance end randomNumber = math.random(1, totalChance) for itemId, itemInfo in pairs (randomTable) do local min, max = itemInfo.min, itemInfo.min + itemInfo.max if randomNumber >= min and randomNumber <= max then local newItem = addEvent(doPlayerAddItem, 6*1000, cid, itemId, itemInfo.count, false) if not newItem then return doPlayerSendCancel(cid, "Voce nao tem espaco para receber o item!") end doRemoveItem(item.uid, 0) exhaustion.set(cid, config.storageUse, config.exhaustionSeconds) local iInfo = getItemInfo(itemId) if itemId == 2160 then addEvent(doBroadcastMessage, 6*1000, getCreatureName(cid) .. " recebeu NOMEDOITEM.") end addEvent(doPlayerSendTextMessage, 6*1000, cid, 27, "Voce achou ("..iInfo.name..")!") break end end return true end OBS: Não cheguei a testar!!
Postado Outubro 15, 2017 7 anos tu pode testar assim tb, n testei, aí é só por em broadcastitems os id q vai dar broadcast eu coloquei 2160, 2161 ali soh de exemplo, muda com os q vc qr e adiciona mais colocando virgula Mostrar conteúdo oculto local items = { {itemId = 2160, count = 1, chance = 50}, -- ITEM, QUANTIDADE, CHANCE {itemId = 2152, count = 1, chance = 50}, {itemId = 2148, count = 1, chance = 70}, } local broadcastitems = {2160, 2161} function onUse(cid, item, frompos, item2, topos) local config = { pos = getCreaturePosition(cid), -- posição do player exhaustionSeconds = 3600, -- exausted em segundos storageUse = 44231, -- storage usado. } if(exhaustion.check(cid, config.storageUse)) then if (exhaustion.get(cid, config.storageUse) >= 60) then doPlayerSendCancel(cid, "Voce so poderar abrir o bau novamente em " .. math.floor(exhaustion.get(cid, config.storageUse) / 60 + 1) .." minutos.") end if (exhaustion.get(cid, config.storageUse) <= 60) then doPlayerSendCancel(cid, "Voce precisa esperar " .. exhaustion.get(cid, config.storageUse).." segundos.") end return true end local totalChance, randomTable, randomNumber = 0, {}, 0 addEvent(doPlayerSendTextMessage, 1*1000, cid, 27, "Procurando algo...") addEvent(doPlayerSendTextMessage, 2*1000, cid, 27, "Procurando algo...") addEvent(doPlayerSendTextMessage, 3*1000, cid, 27, "Procurando algo...") addEvent(doPlayerSendTextMessage, 4*1000, cid, 27, "Procurando algo...") addEvent(doPlayerSendTextMessage, 5*1000, cid, 27, "Procurando algo...") addEvent(doSendAnimatedText, 1*1000, config.pos, "[5]", 180) addEvent(doSendAnimatedText, 2*1000, config.pos, "[4]", 180) addEvent(doSendAnimatedText, 3*1000, config.pos, "[3]", 180) addEvent(doSendAnimatedText, 4*1000, config.pos, "[2]", 180) addEvent(doSendAnimatedText, 5*1000, config.pos, "[1]", 180) addEvent(doSendAnimatedText, 6*1000, config.pos, "DONE!", 180) for _, itemInfo in pairs (items) do randomTable[itemInfo.itemId] = {min = totalChance + 1, max = itemInfo.chance, count = itemInfo.count or 1} totalChance = totalChance + itemInfo.chance end randomNumber = math.random(1, totalChance) for itemId, itemInfo in pairs (randomTable) do local min, max = itemInfo.min, itemInfo.min + itemInfo.max if randomNumber >= min and randomNumber <= max then local newItem = addEvent(doPlayerAddItem, 6*1000, cid, itemId, itemInfo.count, false) if not newItem then return doPlayerSendCancel(cid, "Voce nao tem espaco para receber o item!") end doRemoveItem(item.uid, 0) exhaustion.set(cid, config.storageUse, config.exhaustionSeconds) local iInfo = getItemInfo(itemId) addEvent(doPlayerSendTextMessage, 6*1000, cid, 27, "Voce achou ("..iInfo.name..")!") for i, broaditem in ipairs(broadcastitems) do if itemId==broaditem then doBroadcastMessage(""..getCreatureName(cid).." acabou de ganhar: "..iInfo.name.." na Mystery Box.")end end break end end return true end n coloquei quantidade, ia ter q usar 1 array pra cada item ou storage Editado Outubro 15, 2017 7 anos por rogaforyn2 (veja o histórico de edições)
Postado Outubro 15, 2017 7 anos Autor Em 15/10/2017 em 20:26, rogaforyn2 disse: tu pode testar assim tb, n testei, aí é só por em broadcastitems os id q vai dar broadcast eu coloquei 2160, 2161 ali soh de exemplo, muda com os q vc qr e adiciona mais colocando virgula local items = { {itemId = 2160, count = 1, chance = 50}, -- ITEM, QUANTIDADE, CHANCE {itemId = 2152, count = 1, chance = 50}, {itemId = 2148, count = 1, chance = 70}, } local broadcastitems = {2160, 2161} function onUse(cid, item, frompos, item2, topos) local config = { pos = getCreaturePosition(cid), -- posição do player exhaustionSeconds = 3600, -- exausted em segundos storageUse = 44231, -- storage usado. } if(exhaustion.check(cid, config.storageUse)) then if (exhaustion.get(cid, config.storageUse) >= 60) then doPlayerSendCancel(cid, "Voce so poderar abrir o bau novamente em " .. math.floor(exhaustion.get(cid, config.storageUse) / 60 + 1) .." minutos.") end if (exhaustion.get(cid, config.storageUse) <= 60) then doPlayerSendCancel(cid, "Voce precisa esperar " .. exhaustion.get(cid, config.storageUse).." segundos.") end return true end local totalChance, randomTable, randomNumber = 0, {}, 0 addEvent(doPlayerSendTextMessage, 1*1000, cid, 27, "Procurando algo...") addEvent(doPlayerSendTextMessage, 2*1000, cid, 27, "Procurando algo...") addEvent(doPlayerSendTextMessage, 3*1000, cid, 27, "Procurando algo...") addEvent(doPlayerSendTextMessage, 4*1000, cid, 27, "Procurando algo...") addEvent(doPlayerSendTextMessage, 5*1000, cid, 27, "Procurando algo...") addEvent(doSendAnimatedText, 1*1000, config.pos, "[5]", 180) addEvent(doSendAnimatedText, 2*1000, config.pos, "[4]", 180) addEvent(doSendAnimatedText, 3*1000, config.pos, "[3]", 180) addEvent(doSendAnimatedText, 4*1000, config.pos, "[2]", 180) addEvent(doSendAnimatedText, 5*1000, config.pos, "[1]", 180) addEvent(doSendAnimatedText, 6*1000, config.pos, "DONE!", 180) for _, itemInfo in pairs (items) do randomTable[itemInfo.itemId] = {min = totalChance + 1, max = itemInfo.chance, count = itemInfo.count or 1} totalChance = totalChance + itemInfo.chance end randomNumber = math.random(1, totalChance) for itemId, itemInfo in pairs (randomTable) do local min, max = itemInfo.min, itemInfo.min + itemInfo.max if randomNumber >= min and randomNumber <= max then local newItem = addEvent(doPlayerAddItem, 6*1000, cid, itemId, itemInfo.count, false) if not newItem then return doPlayerSendCancel(cid, "Voce nao tem espaco para receber o item!") end doRemoveItem(item.uid, 0) exhaustion.set(cid, config.storageUse, config.exhaustionSeconds) local iInfo = getItemInfo(itemId) addEvent(doPlayerSendTextMessage, 6*1000, cid, 27, "Voce achou ("..iInfo.name..")!") for i, broaditem in ipairs(broadcastitems) do if itemId==broaditem then doBroadcastMessage(""..getCreatureName(cid).." acabou de ganhar: "..iInfo.name.." na Mystery Box.")end end break end end return true end n coloquei quantidade, ia ter q usar 1 array pra cada item ou storage Gostei bastante desse formato, fiz o teste e tem um problema, ele está avisando que o player ganhou o item raro no caso (2160) antes da contagem de 5 segundos.
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.