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

Door script {Request hard}

LucasFerraz

Systems Analyst
Joined
Jun 10, 2010
Messages
2,857
Reaction score
96
Location
Brazil
I need this script:

Player inside room can go out by a door IF have storage ID.
Players with or without this storage can't enter to the room again.

This is the room
doorp.jpg
 
I remember in OTs 7.5 (old old times, evolutions.exe). I remember that scripts but i lost it.
I know it's possible with a simple script but I can't do that.
 
Code:
function onUse(cid, item, frompos, item2, topos) 
 
local config = {
porta_fechada = 5748, -- id door locked 
porta_aberta = 5749, -- id open door
storage = 8010 -- storage ID
} 
  
if getPlayerStorageValue(cid, config.storage) <= 0 then
return doPlayerSendCancel(cid, "You dont have storage ID.")
elseif getPlayerStorageValue(cid, 91245) >= 1 then
return doPlayerSendCancel(cid, "you can't enter to the room again.")
end
if item.itemid == config.porta_fechada then 
doTransformItem(item.uid,config.porta_aberta) 
elseif item.itemid == config.porta_aberta then 
doTransformItem(item.uid,config.porta_fechada) 
end
setPlayerStorageValue(cid, 91245, 1)
return TRUE 
end
 
are u trying to make the script so when ur a certain level u can go through doors and once u do u can never go back after u leave or just any level?
 
So you don't get trapped in the room, you can always leave by using the door.

But you can only go in once.
 
I made this using Critico's script.

LUA:
 function onUse(cid, item, frompos, item2, topos)
 

local config = {
porta_fechada = 1255, -- id door locked 
porta_aberta = 1256, -- id open door
storage = 9134 -- storage ID
} 
local pos = {x=579, y=608, z=7}

if getPlayerStorageValue(cid, config.storage) <= 0 then
return doPlayerSendCancel(cid, "You have to finish the Quest to pass this door.")
elseif getPlayerStorageValue(cid, 54669) >= 1 then
return doPlayerSendCancel(cid, "You cant enter to the room again.")
end
if item.itemid == config.porta_fechada then 
doTeleportThing(cid,pos)
doSendMagicEffect(getCreaturePosition(cid),10)
elseif item.itemid == config.porta_aberta then 
doTransformItem(item.uid,config.porta_fechada) 
end
setPlayerStorageValue(cid, 54669, 1)
return TRUE 
end
 
LUA:
	local p = getCreaturePosition(cid)
	if getCreatureStorage(cid, storage) < 0 then
If the storage requirement isn't met, getCreaturePosition will still be called even though the variable won't be used. Swap the two lines.

Besides, you could've used this:
LUA:
if getCreaturePosition(cid).x < toPosition.x then
 
My script is working now but is too long S:

LUA:
 function onUse(cid, item, frompos, item2, topos)
 
 
local config = {
porta_fechada = 1255, -- id door locked 
porta_aberta = 1256, -- id open door
storage = 9134 -- storage ID
} 
local pos = {x=579, y=608, z=7}
 
if getPlayerStorageValue(cid, config.storage) <= 0 then
return doPlayerSendCancel(cid, "You have to finish the Quest to pass this door.")
elseif getPlayerStorageValue(cid, 54669) >= 1 then
return doPlayerSendCancel(cid, "You cant enter to the room again.")
end
if item.itemid == config.porta_fechada then 
doTeleportThing(cid,pos)
doSendMagicEffect(getCreaturePosition(cid),10)
elseif item.itemid == config.porta_aberta then 
doTransformItem(item.uid,config.porta_fechada) 
end
setPlayerStorageValue(cid, 54669, 1)
return TRUE 
end
 
If the storage requirement isn't met, getCreaturePosition will still be called even though the variable won't be used. Swap the two lines.

Besides, you could've used this:
LUA:
if getCreaturePosition(cid).x < toPosition.x then

Ah okay, thanks for the tip.

LUA:
local storage = 12345
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if getCreatureStorage(cid, storage) < 0 then
		if getCreaturePosition(cid).x < toPosition.x then
			doTeleportThing(cid, { x = toPosition.x + 1, y = toPosition.y, z = toPosition.z }, true)
		else
			doTeleportThing(cid, { x = toPosition.x - 1, y = toPosition.y, z = toPosition.z }, true)
		end
	else
		doPlayerSendCancel(cid, "Sorry, not possible.")
	end
 
	return true
end
 
Back
Top