ond
Veteran OT User
I wonder if, first if it's possible, and if someone could help me fix my key-door script. I want it to get locked again if someone uses the key on it after opening it up 
For dumb people:
When you unlock door with key -> close the door -> it's still open -> it should only get locked if you use the key on it again
Here is my scripts:
Kind of simpile. I think these are the scripts for it. Help me!
For dumb people:
When you unlock door with key -> close the door -> it's still open -> it should only get locked if you use the key on it again
Here is my scripts:
LUA:
--keys--
function onUse(cid, item, frompos, item2, topos)
if item.actionid > 0 and item.actionid == item2.actionid then
match = 1
else
match = 0
end
if item2.itemid == 1210 or
item2.itemid == 1213 or
item2.itemid == 1219 or
item2.itemid == 1221 or
item2.itemid == 1223 or
item2.itemid == 1225 or
item2.itemid == 1227 or
item2.itemid == 1229 or
item2.itemid == 1232 or
item2.itemid == 1235 or
item2.itemid == 1237 or
item2.itemid == 1239 or
item2.itemid == 1241 or
item2.itemid == 1243 or
item2.itemid == 1245 or
item2.itemid == 1247 or
item2.itemid == 1250 or
item2.itemid == 1253 or
item2.itemid == 1255 or
item2.itemid == 1257 or
item2.itemid == 1249 or
item2.itemid == 1261 then
if match == 1 then
doTransformItem(item2.uid,item2.itemid+1)
else
doPlayerSendCancel(cid,"The key does not match.")
end
elseif item2.itemid == 1209 or
item2.itemid == 1212 or
item2.itemid == 1231 or
item2.itemid == 1234 or
item2.itemid == 1249 or
item2.itemid == 1252 then
if match == 1 then
doTransformItem(item2.uid,item2.itemid+2)
else
doPlayerSendCancel(cid,"The key does not match.")
end
else
return 0
end
end
LUA:
function onUse(cid, item, frompos, item2, topos)
if(item.actionid == 0) then
-- This is impossible to happen, but whatever.
doTransformItem(item.uid, item.itemid+2)
return TRUE
end
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "It is locked.")
return TRUE
end
LUA:
function onUse(cid, item, frompos, item2, topos)
-- Are we on pz?
local isPz = (getTilePzInfo(frompos) == 1)
-- Get the tile to move the things on the door to
local nextTile = {x=frompos.x, y=frompos.y+1, z=frompos.z}
if(isPz and getTilePzInfo(nextTile) == 0) then
nextTile.y = frompos.y-1
end
-- Move all moveable things to the next tile
doRelocate(frompos, nextTile)
-- Transform the door
doTransformItem(item.uid, item.itemid-1)
return TRUE
end
LUA:
function onUse(cid, item, frompos, item2, topos)
-- Are we on pz?
local isPz = (getTilePzInfo(frompos) == 1)
-- Get the tile to move the things on the door to
local nextTile = {x=frompos.x+1, y=frompos.y, z=frompos.z}
if(isPz and getTilePzInfo(nextTile) == 0) then
nextTile.x = frompos.x-1
end
-- Move all moveable things to the next tile
doRelocate(frompos, nextTile)
-- Transform the door
doTransformItem(item.uid, item.itemid-1)
return TRUE
end
LUA:
-- ActionIDs:
-- 1001~1999: Level doors(level is actionID-1000)
-- 2001~2008: Vocation doors(voc is ActionID-2000. 1:Sorcerer, 2:Druid, 3:Paladin, 4:Knight, 5:MS, 6:ED, 7:RP, 8:EK)
function onUse(cid, item, frompos, item2, topos)
local isLevelDoor = (item.actionid >= 1001 and item.actionid <= 1999)
local isVocationDoor = (item.actionid >= 2001 and item.actionid <= 2008)
if not(isLevelDoor or isVocationDoor) then
-- Make it a normal door
doTransformItem(item.uid, item.itemid+1)
return TRUE
end
local canEnter = true
if(isLevelDoor and getPlayerLevel(cid) < (item.actionid-1000)) then
canEnter = false
end
if(isVocationDoor) then
local doorVoc = item.actionid-2000
if (doorVoc == 1 and not(isSorcerer(cid))) or
(doorVoc == 2 and not(isDruid(cid))) or
(doorVoc == 3 and not(isPaladin(cid))) or
(doorVoc == 4 and not(isKnight(cid))) or
(doorVoc ~= getPlayerVocation(cid)) then
canEnter = false
end
end
if not(canEnter or getPlayerAccess(cid) == 0) then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Only the worthy may pass.")
return TRUE
end
doTransformItem(item.uid, item.itemid+1)
local canGo = (queryTileAddThing(cid, frompos, bit.bor(2, 4)) == RETURNVALUE_NOERROR) --Veryfies if the player can go, ignoring blocking things
if not(canGo) then
return FALSE
end
local dir = getDirectionTo(getPlayerPosition(cid), frompos)
doMoveCreature(cid, dir)
return TRUE
end
LUA:
<!-- Doors -->
<action itemid="1209" script="doors/door_locked.lua"/>
<action itemid="1210" script="increment.lua"/>
<action itemid="1211" script="doors/door_open_horizontal.lua"/>
<action itemid="1212" script="doors/door_locked.lua"/>
<action itemid="1213" script="increment.lua"/>
<action itemid="1214" script="doors/door_open_vertical.lua"/>
<action itemid="1219" script="increment.lua"/>
<action itemid="1220" script="doors/door_open_horizontal.lua"/>
<action itemid="1221" script="increment.lua"/>
<action itemid="1222" script="doors/door_open_vertical.lua"/>
<action itemid="1227" script="doors/gateofexp_closed.lua"/>
<action itemid="1228" script="doors/door_open_horizontal.lua"/>
<action itemid="1229" script="doors/gateofexp_closed.lua"/>
<action itemid="1230" script="doors/door_open_vertical.lua"/>
<action itemid="1231" script="doors/door_locked.lua"/>
<action itemid="1232" script="increment.lua"/>
<action itemid="1233" script="doors/door_open_horizontal.lua"/>
<action itemid="1234" script="doors/door_locked.lua"/>
<action itemid="1235" script="increment.lua"/>
<action itemid="1236" script="doors/door_open_vertical.lua"/>
<action itemid="1237" script="increment.lua"/>
<action itemid="1238" script="doors/door_open_horizontal.lua"/>
<action itemid="1239" script="increment.lua"/>
<action itemid="1240" script="doors/door_open_vertical.lua"/>
<action itemid="1241" script="doors/questdoor_closed.lua"/>
<action itemid="1242" script="doors/door_open_horizontal.lua"/>
<action itemid="1243" script="doors/questdoor_closed.lua"/>
<action itemid="1244" script="doors/door_open_vertical.lua"/>
<action itemid="1245" script="doors/gateofexp_closed.lua"/>
<action itemid="1246" script="doors/door_open_horizontal.lua"/>
<action itemid="1247" script="doors/gateofexp_closed.lua"/>
<action itemid="1248" script="doors/door_open_vertical.lua"/>
<action itemid="1249" script="doors/door_locked.lua"/>
<action itemid="1250" script="increment.lua"/>
<action itemid="1251" script="doors/door_open_horizontal.lua"/>
<action itemid="1252" script="doors/door_locked.lua"/>
<action itemid="1253" script="increment.lua"/>
<action itemid="1254" script="doors/door_open_vertical.lua"/>
<action itemid="1255" script="doors/questdoor_closed.lua"/>
<action itemid="1256" script="doors/door_open_horizontal.lua"/>
<action itemid="1257" script="doors/questdoor_closed.lua"/>
<action itemid="1258" script="doors/door_open_vertical.lua"/>
<action itemid="1259" script="doors/gateofexp_closed.lua"/>
<action itemid="1260" script="doors/door_open_horizontal.lua"/>
<action itemid="1261" script="doors/gateofexp_closed.lua"/>
<action itemid="1262" script="doors/door_open_vertical.lua"/>
<action itemid="1539" script="increment.lua"/>
<action itemid="1540" script="doors/door_open_horizontal.lua"/>
<action itemid="1541" script="increment.lua"/>
<action itemid="1542" script="doors/door_open_vertical.lua"/>
<action itemid="1223" script="doors/questdoor_closed.lua"/>
<action itemid="1224" script="doors/door_open_horizontal.lua"/>
<action itemid="1225" script="doors/questdoor_closed.lua"/>
<action itemid="1226" script="doors/door_open_vertical.lua"/>
Last edited: