TalkAction Open Secret Passage

Status
Not open for further replies.

JDB

OtLand Veteran
Joined
Jun 1, 2009
Messages
4,145
Best answers
2
Reaction score
109
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:
OP
JDB

JDB

OtLand Veteran
Joined
Jun 1, 2009
Messages
4,145
Best answers
2
Reaction score
109
@up,
Yes, woot! :thumbup:
 

Shawak

Intermediate OT User
Joined
Sep 11, 2008
Messages
1,976
Best answers
2
Reaction score
101
Location
Germany
@up and upup: Double woot :D.
 

chojrak

Banned User
Joined
Oct 25, 2008
Messages
5,832
Best answers
2
Reaction score
158
Code:
local function replaceBookCase()
	if getTileItemById(bookCasePos, passageID).uid < 1 then
		doCreateItem(bookCase.uid)
	end
end
Triple w00t!
 

Buruniu2

Cześć, I'm Sherlok
Joined
Oct 5, 2009
Messages
23
Best answers
0
Reaction score
0
w00t! I don't know scripting o_0
 

Jaed Le Raep

★Gaeming★
Joined
Sep 3, 2007
Messages
1,091
Best answers
0
Reaction score
234
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.
 

QuaS

Cykotitan Pwned =/
Joined
Sep 11, 2008
Messages
833
Best answers
0
Reaction score
26
Location
Poland/ Wroclaw
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!?!
 

chojrak

Banned User
Joined
Oct 25, 2008
Messages
5,832
Best answers
2
Reaction score
158
@JDB:
Sorry for this spam but we want optimized scripts ;]
Code:
doRemoveItem(getTileItemById(bookCasePos, passageID).uid)
@Quas:
Like a week ago. ;p
 

Colandus

Advanced OT User
Joined
Jun 6, 2007
Messages
2,424
Best answers
18
Reaction score
165
Location
Sweden
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:

cbrm

Top Class brunet scripter
Staff member
Global Moderator
Joined
Jan 6, 2009
Messages
6,585
Best answers
3
Reaction score
852
Location
Caribbean Sea
open sesame?
 
OP
JDB

JDB

OtLand Veteran
Joined
Jun 1, 2009
Messages
4,145
Best answers
2
Reaction score
109
Thanks colandus, I will update first post.
This was made like for 8.4~ while ago.
 
Status
Not open for further replies.
Top