Postado Novembro 19, 2018 6 anos Autor Em 16/11/2018 em 05:53, FlavioHulk disse: local config = { [1234] = { -- ActionId do baú rewards { [1] = {itemId = 2160, amount = 25} -- Item ID e quantidade, por padrão quantidade é 1 }, storage = 213213 }, [1235] = { rewards = { [1] = {itemId = 2195} }, storage = 213213 }, [1231] = { rewards = { [1] = {itemId = 3121} }, storage = 213213 } } function onUse(cid, item, fromPos, item2, count, toPos) local tmpConfig = config[item.actionid] if tmpConfig == nil then return false end if player:getStorageValue(tmpConfig.storage) > 0 then doPlayerSendTextMessage(cid, 22, 'It is empty.') return true end local weight = 0 for i = 1, #tmpConfig.rewards do local reward = tmpConfig.rewards[i] local weightReward = getItemWeightById(reward.itemId, reward.amount or 1) weight = weight + weightReward end if getPlayerFreeCap(cid) < weight then doPlayerSendTextMessage(cid, 22, 'You have found a reward. It weighs '.. weight ..'.00 and it is too heavy.') return true end local backpack = getPlayerSlotItem(cid, CONST_SLOT_BACKPACK).uid local freeSlots = math.max(0, getContainerCap(backpack) - getContainerSize(backpack)) if freeSlots < #tmpConfig.rewards then doPlayerSendTextMessage(cid, 22, 'You have found a reward, but you need a free slot.') return true end for i = 1, #tmpConfig.rewards do local reward = tmpConfig.rewards[i] doPlayerSendTextMessage(cid, 22, 'You have found a '.. getItemNameById(reward.itemId) ..'.') doPlayerAddItem(cid, reward.itemId, reward.amount or 1) end setPlayerStorageValue(cid, tmpConfig.storage, 1) return true end Testa aí, depois me fala... Eu não testei Não funcionou amigos, infelizmente. Ele nao da erro nenhum, mas quando abro o bau in game, nao vem as recompensas nem acusa nenhum erro na distro. local config = { [1234] = { -- ActionId do baú rewards { [1] = {itemId = 5886, amount = 50} [2] = {itemId = 5899} [3] = {itemId = 5888} -- Item ID e quantidade, por padrão quantidade é 1 }, storage = 213213 }, [1235] = { rewards = { [1] = {itemId = 2160, amount = 55} }, storage = 213213 } } function onUse(cid, item, fromPos, item2, count, toPos) local tmpConfig = config[item.actionid] if tmpConfig == nil then return false end if player:getStorageValue(tmpConfig.storage) > 0 then doPlayerSendTextMessage(cid, 22, 'It is empty.') return true end local weight = 0 for i = 1, #tmpConfig.rewards do local reward = tmpConfig.rewards[i] local weightReward = getItemWeightById(reward.itemId, reward.amount or 1) weight = weight + weightReward end if getPlayerFreeCap(cid) < weight then doPlayerSendTextMessage(cid, 22, 'You have found a reward. It weighs '.. weight ..'.00 and it is too heavy.') return true end local backpack = getPlayerSlotItem(cid, CONST_SLOT_BACKPACK).uid local freeSlots = math.max(0, getContainerCap(backpack) - getContainerSize(backpack)) if freeSlots < #tmpConfig.rewards then doPlayerSendTextMessage(cid, 22, 'You have found a reward, but you need a free slot.')?? return true end for i = 1, #tmpConfig.rewards do local reward = tmpConfig.rewards[i] doPlayerSendTextMessage(cid, 22, 'You have found a '.. getItemNameById(reward.itemId) ..'.') doPlayerAddItem(cid, reward.itemId, reward.amount or 1) end setPlayerStorageValue(cid, tmpConfig.storage, 1) return true end O meu codigo de teste, editei e coloquei esses itens de addon, e fiz outro bau para ficar com 2 testando. Nenhum dos dois funcionou, nem trocando o storage pra ficar diferente.
Postado Novembro 20, 2018 6 anos Você testou o que enviei? Caso tenha testado, veja se você está configurando tudo certo: 1 - Colocou o actionID nos baús pelo mapa editor? 2 - Colocou todos os actionsIDs que está testando no data/actions/actions.xml?
Postado Novembro 20, 2018 6 anos function onUse(cid, item, fromPos, item2, count, toPos) local _ = { [1] = {aid = 1234, item = 2160, amount = 25}, -- Aqui gostaria de colocar a quantidade 25 e colocar mais de um item em um unico bau. [2] = {aid = 1235, item = 2195, amount = 10}, [3] = {aid = 1231, item = 3121, amount = 1}, } for i = 1, #_ do _.storage = 202049 + i end for i, valor in ipairs(_) do if item.actionid == valor.aid then if getPlayerFreeCap(cid) >= getItemWeightById(valor.item, valor.amount) then if getPlayerStorageValue(cid, valor.storage) == -1 then local backpack = doPlayerAddItem(cid, 1999, 1) -- backpackID if isItemStackable(valor.item) or valor.amount == 1 then doAddContainerItem(backpack, valor.item, valor.amount) else for i = 1, valor.amount do doAddContainerItem(backpack, valor.item, 1) end end doPlayerSendTextMessage(cid, 22, 'You have found a '..valor.amount..'x '..getItemNameById(valor.item)..'.') setPlayerStorageValue(cid, valor.storage, 1) else doPlayerSendTextMessage(cid, 22, 'It is empty.') end else doPlayerSendTextMessage(cid, 22, 'You have found a '..getItemNameById(valor.item)..'. It weighs '..getItemWeightById(valor.item, valor.amount)..'.00 and it is too heavy.') end break end end return true end
Postado Novembro 21, 2018 6 anos Autor Em 20/11/2018 em 11:19, lordzetros disse: Você testou o que enviei? Caso tenha testado, veja se você está configurando tudo certo: 1 - Colocou o actionID nos baús pelo mapa editor? 2 - Colocou todos os actionsIDs que está testando no data/actions/actions.xml? Fiz tudo direitinho sim amigo, mas não funcionou.
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.