• 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!

Lua doCreateTeleport + ActionID

Michaeel

New Member
Joined
Mar 6, 2009
Messages
272
Reaction score
1
Hey, I have script which make TP but i need edit this because i need also actionID of teleport:
Code:
local config = {

    teleportId = 1387,

    bosses = { -- Monster Name, Teleport To Position, Teleport Position

        ["Ushuriel"] = { { x=1173, y=1141, z=12 }, { x=1097, y=1214, z=12, stackpos=1 } },

        ["Annihilon"] = { { x=1244, y=1297, z=12 }, { x=1187, y=1198, z=12, stackpos=1 } },

        ["Hellgorak"] = { { x=1064, y=1308, z=13 }, { x=1192, y=1240, z=12, stackpos=1 } },

        ["Madareth"] = { { x=1045, y=1206, z=13 }, { x=1112, y=1240, z=12, stackpos=1 } },

        ["Zugurosh"] = { { x=1128, y=1151, z=12 }, { x=1149, y=1213, z=12, stackpos=1 } },

        ["Latrivan"] = { { x=1154, y=1195, z=13 }, { x=1147, y=1244, z=12, stackpos=1 } }

    }

}



local function removal(position)

    if getThingfromPos(position).itemid == config.teleportId then

        doRemoveItem(getThingfromPos(position).uid)

    end

    return TRUE

end



function onKill(cid, target, lastHit)
if lastHit == true then

    local position = getCreaturePosition(target)

    for name, pos in pairs(config.bosses) do

        if name == getCreatureName(target) then

            teleport = doCreateTeleport(config.teleportId, pos[1], pos[2])

            doCreatureSay(cid, config.message, TALKTYPE_ORANGE_1)

            addEvent(removal, config.timeToRemove * 1000, pos[2])
            doSendMagicEffect(pos[2], 10)

        end

    end
end

    return TRUE

I think i have to add action id of teleport after
Code:
Teleport Position
then add something to
Code:
teleport = doCreateTeleport(config.teleportId, pos[1], pos[2])

but how?
 
I need actionID because it sets storage = it saves arena.

"use the one u got in Mods, then Inquistion.xml."
I don't understand
can't I write something (for example):
bosses = { -- Monster Name, Teleport To Position, Teleport Position, actionID of teleport
["Ushuriel"] = { { x=1173, y=1141, z=12 }, { x=1097, y=1214, z=12, stackpos=1 }, {here} }, ?

and

teleport = doCreateTeleport(config.teleportId, pos[1], pos[2], actionID of TP) ?
 
Code:
local config = {
	teleportId = 1387,
	bosses = { -- Monster Name, Teleport To Position, Teleport Position, ActionID
		["ushuriel"] = { { x=1173, y=1141, z=12 }, { x=1097, y=1214, z=12 }, 20001 },
		["annihilon"] = { { x=1244, y=1297, z=12 }, { x=1187, y=1198, z=12 }, 20002 },
		["hellgorak"] = { { x=1064, y=1308, z=13 }, { x=1192, y=1240, z=12 }, 20003 },
		["madareth"] = { { x=1045, y=1206, z=13 }, { x=1112, y=1240, z=12 }, 20004 },
		["zugurosh"] = { { x=1128, y=1151, z=12 }, { x=1149, y=1213, z=12 }, 20005 },
		["latrivan"] = { { x=1154, y=1195, z=13 }, { x=1147, y=1244, z=12 }, 20006 }
	}
}

local function removal(position)
	local v = getTileItemById(position, 1387).uid
	return v > 0 and doRemoveItem(v)
end

function onKill(cid, target, lastHit)
	local i = config.bosses[getCreatureName(target):lower()]
	if lastHit and i then
		local teleport = doCreateTeleport(config.teleportId, i[1], i[2])
		doItemSetAttribute(teleport, "aid", i[3])
		doCreatureSay(cid, "You now have 3 minutes to exit this room through the teleporter. It will bring you to the next room only during his time or the teleporter will disappear.", TALKTYPE_ORANGE_1)
		addEvent(removal, 3 * 60 * 1000, i[2])
		doSendMagicEffect(i[2], CONST_ME_MAGIC_BLUE)
	end
	return true
end
 
Last edited:
I don't want to do new topic but i've merged both scripts and now it doesn't work:
Code:
local t = {
	-- position of teleporter, storage key, storage value
	[{x=904, y=1236, z=6}] = {15294, 1}
}


function onStepIn(cid, item, position, fromPosition)
	if(item.actionid > 30020 and item.actionid < 30100) then
		local townId = (item.actionid - 30020)
		doPlayerSetTown(cid, townId)
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You are the newest resident of " .. getTownName(townId) .. ".")

end
return true
end



function onStepIn(cid, item, pos, fromPosition)
	if(item.actionid > 31001 and item.actionid < 31100) then
	else
		for _pos, sk in pairs(t) do
			if pos.x == _pos.x and pos.y == _pos.y and pos.z == _pos.z then
				setPlayerStorageValue(cid, sk[1], sk[2])
				return true
			end
		end
	end

	return true
end

What's wrong here?
 
You merged them wrong.
Code:
local t = {
	-- position of teleporter, storage key, storage value
	[{x=904, y=1236, z=6}] = {15294, 1}
}
function onStepIn(cid, item, position, fromPosition)
	if item.actionid > 30020 and item.actionid < 30100 then
		local townId = (item.actionid - 30020)
		doPlayerSetTown(cid, townId)
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You are the newest resident of " .. getTownName(townId) .. ".")
	elseif item.actionid > 31001 and item.actionid < 31100 then
		for _pos, sk in pairs(t) do
			if pos.x == _pos.x and pos.y == _pos.y and pos.z == _pos.z then
				setPlayerStorageValue(cid, sk[1], sk[2])
				return true
			end
		end
	end
end
 
Yea thanks :)
But it works when someone enter to TP and when I put actionID on door as same as storage key-> then sb can open door.
Is it possible to do the same but with TP? if somebody enter to TP then he will get storage (it's already done) and he will be able to enter another TP
 
Yea I tried but it doesn't work
I used this script:
Code:
local t = {
	-- position of teleporter, storage key, storage value
	[{x=904, y=1236, z=6}] = {15294, 1}
}

function onStepIn(cid, item, pos, fromPosition)
	if(item.actionid > 31001 and item.actionid < 31100) then
	else
		for _pos, sk in pairs(t) do
			if pos.x == _pos.x and pos.y == _pos.y and pos.z == _pos.z then
				setPlayerStorageValue(cid, sk[1], sk[2])
				return true
			end
		end
	end

	return true
end

It works perfect for door but when i set same storage key at TP then everyone could enter...
any advice?
 
Well when I use this:
Code:
local t = {
	-- position of teleporter, storage key, storage value
	[{x=904, y=1236, z=6}] = {15294, 1}
}
function onStepIn(cid, item, position, fromPosition)
	if item.actionid > 30020 and item.actionid < 30100 then
		local townId = (item.actionid - 30020)
		doPlayerSetTown(cid, townId)
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You are the newest resident of " .. getTownName(townId) .. ".")
	elseif item.actionid > 31001 and item.actionid < 31100 then
		for _pos, sk in pairs(t) do
			if pos.x == _pos.x and pos.y == _pos.y and pos.z == _pos.z then
				setPlayerStorageValue(cid, sk[1], sk[2])
				return true
			end
		end
	end
end

it's the same. it works perfect for door but when I set same storage key at TP then everyone can enter
 
Code:
local STORAGE_LESS, STORAGE_LESSOREQUAL, STORAGE_EQUAL, STORAGE_NOTEQUAL, STORAGE_GREATEROREQUAL, STORAGE_GREATER = 1, 2, 3, 4, 5, 6

local t = {
	[
		{ -- position of teleporter
			x=904,
			y=1236,
			z=6
		}
	] = {
			15294, -- storage key
			1, -- storage value
			"set" -- action ("set"/"require")
	},

	[
		{ -- position of teleporter
			x=1004,
			y=1336,
			z=6
		}
	] = {
			15294, -- storage key
			1, -- storage value
			"require", -- action ("set"/"require")
			STORAGE_GREATEROREQUAL, -- StorageComparision
			{ x = 1104, y = 1436, z = 6 } -- destination
	}
}
function onStepIn(cid, item, pos, fromPosition)
	if item.actionid > 30020 and item.actionid < 30100 then
		local townId = (item.actionid - 30020)
		doPlayerSetTown(cid, townId)
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You are the newest resident of " .. getTownName(townId) .. ".")
	else
		for _pos, sk in pairs(t) do
			if pos.x == _pos.x and pos.y == _pos.y and pos.z == _pos.z then
				if sk[3] == "set" then
					setPlayerStorageValue(cid, sk[1], sk[2])
				elseif sk[3] == "require" and sk[4] and sk[4] >= 1 and sk[4] <= 6 and type(sk[5]) == "table" then
					local c, k, v = sk[4], getPlayerStorageValue(cid, sk[1]), sk[2]
					doTeleportThing(cid, ((c == 1 and k < v) or (c == 2 and k <= v) or (c == 3 and k == v) or (c == 4 and k ~= v) or (c == 5 and k >= v) or (c == 6 and k > v)) and sk[5] or fromPosition)
				end
				return true
			end
		end
	end
end
 
Last edited:
Ok thanks, but it doesn't work :(
I did in map editor teleport without destination:
15:53 You see a magic forcefield.
You can see the other side through it.
ItemID: [1387], ActionID: [15294].
Position: [X: 920] [Y: 1236] [Z: 7].

And I've configured script
Code:
local STORAGE_LESS, STORAGE_LESSOREQUAL, STORAGE_EQUAL, STORAGE_NOTEQUAL, STORAGE_GREATEROREQUAL, STORAGE_GREATER = 1, 2, 3, 4, 5, 6

local t = {
	-- position of teleporter, storage key, storage value, , , if using action "require, 
	[
		{ -- position of teleporter
			x=920,
			y=1236,
			z=7
		}
	] = {
			15294, -- storage key
			1, -- storage value
			"set" -- action ("set"/"require")
	},

	[
		{ -- position of teleporter
			x=920,
			y=1236,
			z=7
		}
	] = {
			15294, -- storage key
			1, -- storage value
			"require", -- action ("set"/"require")
			STORAGE_GREATEROREQUAL, -- StorageComparision
			{ x = 918, y = 1236, z = 7 } -- destination
	}
}
function onStepIn(cid, item, position, fromPosition)
	if item.actionid > 30020 and item.actionid < 30100 then
		local townId = (item.actionid - 30020)
		doPlayerSetTown(cid, townId)
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You are the newest resident of " .. getTownName(townId) .. ".")
	else
		for _pos, sk in pairs(t) do
			if pos.x == _pos.x and pos.y == _pos.y and pos.z == _pos.z then
				if sk[3] == "set" then
					setPlayerStorageValue(cid, sk[1], sk[2])
				elseif sk[3] == "require" and sk[4] and sk[4] >= 1 and sk[4] <= 6 then
					local c, k, v = sk[4], getPlayerStorageValue(cid, sk[1]), sk[2]
					doTeleportThing(cid, ((c == 1 and k < v) or (c == 2 and k <= v) or (c == 3 and k == v) or (c == 4 and k ~= v) or (c == 5 and k >= v) or (c == 6 and k > v)) and sk[5] or fromPosition)
				end
				return true
			end
		end
	end
end

When I stepin TP then:
inq20.png
 
ok fixed (edited)

also you misconfigured position of teleporter for the second entry in the table
(can't be the same as first, and you don't need to set any actionid on the teleporter - just configure its position correctly).

oh, and you'll have to configure all positions again.
 
Ok, I did teleport without destination(map editor)
16:34 You see a magic forcefield.
You can see the other side through it.
ItemID: [1387]
Position: [X: 920] [Y: 1236] [Z: 7].

And
Code:
local STORAGE_LESS, STORAGE_LESSOREQUAL, STORAGE_EQUAL, STORAGE_NOTEQUAL, STORAGE_GREATEROREQUAL, STORAGE_GREATER = 1, 2, 3, 4, 5, 6

local t = {
	[
		{ -- position of teleporter
			x=920,
			y=1236,
			z=7
		}
	] = {
			15294, -- storage key
			1, -- storage value
			"set" -- action ("set"/"require")
	},

	[
		{ -- position of teleporter
			x=1004,
			y=1336,
			z=6
		}
	] = {
			15294, -- storage key
			1, -- storage value
			"require", -- action ("set"/"require")
			STORAGE_GREATEROREQUAL, -- StorageComparision
			{ x = 914, y = 1236, z = 7 } -- destination
	}
}
function onStepIn(cid, item, pos, fromPosition)
	if item.actionid > 30020 and item.actionid < 30100 then
		local townId = (item.actionid - 30020)
		doPlayerSetTown(cid, townId)
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You are the newest resident of " .. getTownName(townId) .. ".")
	else
		for _pos, sk in pairs(t) do
			if pos.x == _pos.x and pos.y == _pos.y and pos.z == _pos.z then
				if sk[3] == "set" then
					setPlayerStorageValue(cid, sk[1], sk[2])
				elseif sk[3] == "require" and sk[4] and sk[4] >= 1 and sk[4] <= 6 and type(sk[5]) == "table" then
					local c, k, v = sk[4], getPlayerStorageValue(cid, sk[1]), sk[2]
					doTeleportThing(cid, ((c == 1 and k < v) or (c == 2 and k <= v) or (c == 3 and k == v) or (c == 4 and k ~= v) or (c == 5 and k >= v) or (c == 6 and k > v)) and sk[5] or fromPosition)
				end
				return true
			end
		end
	end
end

But teleport doesn't work:( when I stepin there is no action
 
No, "set" means that it'll set your storage value to x, not teleport you somewhere. Just look what the script does and don't complain that it doesn't work - it's a multi-purpose script.
 
Maybe I'll show what I want to do
inq228.png


And i configured script:
Code:
local STORAGE_LESS, STORAGE_LESSOREQUAL, STORAGE_EQUAL, STORAGE_NOTEQUAL, STORAGE_GREATEROREQUAL, STORAGE_GREATER = 1, 2, 3, 4, 5, 6

local t = {
	[
		{ -- position of teleporter
			x=920,
			y=1236,
			z=7
		}
	] = {
			15294, -- storage key
			1, -- storage value
			"20001" -- action ("set"/"require")
	},

	[
		{ -- position of teleporter
			x=1004,
			y=1336,
			z=6
		}
	] = {
			15294, -- storage key
			1, -- storage value
			"20001", -- action ("set"/"require")
			STORAGE_GREATEROREQUAL, -- StorageComparision
			{ x = 914, y = 1236, z = 7 } -- destination
	}
}
function onStepIn(cid, item, pos, fromPosition)
	if item.actionid > 30020 and item.actionid < 30100 then
		local townId = (item.actionid - 30020)
		doPlayerSetTown(cid, townId)
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You are the newest resident of " .. getTownName(townId) .. ".")
	else
		for _pos, sk in pairs(t) do
			if pos.x == _pos.x and pos.y == _pos.y and pos.z == _pos.z then
				if sk[3] == "set" then
					setPlayerStorageValue(cid, sk[1], sk[2])
				elseif sk[3] == "require" and sk[4] and sk[4] >= 1 and sk[4] <= 6 and type(sk[5]) == "table" then
					local c, k, v = sk[4], getPlayerStorageValue(cid, sk[1]), sk[2]
					doTeleportThing(cid, ((c == 1 and k < v) or (c == 2 and k <= v) or (c == 3 and k == v) or (c == 4 and k ~= v) or (c == 5 and k >= v) or (c == 6 and k > v)) and sk[5] or fromPosition)
				end
				return true
			end
		end
	end
end
I wrote postion of left TP and actionID but there is no reaction when i stepin teleport
 
Back
Top