function isWalkable(pos)-- by Nord / editado por Omega
if getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid == 0
then return false
elseif getTopCreature(pos).uid > 0 then
return false
elseif isCreature(getTopCreature(pos).uid) then
return false
elseif getTileInfo(pos).protection then
return false
elseif hasProperty(getThingFromPos(pos).uid, 3) or hasProperty(getThingFromPos(pos).uid, 7) then
return false
end
return true
end
function onUse(cid, item, frompos, item2, topos, item3)
local pos = getThingPos(item2.uid)
local effect = 2 ------Coloque aki o efeito que saira quando usar o item--------
local time = 40 -- tempo em segundos.
local itemId = 2554 -- id do item --[[ o mesmo da tag ]]--
local pos1 = getCreaturePosition(cid)
if getTilePzInfo(getCreaturePosition(cid)) then
return doPlayerSendCancel(cid, "O item nao tem poder em Protection Zones.")
elseif not isWalkable(topos) then
return doPlayerSendCancel(cid, "Sorry, not possible.")
elseif not isSightClear(getThingPos(cid), topos, false) then
return doPlayerSendCancel(cid, "Sorry, not possible.")
end
if getDistanceBetween(pos1, pos) <= 6 then
if getPlayerSlotItem(cid, 9).itemid == itemId or getPlayerSlotItem(cid, 10).itemid == itemId then
if getPlayerStorageValue(cid, 1239870) - os.time() <= 0 then
doTeleportThing(cid, pos, false)
doSendMagicEffect(pos, effect)
setPlayerStorageValue(cid, 1239870, os.time()+time)
else
doPlayerSendCancel(cid, "Você só pode usar esse item a cada "..time.." segundos!")
end
else
doPlayerSendCancel(cid, "Você só pode usar o item "..getItemNameById(itemId).." estiver equipado na mão.")
end
else
doPlayerSendCancel(cid, "Você só pode usar esse item a 3 sqm longe de você")
end
return true
end






info
Grupo: Artesão
Registrado: 31/12/10
Posts: 136
Reputação: +1
galera estou com um problema fiz um tipo de "kawarimi"
ele teleporta para onde o player usar o use ! porem
se o player da use na parede o player vai até a parede, tem como colocar para ele nao atravessar paredes, e portas?
function onUse(cid, item, frompos, item2, topos, item3)
local pos = getThingPos(item2.uid)
local effect = 2 ------Coloque aki o efeito que saira quando usar o item--------
local time = 40 -- tempo em segundos.
local itemId = 2554 -- id do item --[[ o mesmo da tag ]]--
local pos1 = getCreaturePosition(cid)
if getTilePzInfo(getCreaturePosition(cid)) then
return doPlayerSendCancel(cid, "O item nao tem poder em Protection Zones.")
end
if getDistanceBetween(pos1, pos) <= 6 then
if getPlayerSlotItem(cid, 9).itemid == itemId or getPlayerSlotItem(cid, 10).itemid == itemId then
if getPlayerStorageValue(cid, 1239870) - os.time() <= 0 then
doTeleportThing(cid, pos, false)
doSendMagicEffect(pos, effect)
setPlayerStorageValue(cid, 1239870, os.time()+time)
else
doPlayerSendCancel(cid, "Você só pode usar esse item a cada "..time.." segundos!")
end
else
doPlayerSendCancel(cid, "Você só pode usar o item "..getItemNameById(itemId).." estiver equipado na mão.")
end
else
doPlayerSendCancel(cid, "Você só pode usar esse item a 3 sqm longe de você")
end
return true
end