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

Action Teleport To Temple Scroll

GangsteR

RPG Maker
Joined
Jul 1, 2007
Messages
815
Reaction score
2
Location
Turkiye
Hi all!
I created new script!
When you use this scroll you will teleport to temple (or anywhere:p).
P.S: I am newbie at scripting! ;)

Create TPScroll.lua at your actions/scripts folder and copy this;
Just edit temple coords :thumbup: (if you want you can edit level and itemid too :p)

PHP:
local scroll = 6119
local temple = {x=xxx, y=xxx, z=x}
local level = 25

function onUse(cid, item, frompos, item2, topos)
    if item.itemid == scroll and getPlayerLevel(cid) >= level then
        doTeleportThing(cid, temple, TRUE)
        doSendMagicEffect(temple,10)
        doSendAnimatedText(temple, "You are in temple!", 5)
        doRemoveItem(cid, item.uid, 1)
    else
        doPlayerSendCancel(cid, "Sorry, your level must higher than 25!")
    end
return 1
end
And finally add this to actions.xml

Code:
<action itemid="6119" script="TPScroll.lua"/>
Comments are welcome! :thumbup:
 
TFS 0.3
Code:
function onUse(cid, item)
	if hasCondition(cid, CONDITION_INFIGHT) == TRUE then
		doPlayerSendCancel(cid, "You may not use this scroll while in-fight!")
		return FALSE
	end
	
	doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
	doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), FALSE)
	doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
	return TRUE
end

It will teleport you to your temple.
 
Try with this, I dont have 0.2 :mad:

data/functions.lua:
Code:
function getTownTemplePosition(townId)
	local towns = {
		[1] = { x = 100, y = 100, z = 7 },
		[2] = { x = 120, y = 130, z = 6 }
	}
	
	for k, v in pairs(towns) do
		if townId == k then
			return { v[1], v[2], v[3] }
		else
			return debugPrint("[GetTownTemplePosition]: Town not found.")
		end
	end
end
 
Why you write keys, not needed o.o

+ it's ipairs you should use x)

and in ur loop k[1], k[2], k[3] is nil :) you meant k.x or k["x"] but preferably just v :)

Code:
function getTownTemplePosition(townId)
	local towns = {
		{ x = 100, y = 100, z = 7 },
		{ x = 120, y = 130, z = 6 }
	}
	
	for k, v in ipairs(towns) do
		if townId == k then
			return v
		else
			return debugPrint("[GetTownTemplePosition]: Town not found.")
		end
	end
end
 
Why you write keys, not needed o.o

+ it's ipairs you should use x)

and in ur loop k[1], k[2], k[3] is nil :) you meant k.x or k["x"] but preferably just v :)

Code:
function getTownTemplePosition(townId)
	local towns = {
		{ x = 100, y = 100, z = 7 },
		{ x = 120, y = 130, z = 6 }
	}
	
	for k, v in ipairs(towns) do
		if townId == k then
			return v
		else
			return debugPrint("[GetTownTemplePosition]: Town not found.")
		end
	end
end

Okej, tank is you mi master :):):)
 
Hi masters, is this loop reeeeealy needed here? ; DD

return towns[townId] ~= nil and towns[townId] or LUA_ERROR
 
Hi masters, is this loop reeeeealy needed here? ; DD

return towns[townId] ~= nil and towns[townId] or LUA_ERROR

I only correct noobishness x) But I missed quite some noobishness o.o

elseif in loop -.- smartass x)
 
Last edited:
lol, simply something it:
PHP:
function getTownTemplePosition(townId)
	local towns = {
		[1] = { x = 100, y = 100, z = 7 },
		[2] = { x = 120, y = 130, z = 6 }
	}
	if towns[townId] then
		return towns[townid]
	end
end
 
lol, simply something it:
PHP:
function getTownTemplePosition(townId)
	local towns = {
		[1] = { x = 100, y = 100, z = 7 },
		[2] = { x = 120, y = 130, z = 6 }
	}
	if towns[townId] then
		return towns[townid]
	end
end

yeah but more efficient to place it outside of the functions and possibly inside of a do-block ;>

Like
PHP:
do
	local towns = {
		[1] = { x = 100, y = 100, z = 7 },
		[2] = { x = 120, y = 130, z = 6 }
	}

	function getTownTemplePosition(townId)
		if(type(townId) ~= 'number') then
			error("luaGetTownTemplePosition: Expecting number for 'townId' (got " .. type(townId) .. ")", 2)
		end

		return towns[townId] or LUA_ERROR
	end
end
 
could u make that when u use the tpscroll appears a box naming the towns that u want to travel. its seem like a bit dificult my question but its not allways imposible.
 
could u make that when u use the tpscroll appears a box naming the towns that u want to travel. its seem like a bit dificult my question but its not allways imposible.


srry for doble post idk wtf happen?
 
"Lua Script Error: [Action Interface]
data/actions/scripts/tpscroll.lua:eek:nUse

attempt to index a number value"


What is wrong? :(
 
Back
Top