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

Solved Need some advice on a line in quest.lua

Goo Goo

Member
Joined
Apr 20, 2010
Messages
42
Reaction score
10
Like the title says, I need advice on a line in quest.lua from forgottenserver v0.2.14\Mystic Spirit\data\actions\scripts\quests

I haven't messed with an OT in a few years and decided to get back into my long forgotten project. With that I decided to update to the 9.6 client, the last one I used for OT was 8.6. Any who I added my monsters and NPC's fine. Got my server started and was expecting non of my quests to work at all. Instead I get a mermaid comb and some other random things. So checked the UID to item IDs and my UID's matched item ids.

So basically what I would like to know is do I need/have to make my quest chests 10001+ in order for my chests to work with uid's?
The line in question...
Code:
if item.uid > 1000 and item.uid < 10000 then

If I'm not mistaken I had to put AID 2000 then the Item id as the UID in the other server.
The line from the other server. it was TFS 0.3.6 I believe.
Code:
if prize > 1000 and prize < 5000 then
EDIT: Just found out. I put AID 2000 and any UID to make a quest chest. If that's important.
 
Last edited:
The system.lua from TFS 0.3/0.4 works with actionid 2000 and uniqueid for storage.
The quest.lua works with uniqueid for both itemid and storage.

If you want to use the system.lua, use this.
http://otland.net/threads/tfs-0-2-mystic-spirit-system-lua-questsystem.185583/#post-1936028

Thanks for the reply. I don't really have preference which way to do it. But to clear up my question.
If I do a quest like this
Code:
function onUse(cid, item, frompos, item2, topos)

      if item.uid== 7510 then
          queststatus = getPlayerStorageValue(cid,7510)
          if queststatus == -1 then
              doPlayerSendTextMessage(cid,22,"You have found Dwarven Axe.")
              doPlayerAddItem(cid,2435,1)
              setPlayerStorageValue(cid,7510,1)
          else
              doPlayerSendTextMessage(cid,22,"It is empty.")
          end
If I put UID 7510 on the chest it won't try and give me the item for 7510? which is an ice shrine? according to RME. Or would I have to change the script to work with AID?
like this
Lua:
if item.aid==7510 then

I know these are really stupid questions but I don't want to spend hours (maybe even days for me)working on them and they still not work or have to start over completely.
 
Why don't you just use the system.lua?

With the quest.lua the uniqueid is the itemid, so you only add an uniqueid in the chest and that will be the item people get from the chest.
The script you posted gives an item with id 2435 which is a dwarven axe (It's incomplete, but I assume you only posted a part of a script).
 
Why don't you just use the system.lua?

I probably will. With 0.3 I used both, the system.lua when I was feeling lazy and the other one for a more complex way I guess.
The script you posted gives an item with id 2435 which is a dwarven axe (It's incomplete, but I assume you only posted a part of a script).

Yes, I only posted part of it since the entire thing consists of 5 items with no , uhm , table? Didn't think the whole thing was nessacary to get my point across, and it's pretty massive.

I tested keeping the UID the same on the chests and inserting my scripts to the appropriate places and what not. Worked like a charm. However, it maybe easier just to start over and use your system.lua. But how do you do lets say for example 5 chests one reward, with out getting the "Duplicate uniqueId" error in the server console?

Thanks again for the replies. I've been away from OT's for a while and have forgotten alot, not that I knew that much to begin with.
 
For extra explanation how the system.lua works:
http://otland.net/threads/how-to-quests.148708/

You can just add 5 items in the chests, add actionid 2000 and an uniqueid for the storage (storage is so people can only take it 1x).
The uniqueid doesn't have influence on the items in the system.lua, the system.lua will give the items you add it the chest. The uniqueid will only be for storage and should be different in every chest.

You have to remove the quest.lua lines in actions.xml if you want to use those chests for the system.lua, else it will conflict with the system.lua.
Code:
<action itemid="1740" script="quests/quests.lua"/>
<action fromid="1747" toid="1749" script="quests/quests.lua"/>

And you can add the system.lua in actions.xml like this.
Code:
<action actionid="2000" script="quests/system.lua"/>
 
I'm slightly embarrassed to admit this, but I read that thread yesterday. It didn't register in my brain til now.
[2001] = 30015, --Annihilator
[2002] = 12000 --New quest
}[/code]
Note: we added [2002] = 12000 --New quest following a comma(,).
[2002] = the actionID of the quest
12000 = the storage value of the quest
That bit flew over my head. So yeah I've been doing it wrong all along. Eh, I'm a noob what can I say.
You have to remove the quest.lua lines in actions.xml if you want to use those chests for the system.lua, else it will conflict with the system.lua.
Code:
<action itemid="1740" script="quests/quests.lua"/>
<action fromid="1747" toid="1749" script="quests/quests.lua"/>

I read that in one of your other links. The one for your system.lua maybe? Probably need to take a break and get some sleep and start fresh tomorrow.

Thanks again that clarified alot of confusion in my pea brain. I think I'm done with harassing you with questions now :) Thank you very much.
You were a great help.

Edit: And now I can get rid of some of those huge scripts that only give you items. WOW! Thanks again :D
 
I have a problem with quest chests using system.lua. If I put a action id other than 2000, then the chest can move, walked on ect. But it gives the reward like it's suppose to.
How do I fix it so they can't be moved or walked on?
PHP:
local specialQuests = {
[2001] = 30015, --Annihilator
[2002] = 10047, --Rook chests 1
[2003] = 10048, --Rook Chests 2
[2004] = 10049, --Rook Chests 3
[2005] = 10070 --High level custom rune quest
}

local questsExperience = {
[30015] = 10000
}

function onUse(cid, item, fromPosition, itemEx, toPosition)

local storage = specialQuests[item.actionid]
if(not storage) then
storage = item.uid
if(storage > 65535) then
return false
end
end

if(getPlayerStorageValue(cid, storage) > 0) then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "It is empty.")
return true
end

local items = {}
local reward = 0

local size = isContainer(item.uid) and getContainerSize(item.uid) or 0
if(size == 0) then
reward = doCopyItem(item, false)
else
for i = 0, size do
local tmp = getContainerItem(item.uid, i)
if(tmp.itemid > 0) then
table.insert(items, tmp)
end
end
end

size = table.maxn(items)
if(size == 1) then
reward = doCopyItem(items[1], true)
end

local result = ""
if(reward ~= 0) then
local ret = getItemDescriptions(reward.itemid)
if(reward.type > 0 and isItemRune(reward.itemid)) then
result = reward.type .. " charges " .. ret.name
elseif(reward.type > 0 and isItemStackable(reward.itemid)) then
result = reward.type .. " " .. ret.plural
else
result = ret.article .. " " .. ret.name
end
else
if(size > 20) then
reward = doCopyItem(item, false)
elseif(size > 8) then
reward = getThing(doCreateItemEx(1988, 1))
else
reward = getThing(doCreateItemEx(1987, 1))
end

for i = 1, size do
local tmp = doCopyItem(items, true)
if(doAddContainerItemEx(reward.uid, tmp.uid) ~= RETURNVALUE_NOERROR) then
print("[Warning] QuestSystem:", "Could not add quest reward")
else
local ret = ", "
if(i == 2) then
ret = " and "
elseif(i == 1) then
ret = ""
end

result = result .. ret
ret = getItemDescriptions(tmp.itemid)
if(tmp.type > 0 and isItemRune(tmp.itemid)) then
result = result .. tmp.type .. " charges " .. ret.name
elseif(tmp.type > 0 and isItemStackable(tmp.itemid)) then
result = result .. tmp.type .. " " .. ret.plural
else
result = result .. ret.article .. " " .. ret.name
end
end
end
end

if(doPlayerAddItemEx(cid, reward.uid, false) ~= RETURNVALUE_NOERROR) then
result = "You have found a reward weighing "..getItemWeightByUID(reward.uid).." oz. It is too heavy or you have not enough space."
else
result = "You have found " .. result .. "."
setPlayerStorageValue(cid, storage, 1)
if(questsExperience[storage] ~= nil) then
doPlayerAddExp(cid, questsExperience[storage])
end
end

doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, result)
return true
end
 
JSvytvY.png

Image of my problem.
 
If you add an uniqueid to the chest players can't move it and they can't walk on it because of the walkback.lua in movements, which pushes a player back when they walk on a chest with an uniqueid.
 
If you add an uniqueid to the chest players can't move it and they can't walk on it because of the walkback.lua in movements, which pushes a player back when they walk on a chest with an uniqueid.
Ok, so I should put the Unique id that I used for the quest in systmes.lua then? Say for this one [2005] = 10070 ... I put 10070 on the chest. Would that work? I'm sorry I know these are some pretty stupid questions again but I've never used the system.lua other than using it with action id 2000 with a unique id. Actually I guess I could just try it and see if it works. lol Thanks again for the reply.
 
You can just use a random uniqueid that's not used yet, it's only to make it not moveable and so people can't walk on it.
 
You can just use a random uniqueid that's not used yet, it's only to make it not moveable and so people can't walk on it.
Oh yeah I know that but if I get all willy nilly with my uid's I'll forget which one i've used then i'll run into the blasted duplicate unique id error in the server console. which is slightly annoying to me. :)

However using my storageid from my system.lua worked. I don't know why I didn't think of that. Thanks once more from the biggest noob on the planet.
4qdnOxw.png
 
To avoid getting duplicated unique ids you can choose a certain range of uniqueids you are going to use for the chests, for example 10000-11000, then every new chest you do +1, so 10001, 10002, 10003.
This way you only have to remember the last one you used (and you can look at the last chest you added if you forget it).
 
Back
Top