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

Door/Tile script help.

Skylinx

Game Programmer
Joined
Nov 26, 2008
Messages
399
Reaction score
15
Location
TORONTO, CANADA
Hey, so I'm trying to make it so a door or tile can only be passed through once, after that, the player can never go through it again.
I'm using this script :
But it doesn't seem to work and I don't know how to implement it. I set the action ID I want on the door, but where do I put the script?

Code:
-- level doors based on actionId
-- to make door for level x create door on map and set its actionid to x+1000
 
function onUse(cid, item, frompos, item2, topos)
	reqlevel = item.actionid - 1000 -- actionids below 100 are reserved
        storage = XXXX  
 
	if reqlevel > 0 then
		if getPlayerLevel(cid) >= reqlevel and if(getPlayerStorageValue(cid, storage) >= 1 then
			pos = getPlayerPosition(cid)
                        setPlayerStorageValue(cid, storage, 1)
			if pos.x == topos.x then
				if pos.y < topos.y then
					pos.y = topos.y + 1
				else
					pos.y = topos.y - 1
				end
			elseif pos.y == topos.y then
				if pos.x < topos.x then
					pos.x = topos.x + 1
				else
					pos.x = topos.x - 1
				end
			else
				doPlayerSendTextMessage(cid,22,'Stand in front of the door.')
				return 1
			end
 
			doTeleportThing(cid,pos)
			doSendMagicEffect(topos,12)
		else
			doPlayerSendTextMessage(cid,22,'You need level ' .. reqlevel .. ' to pass this door and not passed it before.')
		end
		return 1
	else
		return 0
	end
end
 
This script should be placed in actions/scripts

If you want the player to go trough it only once, use this code:
LUA:
-- level doors based on actionId
-- to make door for level x create door on map and set its actionid to x+1000
-- Adapted by Ramirow (Otland.net)
 
function onUse(cid, item, frompos, item2, topos)
	reqlevel = item.actionid - 1000 -- actionids below 1000 are reserved
        storage = 2500
 
	if reqlevel > 0 then
		if getPlayerLevel(cid) >= reqlevel and if(getPlayerStorageValue(cid, storage) >= 1 then
			pos = getPlayerPosition(cid)
                        setPlayerStorageValue(cid, storage, 1)
				if pos.x == topos.x then
					if pos.y < topos.y then
					pos.y = topos.y + 1
					else
					pos.y = topos.y - 1
					end
					elseif pos.y == topos.y then
				if pos.x < topos.x then
					pos.x = topos.x + 1
				else
					pos.x = topos.x - 1
				end
			else
				doPlayerSendTextMessage(cid,22,'Stand in front of the door.')
				return 1
			end
			doTeleportThing(cid,pos)
			doSendMagicEffect(topos,12)
		else
			doPlayerSendTextMessage(cid,22,'You need level ' .. reqlevel .. ' to pass this door and not passed it before.')
		end
		return 1
	else
		return 0
	end
end

I hope this works for you! :D
 
[26/06/2012 15:40:33] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/other/doortest.lua)
[26/06/2012 15:40:33] data/actions/scripts/other/doortest.lua:10: unexpected symbol near 'if'
 
PHP:
-- level doors based on actionId
-- to make door for level x create door on map and set its actionid to x+1000
-- Adapted by Ramirow (Otland.net)
 
function onUse(cid, item, frompos, item2, topos)
	reqlevel = item.actionid - 1000 -- actionids below 1000 are reserved
        storage = 2500

		if getPlayerLevel(cid) >= reqlevel and if(getPlayerStorageValue(cid, storage) >= 1 then
			pos = getPlayerPosition(cid)
                        setPlayerStorageValue(cid, storage, 1)
				if pos.x == topos.x then
					if pos.y < topos.y then
					pos.y = topos.y + 1
					else
					pos.y = topos.y - 1
					end
					elseif pos.y == topos.y then
				if pos.x < topos.x then
					pos.x = topos.x + 1
				else
					pos.x = topos.x - 1
				end
			else
				doPlayerSendTextMessage(cid,22,'Stand in front of the door.')
				return 1
			end
			doTeleportThing(cid,pos)
			doSendMagicEffect(topos,12)
		else
			doPlayerSendTextMessage(cid,22,'You need level ' .. reqlevel .. ' to pass this door and not passed it before.')
		end
		return 1
	else
		return 0
	end
end

try this
 
[27/06/2012 22:14:52] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/other/doortest.lua)
[27/06/2012 22:14:52] data/actions/scripts/other/doortest.lua:9: unexpected symbol near 'if'
Same error, different line. Well technically the same, it's just you removed
Code:
if reqlevel > 0 then


Ok, Now I'm just making a tile.

Code:
function onStepIn(cid, item, position, fromPos, fromPosition)
	storage = 2500
	     if(getPlayerStorageValue(cid, storage) >= 1 then
	setPlayerStorageValue(cid, storage, 1)
	doSendMagicEffect(getCreaturePosition(cid), CONST_ME_FIREWORK_RED)
        doPlayerSendTextMessage(cid, 27, "You have entered the lair of Hokar.")
	doCreatureSay(cid, "How dare you enter my lair?!", TALKTYPE_MONSTER)

	     else
	doTeleportThing(cid, fromPosition, true)
	doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
        doPlayerSendTextMessage(cid, 27, "You have already tried entering this realm once. Your very soul has been banished from this room. ")

	end
end

But I get

[27/06/2012 22:26:26] [Error - LuaScriptInterface::loadFile] data/actions/scripts/other/tilepassonlyonce.lua:8: ')' expected near 'then'
[27/06/2012 22:26:26] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/other/tilepassonlyonce.lua)
[27/06/2012 22:26:26] data/actions/scripts/other/tilepassonlyonce.lua:8: ')' expected near 'then'
 
Last edited:
[27/06/2012 22:14:52] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/other/doortest.lua)
[27/06/2012 22:14:52] data/actions/scripts/other/doortest.lua:9: unexpected symbol near 'if'
Same error, different line. Well technically the same, it's just you removed
Code:
if reqlevel > 0 then


Ok, Now I'm just making a tile.

Code:
function onStepIn(cid, item, position, fromPos, fromPosition)
	storage = 2500
	     if(getPlayerStorageValue(cid, storage) >= 1 then
	setPlayerStorageValue(cid, storage, 1)
	doSendMagicEffect(getCreaturePosition(cid), CONST_ME_FIREWORK_RED)
        doPlayerSendTextMessage(cid, 27, "You have entered the lair of Hokar.")
	doCreatureSay(cid, "How dare you enter my lair?!", TALKTYPE_MONSTER)

	     else
	doTeleportThing(cid, fromPosition, true)
	doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
        doPlayerSendTextMessage(cid, 27, "You have already tried entering this realm once. Your very soul has been banished from this room. ")

	end
end

But I get

[27/06/2012 22:26:26] [Error - LuaScriptInterface::loadFile] data/actions/scripts/other/tilepassonlyonce.lua:8: ')' expected near 'then'
[27/06/2012 22:26:26] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/other/tilepassonlyonce.lua)
[27/06/2012 22:26:26] data/actions/scripts/other/tilepassonlyonce.lua:8: ')' expected near 'then'

LUA:
function onStepIn(cid, item, position, fromPos, fromPosition)
	storage = 2500
	     if getPlayerStorageValue(cid, storage) >= 1 then
	setPlayerStorageValue(cid, storage, 1)
	doSendMagicEffect(getCreaturePosition(cid), CONST_ME_FIREWORK_RED)
        doPlayerSendTextMessage(cid, 27, "You have entered the lair of Hokar.")
	doCreatureSay(cid, "How dare you enter my lair?!", TALKTYPE_MONSTER)

	     else
	doTeleportThing(cid, fromPosition, true)
	doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
        doPlayerSendTextMessage(cid, 27, "You have already tried entering this realm once. Your very soul has been banished from this room. ")

	end
end

You had this :
LUA:
if(getPlayerStorageValue
 
Back
Top