Postado Março 24, 2015 10 anos Fala galerinha, como o pessoal aqui da seção tem me ajudado muito vim fazer mais um pedido. Tenho uma quest e quero que após o player pegar a recompensa o baú some e o player e jogado para um destino. Aqui está o script, alguém poderiam me ajudar a adicionar essas duas funções ? local config = { storage = 27364, exhauststorage = 20932, days = { ["Monday"] = {itemid = 2160, count = 15, storagevalue = 8}, ["Tuesday"] = {itemid = 2160, count = 20, storagevalue = 9}, ["Wednesday"] = {itemid = 6570, count = 1, storagevalue = 10}, ["Thursday"] = {itemid = 6570, count = 1, storagevalue = 11}, ["Friday"] = {itemid = 6570, count = 1, storagevalue = 12}, ["Saturday"] = {itemid = 6570, count = 1, storagevalue = 13}, ["Sunday"] = {itemid = 2160, count = 10, storagevalue = 14} } } function onUse(cid, item, fromPosition, itemEx, toPosition) local x = config.days[os.date("%A",os.time())] if(getPlayerStorageValue(cid, config.storage) == x.storagevalue and exhaustion.check(cid, config.exhauststorage)) then return doPlayerSendCancel(cid, "The chest is empty, come back tomorrow for a new reward.") end local info = getItemInfo(x.itemid) if(x.count > 1) then text = x.count .. " " .. info.plural else text = info.article .. " " .. info.name end local item = doCreateItemEx(x.itemid, x.count) if(doPlayerAddItemEx(cid, item, false) ~= RETURNVALUE_NOERROR) then doSendMagicEffect(getThingPos(cid), CONST_ME_POFF) text = "You have found a reward weighing " .. getItemWeight(item) .. " oz. It is too heavy or you have not enough space." else text = "You have received " .. text .. "." setPlayerStorageValue(cid, config.storage, x.storagevalue) exhaustion.set(cid, config.exhauststorage, 24*60*60) end doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, text) return true end
Postado Março 24, 2015 10 anos Solução Testa ai: local config = { storage = 27364, exhauststorage = 20932, destino = {x = 1010, y = 1020, z = 7}, days = { ["Monday"] = {itemid = 2160, count = 15, storagevalue = 8}, ["Tuesday"] = {itemid = 2160, count = 20, storagevalue = 9}, ["Wednesday"] = {itemid = 6570, count = 1, storagevalue = 10}, ["Thursday"] = {itemid = 6570, count = 1, storagevalue = 11}, ["Friday"] = {itemid = 6570, count = 1, storagevalue = 12}, ["Saturday"] = {itemid = 6570, count = 1, storagevalue = 13}, ["Sunday"] = {itemid = 2160, count = 10, storagevalue = 14} } } function onUse(cid, item, fromPosition, itemEx, toPosition) local x = config.days[os.date("%A",os.time())] if(getPlayerStorageValue(cid, config.storage) == x.storagevalue and exhaustion.check(cid, config.exhauststorage)) then return doPlayerSendCancel(cid, "The chest is empty, come back tomorrow for a new reward.") end local info = getItemInfo(x.itemid) if(x.count > 1) then text = x.count .. " " .. info.plural else text = info.article .. " " .. info.name end local itm = doCreateItemEx(x.itemid, x.count) if(doPlayerAddItemEx(cid, itm, false) ~= RETURNVALUE_NOERROR) then doSendMagicEffect(getThingPos(cid), CONST_ME_POFF) text = "You have found a reward weighing " .. getItemWeight(itm) .. " oz. It is too heavy or you have not enough space." else text = "You have received " .. text .. "." setPlayerStorageValue(cid, config.storage, x.storagevalue) exhaustion.set(cid, config.exhauststorage, 24*60*60) doTeleportThing(cid, config.destino) doRemoveItem(item.uid, 1) end doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, text) return true end ➥ Regras | Seções OTServ | Seções BOT
Postado Março 24, 2015 10 anos Autor Obrigado cara, funcionou certinho. Só tive que trocar o : doTeleportThing(cid, config.destino) E inverter de lugar com o: doRemoveItem(item.uid, 1) Ficando: local config = { storage = 27364, exhauststorage = 20932, destino = {x = 251, y = 253, z = 6}, days = { ["Monday"] = {itemid = 2160, count = 15, storagevalue = 8}, ["Tuesday"] = {itemid = 2160, count = 20, storagevalue = 9}, ["Wednesday"] = {itemid = 6570, count = 1, storagevalue = 10}, ["Thursday"] = {itemid = 6570, count = 1, storagevalue = 11}, ["Friday"] = {itemid = 6570, count = 1, storagevalue = 12}, ["Saturday"] = {itemid = 6570, count = 1, storagevalue = 13}, ["Sunday"] = {itemid = 2160, count = 10, storagevalue = 14} } } function onUse(cid, item, fromPosition, itemEx, toPosition) local x = config.days[os.date("%A",os.time())] if(getPlayerStorageValue(cid, config.storage) == x.storagevalue and exhaustion.check(cid, config.exhauststorage)) then return doPlayerSendCancel(cid, "The chest is empty, come back tomorrow for a new reward.") end local info = getItemInfo(x.itemid) if(x.count > 1) then text = x.count .. " " .. info.plural else text = info.article .. " " .. info.name end local itm = doCreateItemEx(x.itemid, x.count) if(doPlayerAddItemEx(cid, itm, false) ~= RETURNVALUE_NOERROR) then doSendMagicEffect(getThingPos(cid), CONST_ME_POFF) text = "You have found a reward weighing " .. getItemWeight(itm) .. " oz. It is too heavy or you have not enough space." else text = "You have received " .. text .. "." setPlayerStorageValue(cid, config.storage, x.storagevalue) exhaustion.set(cid, config.exhauststorage, 24*60*60) doRemoveItem(item.uid, 1) doTeleportThing(cid, config.destino) end doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, text) return true end Me ajudou muito, marcado como melhor resposta e reputado !
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.