Action Demon helmet quest

Swij

Active Member
Joined
Mar 2, 2009
Messages
120
Best answers
0
Reaction score
28
Location
Sweden, Jönköping
Demon helmet quest!

In this tutorial i will be showing you how to make a functioning DHQ,
to begin with i didn't write the entire script myself that credits goes to Oxious,
I did write some parts to make the quest a little bit better.
but he didn't explain how to install it so i'll do that.
This script allows players to enter the Quest room until somebody throws the switch,
after 40 seconds the room will be opened again and during that time the players inside will be able to take the reward and leave the room.


1) Create your own map. Looking like the one on the picture. and add the reward of your choice in the 3 chests. dont forget to make a teleport into the quest room :p.


chests - Action id 2000
chest 1 - Unique id 30017
chest 2 - Unique id 30018
chest 3 - Unique id 30019
lever - Unique ID 30016


2) Create a text file and paste the script below, and enter your own coordinates. Save this as DHQ.lua in your "data\actions\scripts\quests" directory.
PHP:
local pinkstonepos1 = {x=XXXX, y=YYYY, z=Z}        -- Blocking stone position.
local TeleportToPos = { x = XXXX, y = YYYY, z = Z} -- Position the player will be ported to when leaving the DHQ, like the Temple...
local TeleportInPos = { x = XXXX, y = YYYY, z = Z} -- Position In DHQ.
local LeverPos      = { x = XXXX, y = YYYY, z = Z} -- Lever Position
local TeleportoutPos = { x = XXXX, y = YYYY, z = Z} -- Telporter out pos
local timeToRemove  = 40 -- Time before quest reset

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

local pinkstone1 = getTileItemById(pinkstonepos1, 1355) -- You can change the ID to any other kind of blocking item
local teleport = getTileItemById(TeleportInPos, 1387)

        if item.itemid == 1945 then

            doRemoveItem(pinkstone1.uid, 1)
            doCreateTeleport(1387, TeleportToPos, TeleportOutPos)
            doSendMagicEffect(TeleportInPos, CONST_ME_TELEPORT)
            doPlayerSendTextMessage(cid,22,"The stone is removed, get the reward before the time runs out!") -- Message when the lever is pulled
            addEvent(doRemoveTeleport, timeToRemove * 1000)

    else if item.itemid == 1946 then

        doPlayerSendCancel(cid,"Sorry, not possible.") -- message if the lever is pulled again.

    return 1

    end
end  

end

function doRemoveTeleport()

local teleport = getTileItemById(TeleportInPos, 1387)
local Lever = getTileItemById(LeverPos, 1946)

    if teleport.uid > 0 then

        doCreateItem(1355, 1, pinkstonepos1)
        doRemoveItem(teleport.uid)
        doSendMagicEffect(TeleportInPos, CONST_ME_POFF)
        doTransformItem(Lever.uid, 1945)

    end

end
3) Now open your Actions.xml and add this line somwere after <Actions>

This one works on TFS 0.3.1 <-
PHP:
	<action uniqueid="30016" script="quests/DHQ.lua"/>
This one works on the TFS 0.3.2 ->
PHP:
	<action uniqueid="30016" event="script" value="quests/DHQ.lua"/>
4) Now your Quest should be working, just reload your server and try it :D. Give me Rep++ if this tutorial helped you.
This scripts works perfectly on TFS 0.3.1, if your using the newer TFS you will have to add the second actions line.

//Swij
 
Last edited:
OP
Swij

Swij

Active Member
Joined
Mar 2, 2009
Messages
120
Best answers
0
Reaction score
28
Location
Sweden, Jönköping
@up: Thank you! Don't forget to Rep me :D.

I EDITED the script so that the exit teleporter pops up in
the top right corner instead of the middle of the room.
 
Last edited:

Suxex

Member
Joined
Aug 13, 2007
Messages
391
Best answers
0
Reaction score
5
Location
Halland - Getinge
Hey Swij, i've changed server to TFS 0.3.4 and added this script.

When I pull the switch the stone remove but no text pop up and the teleport dont come and the stone will not come back after a time =(

Have some idea why? = )

Thanks
 

Suxex

Member
Joined
Aug 13, 2007
Messages
391
Best answers
0
Reaction score
5
Location
Halland - Getinge
[24/05/2009 14:23:45] Lua Script Error: [Action Interface]
[24/05/2009 14:23:45] data/actions/scripts/quests/DHQ.lua:eek:nUse

[24/05/2009 14:23:45] attempt to index a nil value
[24/05/2009 14:23:46] stack traceback:
[24/05/2009 14:23:46] [C]: in function 'doCreateTeleport'
[24/05/2009 14:23:46] data/actions/scripts/quests/DHQ.lua:16: in function <data/actions/scripts/quests/DHQ.lua:8>


comes up in the server console when I pull the switch.
 

Apitov

Man With The Plan
Joined
Jun 9, 2008
Messages
40
Best answers
0
Reaction score
2
Location
Louisiana, United States
Getting the same problem as the other person who posted

[24/05/2009 14:23:45] Lua Script Error: [Action Interface]
[24/05/2009 14:23:45] data/actions/scripts/quests/DHQ.luanUse

[24/05/2009 14:23:45] attempt to index a nil value
[24/05/2009 14:23:46] stack traceback:
[24/05/2009 14:23:46] [C]: in function 'doCreateTeleport'
[24/05/2009 14:23:46] data/actions/scripts/quests/DHQ.lua:16: in function <data/actions/scripts/quests/DHQ.lua:8>


anyone know how to fix it?
 

JDB

OtLand Veteran
Joined
Jun 1, 2009
Messages
4,145
Best answers
2
Reaction score
109
@Up,

Thank you.
I hope you like it.
 

Triggah

TrigCore
Joined
Aug 1, 2007
Messages
434
Best answers
0
Reaction score
0
[25/07/2009 18:34:02] Lua Script Error: [Action Interface]
[25/07/2009 18:34:02] data/actions/scripts/quests/demonhelm.lua:eek:nUse

[25/07/2009 18:34:02] attempt to index a nil value
[25/07/2009 18:34:02] stack traceback:
[25/07/2009 18:34:02] [C]: in function 'doCreateTeleport'
[25/07/2009 18:34:02] data/actions/scripts/quests/demonhelm.lua:16: in function <data/actions/scripts/quests/demonhelm.lua:8>

does this not work on 0.3.4 pl2?

edit: used JDB's and it worked
 
Last edited:

Printer

if Printer then print("LUA") end
Premium User
Joined
Dec 27, 2009
Messages
5,733
Best answers
21
Reaction score
2,018
Location
Sweden?
who can fix it to tfs 0.3.6!
 

Printer

if Printer then print("LUA") end
Premium User
Joined
Dec 27, 2009
Messages
5,733
Best answers
21
Reaction score
2,018
Location
Sweden?
yes: look

[Error - LuaScriptInterface::loadFile] data/actions/scripts/quests/d-helmet.lua:8: 'end' expected (to close 'function' at line 1) near '<eof>'
[03/02/2010 16:22:16] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/quests/d-helmet.lua)
[03/02/2010 16:22:16] data/actions/scripts/quests/d-helmet.lua:8: 'end' expected (to close 'function' at line 1) near '<eof>'
 
Top