• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Quest door starts a timer

Frillinde

Founder: Another Realm
Joined
Jan 16, 2012
Messages
148
Reaction score
3
Location
his computer
Hello, Im looking for a script for a quest for the custom map Im working on.Im using crying damson 3.6 pl1 with windows 7.

Features needed:
The quest should start a timer when you walk thru a door and stop the timer when you go thru door #2.
This quest can only be tried once.
If you die between doors you fail.
If you make it thru door 2 it should save your level, vocation, date attempted and amount of time used on timer.

Thanks for any help with this.
 
Im hoping someone will accept this challenge for me as finishing my quests are the last to do on my map....
Even a point in the right direction would help right now as my scripting skills arent too good
 
it should be saved so it coulf be veiwed on the server quest list if posible and the coords on doors are--->#1 x1897 , y454, z8 and door #2----> x1895, y454, z9
hopefully thats what ya needed
 
Edited:
Scripts tested, video added (I was so freaking bored that I recorded that xD)

Video: test.wmv - YouTube
low quality, just to show the working script.
I'm playing my games to pass times, ignore them :>


Scripts:

XML:
<action actionid="xxxx" event="script" value="firstdoor.lua"/>

actions/scripts/firstdoor.lua
LUA:
local config = {
	storageq = XXXX, --quest storage
	storaget = xxxx, --timer storage
	pos = {x= , y= , z= } --teleport position after using the door
	}

function onUse(cid, fromPosition, item, toPosition)

if getPlayerStorageValue(cid, config.storageq) > 0 then
	doPlayerSendTextMessage(cid, 19, "You already tried this Quest.")
	return false
else
	setPlayerStorageValue(cid, config.storageq, 1)
	setPlayerStorageValue(cid, config.storaget, os.time())
	doTeleportThing(cid, config.pos)
end
return true
end

seconddoor
XML:
<action actionid="xxxx" event="script" value="seconddoor.lua"/>

seconddoor.lua script
LUA:
local config = {
	storageq = 60001, --quest storage same as first script
	storaget = 60002, --timer storage same as first script
	pos = {x=367, y=825, z=7}, --teleport position after using the door
	storingvoc = 60003, --storagevalue to store lvl,voc,date,time,..
	storingname = 60004,
	storingdate = 60005,
	storinglvl = 60006,
	storingtime = 60007
	}
 
function onUse(cid, fromPosition, item, toPosition)
 
	local timeneeded = math.ceil((os.difftime(os.time(), getPlayerStorageValue(cid, config.storaget))) / 60)
	doPlayerSendTextMessage(cid, 19, "You successfully completed the Quest!\nYour time is "..timeneeded.." minutes.")
	setPlayerStorageValue(cid, config.storageq, 1)
	doTeleportThing(cid, config.pos)
	setPlayerStorageValue(cid, config.storingvoc, getPlayerVocation(cid))
	setPlayerStorageValue(cid, config.storingname, getPlayerName(cid))
	setPlayerStorageValue(cid, config.storingdate, os.date())
	setPlayerStorageValue(cid, config.storinglvl, getPlayerLevel(cid))
	setPlayerStorageValue(cid, config.storingtime, timeneeded)
return true
end

That's one way to store all the data, split it to storagevalues.

30x7bzk.jpg


I'm searching a better way of doing this, I'll update this if I find any, or maybe someone else does ;)
 
Last edited:
ok it works :)(no errors in console)
... how I set it up....
All I did to test it was put the 2 door lua files in actions xml and actions/quests,used remeres to give doors action 2000 and unique X, then tested with a player and a god.
How do I make it show minutes and seconds,instead of just "2 minutes" or "4 minutes" make it say "2 minutes 12 seconds" or "4 minutes 47 seconds"?
How do I make it not be done by group higher than Senior Tutor?
I think I also didnt install it right so any pointers would be great.
Thanks for helping.
:)
 
Last edited:
for the "minutes , seconds" thing, replace the old code with that:
LUA:
local timeneeded = os.difftime(os.time(), getPlayerStorageValue(cid, config.storaget))
local minutes = timeneeded / 60
local realminutes = math.floor(minutes)
local seconds = 60* (minutes - realminutes)
doPlayerSendTextMessage(cid, 19, "You successfully completed the Quest!\nYour time is "..realminutes.." minutes and "..seconds.." seconds.")
This will split it to minutes and seconds.

I'm freaking tired, I'll continue another time for the other questions xD
The solution to the GM Tutor thing would be to check the "getPlayerGroupId" function.
like:
LUA:
if getPlayerGroupId(cid) > "tutor group" then
return doPlayerSendCancel(cid, "Only Players can do that quest.")
Just add that and it will work xD
 
Last edited:
AFAIK getCreatureStorage or getPlayerStorageValue returns an integrer. So using setPlayerStorageValue for storing text or a date other than os.time() is useless :p.
 
AFAIK getCreatureStorage or getPlayerStorageValue returns an integrer. So using setPlayerStorageValue for storing text or a date other than os.time() is useless :p.
This is what I get for returning the storages with "getPlayerStorageValue"
Code:
[15/02/2012 16:51:25] storage 3 = 4
[15/02/2012 16:51:25] storage 4 = Zyntax
[15/02/2012 16:51:25] storage 5 = 2
[15/02/2012 16:51:25] storage 6 = 10
[15/02/2012 16:51:25] storage 7 = 4
3 = vocation
4 = name
5 = os.date()
6 = lvl
7 = timeneeded

The only thing which doesn't work is storing os.date()


btw:
Had a mistake at the time formation:
local realminutes = math.floor(timeneeded)
should be
local realminutes = math.floor(minutes)
 
Last edited:
Hmm kinda strange that it returns text. Oh well...about os.date: Use setPlayerStorageValue(cid, value, os.time()) and to get the date use (getPlayerStorageValue(cid, value) > 0 and os.date("%d/%m/%Y %H:%M:%S", getPlayerStorageValue(cid, value)) or nil). Or if you want the direct and risky way just use: os.date("%d/%m/%Y %H:%M:%S", getPlayerStorageValue(cid, value))
 
Last edited:
ok after I tried update the lua files, I got an error in firstdoor lua so I didnt get that 1 right
....
could you post the updated copys for me so I dont have to show off my bad lua skills (lol)
 
Back
Top