Postado Outubro 19, 2018 6 anos local chest = { [8049] = { name = '[Event] BOX', container = 1738, items = { [1] = { chance = 100, itemId = 2160, amountMax = 10 } } } } function onUse(cid, item, frompos, item2, topos) local tmpConfig = chest[item.actionid] if not tmpConfig then return true end local container, str = doPlayerAddItem(cid, tmpConfig.container, 1), 'BackPack from '.. tmpConfig.name ..', Your Rewards:\n' for i = 1, #tmpConfig.items do local items = tmpConfig.items[i] if chance >= math.random(1, 100) then local amountRandom = math.random(1, items.amountMax) str = str .. amountRandom .. ' ' .. getItemNameById(items.itemId) .. ' '..(i ~= #tmpConfig.items and ', ' or '.') doAddContainerItem(tmpConfig.container, items.itemId, amountRandom) else return true end end doSendMagicEffect(getPlayerPosition(cid), math.random(28, 30)) doRemoveItem(item.uid, 1) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,'You have found a '.. str) return true end
Postado Outubro 19, 2018 6 anos Autor Em 19/10/2018 em 19:56, FlavioHulk disse: local chest = { [8049] = { name = '[Event] BOX', container = 1738, items = { [1] = { chance = 100, itemId = 2160, amountMax = 10 } } } } function onUse(cid, item, frompos, item2, topos) local tmpConfig = chest[item.actionid] if not tmpConfig then return true end local container, str = doPlayerAddItem(cid, tmpConfig.container, 1), 'BackPack from '.. tmpConfig.name ..', Your Rewards:\n' for i = 1, #tmpConfig.items do local items = tmpConfig.items[i] if chance >= math.random(1, 100) then local amountRandom = math.random(1, items.amountMax) str = str .. amountRandom .. ' ' .. getItemNameById(items.itemId) .. ' '..(i ~= #tmpConfig.items and ', ' or '.') doAddContainerItem(tmpConfig.container, items.itemId, amountRandom) else return true end end doSendMagicEffect(getPlayerPosition(cid), math.random(28, 30)) doRemoveItem(item.uid, 1) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,'You have found a '.. str) return true end [18:11:34.774] [Error - Action Interface] [18:11:34.776] data/actions/scripts/test2.lua:onUse [18:11:34.779] Description: [18:11:34.781] data/actions/scripts/test2.lua:24: attempt to compare number with nil [18:11:34.782] stack traceback: [18:11:34.783] data/actions/scripts/test2.lua:24: in function <data/actions/scripts/test2.lua:15> Senhoras e senhores, se alguma resposta lhe ajudou, marque-a como a melhor resposta e de ponto positivo, assim você incentiva quem lhe ajudou a continuar ajudando!!.
Postado Outubro 19, 2018 6 anos local chest = { [8049] = { name = '[Event] BOX', container = 1738, items = { [1] = { chance = 100, itemId = 2160, amountMax = 10 } } } } function onUse(cid, item, frompos, item2, topos) local tmpConfig = chest[item.actionid] if not tmpConfig then return true end local container, str = doPlayerAddItem(cid, tmpConfig.container, 1), 'BackPack from '.. tmpConfig.name ..', Your Rewards:\n' for i = 1, #tmpConfig.items do local items = tmpConfig.items[i] if tmpConfig.chance >= math.random(1, 100) then local amountRandom = math.random(1, items.amountMax) str = str .. amountRandom .. ' ' .. getItemNameById(items.itemId) .. ' '..(i ~= #tmpConfig.items and ', ' or '.') doAddContainerItem(tmpConfig.container, items.itemId, amountRandom) else return true end end doSendMagicEffect(getPlayerPosition(cid), math.random(28, 30)) doRemoveItem(item.uid, 1) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,'You have found a '.. str) return true end
Postado Outubro 19, 2018 6 anos Autor Em 19/10/2018 em 22:26, FlavioHulk disse: local chest = { [8049] = { name = '[Event] BOX', container = 1738, items = { [1] = { chance = 100, itemId = 2160, amountMax = 10 } } } } function onUse(cid, item, frompos, item2, topos) local tmpConfig = chest[item.actionid] if not tmpConfig then return true end local container, str = doPlayerAddItem(cid, tmpConfig.container, 1), 'BackPack from '.. tmpConfig.name ..', Your Rewards:\n' for i = 1, #tmpConfig.items do local items = tmpConfig.items[i] if tmpConfig.chance >= math.random(1, 100) then local amountRandom = math.random(1, items.amountMax) str = str .. amountRandom .. ' ' .. getItemNameById(items.itemId) .. ' '..(i ~= #tmpConfig.items and ', ' or '.') doAddContainerItem(tmpConfig.container, items.itemId, amountRandom) else return true end end doSendMagicEffect(getPlayerPosition(cid), math.random(28, 30)) doRemoveItem(item.uid, 1) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,'You have found a '.. str) return true end [19:35:34.292] [Error - Action Interface] [19:35:34.294] data/actions/scripts/test2.lua:onUse [19:35:34.295] Description: [19:35:34.298] data/actions/scripts/test2.lua:24: attempt to compare number with nil [19:35:34.299] stack traceback: [19:35:34.300] data/actions/scripts/test2.lua:24: in function <data/actions/scripts/test2.lua:15> Senhoras e senhores, se alguma resposta lhe ajudou, marque-a como a melhor resposta e de ponto positivo, assim você incentiva quem lhe ajudou a continuar ajudando!!.
Postado Outubro 19, 2018 6 anos Solução local chest = { [8049] = { name = '[Event] BOX', container = 1738, items = { [1] = { chance = 100, itemId = 2160, amountMax = 10 } } } } function onUse(cid, item, frompos, item2, topos) local tmpConfig = chest[item.actionid] if not tmpConfig then return true end local container, str = doPlayerAddItem(cid, tmpConfig.container, 1), 'BackPack from '.. tmpConfig.name ..', Your Rewards:\n' for i = 1, #tmpConfig.items do local items = tmpConfig.items[i] if items.chance >= math.random(1, 100) then local amountRandom = math.random(1, items.amountMax) str = str .. amountRandom .. ' ' .. getItemNameById(items.itemId) .. ' '..(i ~= #tmpConfig.items and ', ' or '.') doAddContainerItem(container, items.itemId, amountRandom) else return true end end doSendMagicEffect(getPlayerPosition(cid), math.random(28, 30)) doRemoveItem(item.uid, 1) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,'You have found a '.. str) return true end Puts, erro meu! Não havia reparado, mas tudo bem, vida que segue... @KotZletY @Vodkart marcação aleatória, só saudades
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.