tiddpd
PHP Scripter
- Joined
- Apr 16, 2008
- Messages
- 331
- Reaction score
- 0
When you say "opensesame" the door will open. To keep it locked and only able to open with "opensesame" give the door an action id which will lock it. (This is for TFS 0.3)
Add this to talkactions.xml:
In scripts put this and name it open.lua:
You should also add this to lib/functions.lua
If you want it to close, put an action id on the floor below the door, and use this script (you have to change locations and door ids to the ones you use)
Updated as of Fed 16th, added in the teleport player function. (you will walk to the door when opensesame is said)
Add this to talkactions.xml:
Code:
<talkaction words="opensesame" script="open.lua"/>
In scripts put this and name it open.lua:
Code:
function onSay(cid, param)
local standPos = {x=459,y=199,z=7}
local doorPos = {x = 459, y = 198, z = 7, stackpos=1}
local door = getThingFromPos(doorPos)
if comparePos(getPlayerPosition(cid), standPos) then
if door.itemid == 5138 then
doTransformItem(door.uid, door.itemid + 1)
elseif comparePos(getPlayerPosition(cid), standPos) then
doCreatureAddHealth(cid, -500, force)
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
end
end
end
You should also add this to lib/functions.lua
Code:
function comparePos(pos1, pos2)
return (pos1.x == pos2.x and pos1.y == pos2.y and pos1.z == pos2.z)
end
If you want it to close, put an action id on the floor below the door, and use this script (you have to change locations and door ids to the ones you use)
Code:
function onStepIn(cid, item, position, fromPosition)
local doorPos = {x = 459, y = 198, z = 7, stackpos=1}
local door = getThingFromPos(doorPos)
if door.itemid == 5139 then
doTransformItem(door.uid, door.itemid - 1)
doPlayerSendTextMessage(cid,25,"The door has shut behind you!")
else
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
end
end
Updated as of Fed 16th, added in the teleport player function. (you will walk to the door when opensesame is said)
Last edited: