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

TalkAction Open Secret Passage

Status
Not open for further replies.

JDB

OtLand Veteran
Joined
Jun 1, 2009
Messages
4,145
Solutions
2
Reaction score
115
The Forgotten Server 0.3.5

It is pretty obvious what it does.
Say !pass "words" and it removes a door or w/e, for XX seconds.

data/talkactions/talkactions.xml
PHP:
<talkaction log="no" words="!pass" access="0" event="script" value="script.lua"/>

data/talkactions/scripts/script.lua
Lua:
local standPos = {x=100, y=100, z=7} -- Player Stands Here
local bookCasePos = {x=100, y=100, z=7} -- Bookcase Spot
local passageKey = "Open Sesame" -- Message player has to say
local openTime = 10 -- Seconds the passage will remain open
local passageID = XXXX -- Passage Door/Blocking Item ID

local function countDown(n)
    if(n > 0) then
        doSendAnimatedText(bookCasePos, n, TEXTCOLOR_RED)
        addEvent(countDown, 1000, n - 1)
    else
        local bookCase = getTileItemById(bookCasePos, passageID)
        if(bookCase.uid == 0) then
            doCreateItem(bookCasePos, passageID)
        end
    end
end

function onSay(cid, words, param)
    if(#param == 0) then
        doPlayerSendCancel(cid, "Command requires param.")
        return true
    end
    
    if(param:lower() == passageKey:lower()) then
        if(comparePos(getCreaturePosition(cid), standPos)) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Passage has been revealed!")
            local passageWay = getTileItemById(bookCasePos, passageID)
            if(passageWay.uid ~= 0) then
                doRemoveItem(passageWay.uid)
            end
            countDown(openTime)
        else
            doPlayerSendCancel(cid, "You must stand on the correct spot.")
        end
    else
        doPlayerSendCancel(cid, "You must say the correct password to open the passage.")
    end
    return true
end

Extra Feature:
  • Countdown at passage position. [10, 9, 8, 7, 6...]
 
Last edited:
@up,
Yes, woot! :thumbup:
 
Code:
local function replaceBookCase()
	if getTileItemById(bookCasePos, passageID).uid < 1 then
		doCreateItem(bookCase.uid)
	end
end

Triple w00t!
 
Erm, not sure if its just me but I set everything correctly and the script give the error "You must stand on the correct spot." despite the fact that I'm ON the tile.
 
the Woot above the other WooT'es!

Lua:
        if bookCase.uid < 1 then
                doCreateItem(bookCase.uid)
        end

DoCreateItem needs 2 values om nom? Id an dPosition o_O?

There is no one of them!

@offtop: chojrak! when have you changed name!?!
 
@JDB:
Sorry for this spam but we want optimized scripts ;]
Code:
doRemoveItem(getTileItemById(bookCasePos, passageID).uid)

@Quas:
Like a week ago. ;p
 
Lua:
local standPos = {x=100, y=100, z=7} -- Player Stands Here
local bookCasePos = {x=100, y=100, z=7} -- Bookcase Spot
local passageKey = "Open Sesame" -- Message player has to say
local openTime = 10 -- Seconds the passage will remain open
local passageID = XXXX -- Passage Door/Blocking Item ID

local function countDown(n)
    if(n > 0) then
        doSendAnimatedText(bookCasePos, n, TEXTCOLOR_RED)
        addEvent(countDown, 1000, n - 1)
    else
        local bookCase = getTileItemById(bookCasePos, passageID)
        if(bookCase.uid == 0) then
            doCreateItem(bookCasePos, passageID)
        end
    end
end

function onSay(cid, words, param)
    if(#param == 0) then
        doPlayerSendCancel(cid, "Command requires param.")
        return true
    end
    
    if(param:lower() == passageKey:lower()) then
        if(comparePos(getCreaturePosition(cid), standPos)) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Passage has been revealed!")
            local passageWay = getTileItemById(bookCasePos, passageID)
            if(passageWay.uid ~= 0) then
                doRemoveItem(passageWay.uid)
            end
            countDown(openTime)
        else
            doPlayerSendCancel(cid, "You must stand on the correct spot.")
        end
    else
        doPlayerSendCancel(cid, "You must say the correct password to open the passage.")
    end
    return true
end
 
Last edited:
open sesame?
 
Thanks colandus, I will update first post.
This was made like for 8.4~ while ago.
 
Status
Not open for further replies.
Back
Top