• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Solved Level Tile for players over 50

Akkz

New Member
Joined
Apr 22, 2012
Messages
172
Reaction score
0
Hello ;) Im trying to learn how to scripting, and what I trying to do is a tile that if you are below level 50 you can enter
Code:
function onStepIn(cid, item, frompos, itemEx, topos)
        if item.uniqueid == 1234 then
		   getPlayerLevel(cid) > 50 then 
		   doPlayerSendTextMessage(cid,21,"It works !")

	elseif getPlayerLevel(cid) < 50 then
	       doPlayerSendCancel(cid,21,"You need to be below level 50.")
		 	 
  return true
		 
end
I get this error in console
Code:
[Error - LuaScriptInterface::loadFile] data/movements/scripts/test.lua:3: unexpe
cted symbol near '>'
[Warning - Event::loadScript] Cannot load script (data/movements/scripts/test.lu
a)
data/movements/scripts/test.lua:3: unexpected symbol near '>'
 
Solution
uid... screw that.

LUA:
function onStepIn(cid, item, frompos, itemEx, topos)
	if getPlayerLevel(cid) < 50 then 
		doPlayerSendTextMessage(cid, "Access granted.")
	else
		doPlayerSendCancel(cid, "You need to be below level 50 to gain access.")
		doTeleportThing(cid, frompos, true)
	end
	return true
end
getPlayerLevel(cid) > 50 then <-- this is the problem it have to be if getPlayerLevel(cid) > 50 then

Also use isPlayer(cid) to prevent errors when monster steps into the tile.

LUA:
function onStepIn(cid, item, frompos, itemEx, topos)
		if isPlayer(cid) and item.uniqueid == 1234 then
			if getPlayerLevel(cid) > 50 then 
				doPlayerSendTextMessage(cid,21,"It works !")
			elseif getPlayerLevel(cid) < 50 then
				doPlayerSendCancel(cid,21,"You need to be below level 50.")
			end
		return true		 
	end
end

Also you can do this:
LUA:
function onStepIn(cid, item, frompos, itemEx, topos)
		if isPlayer(cid) and item.uniqueid == 1234 then
			if getPlayerLevel(cid) > 50 then 
				doPlayerSendTextMessage(cid,21,"It works !")
			else
				doPlayerSendCancel(cid,21,"You need to be below level 50.")
			end
		return true		 
	end
end

Enjoy!
 
Last edited:
that's what it said before, but ehm... the script still not working, becouse when I walk on a tile with UID 1234 it doesn't do anything
Code:
[Warning - Event::loadScript] Cannot load script (data/movements/scripts/test.lu
a)
data/movements/scripts/test.lua:12: 'end' expected (to close 'if' at line 2) nea
r '<eof>'
 
LUA:
function onStepIn(cid, item, frompos, itemEx, topos)
		if isPlayer(cid) and item.uid == 1234 then
			if getPlayerLevel(cid) < 50 then 
				doPlayerSendTextMessage(cid,21,"It works !")
			else
				doPlayerSendCancel(cid,21,"You need to be below level 50.")
			end
		end
		return true		 
	end
end

It is .uid not .uniqueid. ;)
 
Try and this item set actionid on the tile:

LUA:
local otswe_actionid = 1234

function onStepIn(cid, item, frompos, itemEx, topos)
	if item.actionid == otswe_actionid then
		if isPlayer(cid) and getPlayerLevel(cid) >= 50 then 
			doPlayerSendTextMessage(cid,21,"It works !")
		else
			doPlayerSendCancel(cid,21,"You need to be below level 50.")
			end
		return true		 
	end
end
 
Okey! Now it tells me it works! but I want to, if you are over level 50 you cannot walk on that tile, but now it's possible :/
 
LUA:
function onStepIn(cid, item, frompos, itemEx, topos)
		if isPlayer(cid) and item.uid == 1234 then
			if getPlayerLevel(cid) < 50 then 
				doPlayerSendTextMessage(cid,21,"It works !")
			else
				doPlayerSendCancel(cid,21,"You need to be below level 50.")
				doTeleportThing(cid, frompos)
			end
		end
		return true		 
	end
end
 
Try:
LUA:
local otswe_uid = 1234
 
function onStepIn(cid, item, frompos, itemEx, topos)
	if item.uid == otswe_uid then
		if isPlayer(cid) and getPlayerLevel(cid) <= 49 then 
			doPlayerSendTextMessage(cid,21,"It works !")
		else
			doPlayerSendCancel(cid, "Sorry not possible")
                        doTeleportThing(cid, frompos, false)
			end
		return true		 
	end
end
 
Last edited:
sorry cyko but I wants it to be UID not AID,
[Error - MoveEvents Interface]
data/movements/scripts/test.lua:onStepIn
Description:
(luaDoPlayerSendCancel) Player not found
 
Ok try now. edited post

- - - Updated - - -

FFS saw the problem now xD this is right: doPlayerSendCancel(cid, "Sorry not possible")
and this is wrong: doPlayerSendCancel(cid, 21, "Sorry not possible")
 
ok now xD

LUA:
local otswe_uid = 1234
 
function onStepIn(cid, item, frompos, itemEx, topos)
	if item.uid == otswe_uid then
		if isPlayer(cid) and getPlayerLevel(cid) <= 49 then 
			doPlayerSendCancel(cid, "Sorry not possible")
                        doTeleportThing(cid, frompos, false)
		else
                        doPlayerSendTextMessage(cid,21,"It works !")
			end
		return true		 
	end
end
 
Back
Top