• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Solved I need this teleport rune fixed please

Werewolf

Forbidden Ascension
Joined
Jul 15, 2012
Messages
886
Reaction score
123
LUA:
local t = {
    storage = 12345,
    time = 3,
    vocations = {8, 16, 46, 47, 48, 58}
}
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if(t.vocations and not isInArray(t.vocations, getPlayerVocation(cid) or isInArray({CONST_PROP_MOVABLE, CONST_PROP_BLOCKSOLID}, hasItemProperty(getTileThingByPos(toPosition).uid)))) then
        doPlayerSendCancel(cid, "Sorry, not possible.")
    elseif(getTilePzInfo(getCreaturePosition(cid)) == TRUE or getTilePzInfo(toPosition) == TRUE) then
        doPlayerSendCancel(cid, "You cannot Teleport in a protection zone.")
    elseif(getPlayerStorageValue(cid, t.storage) > os.time()) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You must wait another " .. getPlayerStorageValue(cid, t.storage) - os.time() .. ' second' .. ((getPlayerStorageValue(cid, t.storage) - os.time()) == 1 and "" or "s") .. " to teleport.")
    else
        doSendDistanceShoot(getCreaturePosition(cid), toPosition, CONST_ANI_HOLY) -- Holy effect can be changed here.
        doTeleportThing(cid, toPosition)
        doSendMagicEffect(toPosition, CONST_ME_ENERGYAREA)
        setPlayerStorageValue(cid, t.storage, os.time() + t.time)
    end
    return true
end


------------------------------------------------------------------------------------------------This Rune Works Perfect, However it has 1 flaw... It is able to teleport inside walls and players. I need this rune to stop teleporting in non-movable areas like, Trees, Players, Walls and stuff like that, Is anyone able to help me out D:?
 
Last edited by a moderator:
Add this on libs/050-functions.lua

LUA:
function isWalkable(pos, creature, proj, pz)-- by Nord
	if getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid == 0 then return false end
	if getTopCreature(pos).uid > 0 and creature then return false end
	if getTileInfo(pos).protection and pz then return false, true end
	local n = not proj and 3 or 2
	for i = 0, 255 do
		pos.stackpos = i
		local tile = getTileThingByPos(pos)
		if tile.itemid ~= 0 and not isCreature(tile.uid) then
			if hasProperty(tile.uid, n) or hasProperty(tile.uid, 7) then
				return false
			end
		end
	end
	return true
end

and replace your script with this:
LUA:
local t = {
    storage = 12345,
    time = 3,
    vocations = {8, 16, 46, 47, 48, 58}
}
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if(t.vocations and not isInArray(t.vocations, getPlayerVocation(cid) or isInArray({CONST_PROP_MOVABLE, CONST_PROP_BLOCKSOLID}, hasItemProperty(getTileThingByPos(toPosition).uid)))) then
        doPlayerSendCancel(cid, "Sorry, not possible.")
    elseif(getTilePzInfo(getCreaturePosition(cid)) == TRUE or getTilePzInfo(toPosition) == TRUE) then
        doPlayerSendCancel(cid, "You cannot Teleport in a protection zone.")
    elseif(getPlayerStorageValue(cid, t.storage) > os.time()) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You must wait another " .. getPlayerStorageValue(cid, t.storage) - os.time() .. ' second' .. ((getPlayerStorageValue(cid, t.storage) - os.time()) == 1 and "" or "s") .. " to teleport.")
    else
	if isWalkable(toPosition, false, false, true, true, true) then
		doSendDistanceShoot(getCreaturePosition(cid), toPosition, CONST_ANI_HOLY) -- Holy effect can be changed here.
        doTeleportThing(cid, toPosition)
        doSendMagicEffect(toPosition, CONST_ME_ENERGYAREA)
        setPlayerStorageValue(cid, t.storage, os.time() + t.time)
		end
	end
    return true
end

- - - Updated - - -

If that script above dont work, try this:

LUA:
local t = {
    storage = 12345,
    time = 3,
    vocations = {8, 16, 46, 47, 48, 58}
}
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if(t.vocations and not isInArray(t.vocations, getPlayerVocation(cid) or isInArray({CONST_PROP_MOVABLE, CONST_PROP_BLOCKSOLID}, hasItemProperty(getTileThingByPos(toPosition).uid)))) then
        doPlayerSendCancel(cid, "Sorry, not possible.")
    elseif(getTilePzInfo(getCreaturePosition(cid)) == TRUE or getTilePzInfo(toPosition) == TRUE) then
        doPlayerSendCancel(cid, "You cannot Teleport in a protection zone.")
    elseif(getPlayerStorageValue(cid, t.storage) > os.time()) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You must wait another " .. getPlayerStorageValue(cid, t.storage) - os.time() .. ' second' .. ((getPlayerStorageValue(cid, t.storage) - os.time()) == 1 and "" or "s") .. " to teleport.")
		return false
    end
end
	if isWalkable(toPosition, false, false, true, true, true) then
		doSendDistanceShoot(getCreaturePosition(cid), toPosition, CONST_ANI_HOLY) -- Holy effect can be changed here.
        doTeleportThing(cid, toPosition)
        doSendMagicEffect(toPosition, CONST_ME_ENERGYAREA)
        setPlayerStorageValue(cid, t.storage, os.time() + t.time)
        return true
    end
 
:D Thank you SOOOO VERY MUCH!!

You saved me years of work...

I had to make every rock, Tree, Obstical, Wall ALL protection zone so they wouldn't teleport into them XD but you fixed that THANK YOU!
 
Back
Top