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

A script that teleports you after a certain level.

frankfarmer

who'r ninja now
Premium User
Joined
Aug 5, 2008
Messages
1,644
Solutions
1
Reaction score
99
Hello Otlanders.

I want a script, when a player reaches level.. 14. Then the player will be teleported to a new location on the map, with a new TownID.

I want to use this for my war-server, so that there is different islands for different levels.

Anyone knows how it could be made very simple and easy?
 
Code:
local islands = {
	-- level => town
	[15] = 1,
	[50] = 2
}

function onAdvance(cid, skill, oldLevel, newLevel)
	for level, town in ipairs(islands) do
		if(newLevel == level) then
			doTeleportThing(cid, getTownTemplePosition(town))
		end
	end

	return true
end

repp++
 
aaaa ;! thenks

(1 more fix included)
Code:
local islands = {
	-- level => town
	[15] = 1,
	[50] = 2
}

function onAdvance(cid, skill, oldLevel, newLevel)
	if(skill == SKILL__LEVEL) then
		for level, town in ipairs(islands) do
			if(oldLevel < level and newLevel >= level) then
				doTeleportThing(cid, getTownTemplePosition(town))
				break
			end
		end
	end

	return true
end
 
Shit, it does not work.. Players reach level 15, but they don't get teleported :S

Code:
local islands = {
	-- level => town
	[15] = 2,
	[50] = 3
}

function onAdvance(cid, skill, oldLevel, newLevel)
	if(skill == SKILL__LEVEL) then
		for level, town in ipairs(islands) do
			if(oldLevel < level and newLevel >= level) then
				doTeleportThing(cid, getTownTemplePosition(town))
				break
			end
		end
	end

	return true
end

Code:
	registerCreatureEvent(cid, "teleportlevel")


Code:
	<event type="advance" name="teleportlevel" event="script" value="teleportlevel.lua"/>
 
Code:
local towns = {
   -- Level & Town --
	[15] = 1,
	[25] = 2
    }
function onAdvance(cid, skill, oldLevel, newLevel)
	if(skill == SKILL__LEVEL) then
		for lvl, town in ipairs(towns) do
			if(newLevel == lvl) then
				doTeleportThing(cid, getTownTemplePosition(town))
                                break
			end
		end
	end
	return true
end
 
Last edited:
Code:
local towns = {
   -- Level & Town --
	15 = 1,
	25 = 2
    }
function onAdvance(cid, skill, oldLevel, newLevel)
	if(skill == SKILL__LEVEL) then
		for lvl, town in ipairs(towns) do
			if(newLevel == lvl) then
				doTeleportThing(cid, getTownTemplePosition(town))
                                break
			end
		end
	end
	return true
end
input:3: '}' expected (to close '{' at line 1) near '='

:D you need to put the first numbers (on left) inside brackets [], because they should be table indexes.
 
Code:
local towns = {
   -- Level & Town --
	[15] = 1,
	[25] = 2
    }
function onAdvance(cid, skill, oldLevel, newLevel)
	if(skill == SKILL__LEVEL) then
		for lvl, town in ipairs(towns) do
			if(newLevel == lvl) then
				doTeleportThing(cid, getTownTemplePosition(town))
                                break
			end
		end
	end
	return true
end

what if player advance from 14 to 16? :peace:

Now I'm going to test my script (it must work :|)
 
Back
Top