• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Action Teleportal Wand

Zysen

=)
Joined
Sep 18, 2010
Messages
2,270
Reaction score
170
Location
Bosnia & Herzegovina
Features


  • Use the wand,and a teleport creates

LUA Script

data/actions/other/wand.lua

LUA:
--Credits: Zysen @OtLand--

local ppos = getPlayerPosition(cid)
local temple = {x=1000, y=1000, z=7} ---edit this to your temple position

function onUse(cid, item, frompos, item2, topos)
	if item.actionid == 7415 and getPlayerLevel(cid) >= 50 then
    doPlayerAddItem(cid, 7410, 1) 
   doCreateTeleport(itemid, temple, ppos - 1)
      doSendMagicEffect(ppos, 34)
    doSendAnimatedText(playerpos,"Teleport created.", 172) 
	else
		doPlayerSendCancel(cid,"You don't have the required level to use this.")
	end
	return TRUE
end

actions.xml

XML:
	<action itemid="7415" script="other/wand.lua"/>

NOTE: I only tested it in my console and i didn't get any errors (TFS 0.2.8)



Regards,
Zysen
 
Last edited:
You can get the player temple position with this function
getTownTemplePosition(getPlayerTown(cid))
 
Alot of errors and it won't work, test before releasing.
And don't you think the teleport should be removed after like, 10 seconds?
 
LUA:
--Credits: Zysen @OtLand--
 
local ppos = getPlayerPosition(cid)
local temple = {x=1000, y=1000, z=7} ---edit this to your temple position
 
function onUse(cid, item, frompos, item2, topos)
	if item.actionid == 7415 and getPlayerLevel(cid) >= 50 then
    doPlayerAddItem(cid, 7410, 1) 
   doItemSetAttribute(doCreateTeleport(1387, temple, ppos - 1), 'uid', xxxx)
      doSendMagicEffect(ppos, 34)
    doSendAnimatedText(playerpos,"Teleport created.", 172) 
	else
		doPlayerSendCancel(cid,"You don't have the required level to use this.")
	end
	return TRUE
end

Now just make in movements a stepIn function that removes the TP with the UID you put here:
LUA:
doItemSetAttribute(doCreateTeleport(1387, temple, ppos - 1), 'uid', xxxx)
Or make an addEvent(doRemove.., but its harder.
 
LUA:
local config, tps = {
	secsToRemove = 15,
	createInPZ = false,
	tpID = 1387,
	level = 50,
	onePortalPerPlayer = false,
	temple = {x=100, y=100, z=7} -- set it to false if you want it to teleport to player's temple pos
}, {}

local function remove(pos, guid)
	if config.onePortalPerPlayer then
		for i = 1, #tps do
			if tps[i] == guid then
				table.remove(tps, i)
				break
			end
		end
	end
	local item = getTileItemById(pos, config.tpID).uid
	return item > 0 and doRemoveItem(item)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if getPlayerLevel(cid) >= config.level then
		local guid = getPlayerGUID(cid)
		if not config.onePortalPerPlayer or not isInArray(tps, guid) then
			toPosition.stackpos = 0
			if not isInArray({0,65535}, toPosition.x) and (config.createInPZ or not getTileInfo(toPosition).protection) and not hasItemProperty(getTileThingByPos(toPosition).uid, CONST_PROP_BLOCKSOLID) and queryTileAddThing(cid, toPosition) == RETURNVALUE_NOERROR and getTileItemByType(toPosition, ITEM_TYPE_TELEPORT).uid == 0 then
				doCreateTeleport(config.tpID, type(config.temple) == 'table' and config.temple or getTownTemplePosition(getPlayerTown(cid)), toPosition)
				if config.onePortalPerPlayer then
					table.insert(tps, guid)
				end
				addEvent(remove, config.secsToRemove * 1000, toPosition, guid)
				doSendMagicEffect(toPosition, CONST_ME_GROUNDSHAKER)
				doCreatureSay(cid, 'Teleport created', TALKTYPE_ORANGE_1)
			else
				doPlayerSendCancel(cid, "You can't create a teleport here.")
			end
		else
			doPlayerSendCancel(cid, "You already have an active teleport.")
		end
	else
		doPlayerSendCancel(cid, "You don't have the required level (" .. config.level .. ") to use this.")
	end
	return true
end
 
cyko u can creat for can use in X minutes,only use passed 5 minutes.

Srry for my english
 
didint know 0.2.8 had this function
LUA:
   doCreateTeleport(itemid, temple, ppos - 1)
Very good thanks ! :)
 
LUA:
local config, tps = {
	secsToRemove = 15,
	createInPZ = false,
	tpID = 1387,
	level = 50,
	onePortalPerPlayer = false,
	temple = {x=100, y=100, z=7} -- set it to false if you want it to teleport to player's temple pos
}, {}

local function remove(pos, guid)
	if config.onePortalPerPlayer then
		for i = 1, #tps do
			if tps[i] == guid then
				table.remove(tps, i)
				break
			end
		end
	end
	local item = getTileItemById(pos, config.tpID).uid
	return item > 0 and doRemoveItem(item)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if getPlayerLevel(cid) >= config.level then
		local guid = getPlayerGUID(cid)
		if not config.onePortalPerPlayer or not isInArray(tps, guid) then
			toPosition.stackpos = 0
			if not isInArray({0,65535}, toPosition.x) and (config.createInPZ or not getTileInfo(toPosition).protection) and not hasItemProperty(getTileThingByPos(toPosition).uid, CONST_PROP_BLOCKSOLID) and queryTileAddThing(cid, toPosition) == RETURNVALUE_NOERROR and getTileItemByType(toPosition, ITEM_TYPE_TELEPORT).uid == 0 then
				doCreateTeleport(config.tpID, type(config.temple) == 'table' and config.temple or getTownTemplePosition(getPlayerTown(cid)), toPosition)
				if config.onePortalPerPlayer then
					table.insert(tps, guid)
				end
				addEvent(remove, config.secsToRemove * 1000, toPosition, guid)
				doSendMagicEffect(toPosition, CONST_ME_GROUNDSHAKER)
				doCreatureSay(cid, 'Teleport created', TALKTYPE_ORANGE_1)
			else
				doPlayerSendCancel(cid, "You can't create a teleport here.")
			end
		else
			doPlayerSendCancel(cid, "You already have an active teleport.")
		end
	else
		doPlayerSendCancel(cid, "You don't have the required level (" .. config.level .. ") to use this.")
	end
	return true
end
Cyko, can you make it say time (seconds) left over the TP and let it done only once per minute (60 secs) (Exhaust = 60 seconds) ????
 
Back
Top