Postado Setembro 21, 2017 7 anos Olá, como o título já diz, Gostaria de um script que quando o player clicar em um item ele fosse teleportado para uma cordenada x, y, z, e que ele só pudesse ser teleportado se estivesse em pz, e possuir um cooldown de um dia para poder usar o item novamente . desde já agradeço
Postado Setembro 21, 2017 7 anos Tente isso, em /actions/scripts/, crie um arquivo .lua e coloque isso dentro: Spoiler function onUse(cid, item, fromPosition, itemEx, toPosition) local pos = {x = 0, y = 0, z = 7} local hours = 24 local storage = 34534 if getPlayerStorageValue(cid, storage) - os.time() > 0 then doPlayerSendTextMessage(cid, 27, "You need wait.") return true end if not getTilePzInfo(fromPosition) then doPlayerSendTextMessage(cid, 27, "You need to be in protection zone.") return true end doTeleportThing(cid, pos) setPlayerStorageValue(cid, storage, os.time()+hours*60*60) return true end Em /actions/actions.xml coloque essa linha: Spoiler <action itemid="xxxx" event="script" value="arquivo.lua"/> Altere o nome do arquivo e o id do item.
Postado Setembro 21, 2017 7 anos Solução Em actions/scripts crie um arquivo: itemteleport.lua Spoiler local newpos = Position(1,1,1) local time = {1, "day"} function onUse(player, item, fromPosition, target, toPosition, isHotkey) if player:getStorageValue(65770) >= os.time() then return player:sendCancelMessage("You can use again at " .. os.date("%d %B %Y %X", player:getStorageValue(65770))..".") end if not getTilePzInfo(player:getPosition()) then return player:sendCancelMessage("You can use this item only inside protection zone.") end player:teleportTo(newpos) newpos:sendMagicEffect(CONST_ME_TELEPORT) player:setStorageValue(65770, mathtime(time) + os.time()) return true end function mathtime(table) -- by dwarfer local unit = {"sec", "min", "hour", "day"} for i, v in pairs(unit) do if v == table[2] then return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1) end end return "Error: Bad declaration in mathtime function." end Em actions.xml, adicione a tag: <action itemid="ID_DO_ITEM" script="itemteleport.lua"/>
Postado Setembro 21, 2017 7 anos Autor 26 minutos atrás, Noninhouh disse: Tente isso, em /actions/scripts/, crie um arquivo .lua e coloque isso dentro: Ocultar conteúdo function onUse(cid, item, fromPosition, itemEx, toPosition) local pos = {x = 0, y = 0, z = 7} local hours = 24 local storage = 34534 if getPlayerStorageValue(cid, storage) - os.time() > 0 then doPlayerSendTextMessage(cid, 27, "You need wait.") return true end if not getTilePzInfo(fromPosition) then doPlayerSendTextMessage(cid, 27, "You need to be in protection zone.") return true end doTeleportThing(cid, pos) setPlayerStorageValue(cid, storage, os.time()+hours*60*60) return true end Em /actions/actions.xml coloque essa linha: Ocultar conteúdo <action itemid="xxxx" event="script" value="arquivo.lua"/> Altere o nome do arquivo e o id do item. Muito obrigado pela ajuda, eu testei e quando usa o item mesmo dentro do pz ele da a mensagem que não estou dentro do pz e não consigo usar o item . 16 minutos atrás, Dwarfer disse: Em actions/scripts crie um arquivo: itemteleport.lua Ocultar conteúdo local newpos = Position(1,1,1) local time = {1, "day"} function onUse(player, item, fromPosition, target, toPosition, isHotkey) if player:getStorageValue(65770) >= os.time() then return player:sendCancelMessage("You can use again at " .. os.date("%d %B %Y %X", player:getStorageValue(65770))..".") end if not getTilePzInfo(player:getPosition()) then return player:sendCancelMessage("You can use this item only inside protection zone.") end player:teleportTo(newpos) newpos:sendMagicEffect(CONST_ME_TELEPORT) player:setStorageValue(65770, mathtime(time) + os.time()) return true end function mathtime(table) -- by dwarfer local unit = {"sec", "min", "hour", "day"} for i, v in pairs(unit) do if v == table[2] then return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1) end end return "Error: Bad declaration in mathtime function." end Em actions.xml, adicione a tag: <action itemid="ID_DO_ITEM" script="itemteleport.lua"/> Testei o seu amigo e funcionou, fora do pz ele notifica que precisa estar em pz para usar o item, e quando está no pz ele teleporta corretamente para a coordenada, está funcionando perfeitamente, muito obrigado.-Resolvido
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.