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

Lua Quest Chest Problem!

seto sazo

Member
Joined
Apr 27, 2009
Messages
162
Reaction score
21
Yoyo. So i'm making a 7.6 server and i've added the chest quest script to my 7.6 distro where you put action ID 2000 UID=W.e. And add the item into the chest. The action works and I get my item BUT It also opens up the chest and you can take the quest item out of it. I need to make it where it does the quest action but it doesn't open up the chest, because you can take the item out of the chest then it gets all screwed up and gives you chests for the quests instead of that item. Any help!? Rep!
 
It doesnt matter. I don't want to script every single chest quest in real tibia... I use the map editor function where you put 2000 in the action ID and storage value in the unique and then add the item into the chest.
 
Else, you could use this script for each chest..

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


if item.uid == xxxxx then
if getPlayerStorageValue(cid,xxxxx) == -1 then
doPlayerSendTextMessage(cid,25,"You have found a <insert item name here>.")
doPlayerAddItem(cid,xxxx,1)
setPlayerStorageValue(cid,xxxxx,1)
else
doPlayerSendTextMessage(cid,25,"The chest is empty.")
end

end
return TRUE
end

Red text/xxxxx = Change them to fit your needs.
 
Alright i found the problem
heres my script
local specialQuests = {
[2001] = 30015 --Annihilator
}

local questsExperience = {
[30015] = 10000
}
function onUse(cid, item, frompos, item2, topos)

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.uid)
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.uid)
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 " .. getItemWeight(reward.uid) .. " oz. It is too heavy or you have not enough space."
else
result = "You have found " .. result .."a quest"
setPlayerStorageValue(cid, storage, 1)
if(questsExperience[storage] ~= nil) then
doPlayerAddExp(cid, questsExperience[storage])
doSendAnimatedText(getCreaturePosition(cid), questsExperience[storage], TEXTCOLOR_WHITE)
end
end

doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, result)
return false
end



The trouble part is at
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
I get the error
Action interface :On Use
LuaGetContainerSize()/ Container not found.

Im using Avesta version 7.6! Someone please help!
 
Alright i found the problem
heres my script


The trouble part is at

I get the error

Im using Avesta version 7.6! Someone please help!



PHP:
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
return true
end

Delete the extra "End"

IDK if it will work, but u can try.
 
Try this chest system I made. It's simple, but works.
Code:
local chests = {
	[COLOR="red"][1001] = { -- CHEST ACTION ID[/COLOR]
		level = 100,
		msg = "You have found some money!",
		storage = 23315,
		items = { 
			{2160,1},
			{2152,1}
		}
	},
	[COLOR="red"][1002] = { -- CHEST ACTION ID[/COLOR]
		level = 100,
		msg = "You have found some money!",
		storage = 23315,
		items = { 
			{2160,1},
			{2152,1}
		}
	}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	local v = chests[item.actionid]
	if(getPlayerStorageValue(cid, v.storage) == -1) then
		if(getPlayerLevel(cid) >= v.level) then
			for i = 1, #v.items do
				local x = v.items[i]
				local rewards = doCreateItemEx(x[1], x[2] or 1)
				if(doPlayerAddItemEx(cid, rewards, true) ~= RETURNVALUE_NOERROR) then
					doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You are unable to carry your reward.")
				else
					doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, v.msg)
					doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_BLUE)
					setPlayerStorageValue(cid, v.storage, 1)
				end
			end
		else
			doPlayerSendCancel(cid, "Your level is not high enough.")
			doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
		end
	else
		doPlayerSendCancel(cid, "The chest is empty.")
		doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
	end
	
	return true
end
 
Last edited:
See I would try it but all my 50+ quests are already scripted to my script. The script works perfectly only it gives you that error then it allows you to open out the chest, take out the item in the chest. Since the script uses copy item it can't copy that item because someone took it, making the quest obsolete.
 
No, I want it where you click on a chest, get the quest item, and it doesnt Open up the chest. Like my problem right now is, The quest works. This script works, BUT when you use the chest it not only gives you the quest item but it opens up the chest itself, and this script takes the item out of the chest, copys the item and gives it to you. But since you can open up the chest and take the item out, then the script can't work because theres no item in the chest. I want to make it so you can't open up the chest.

I want to make it so this doesn't happen.
helpvh.jpg
 
You have to remove the item in the Map Editor I believe.

Try removing those boots in the Map Editor.
 
No I need them, thats how the script works... It copys the item out of the chest and then gives it to you. I need to make it so the chest doesnt open lol
 
I am thinking that you are using my script, nvm...my script adds it automatically.
I don't know why it's not working to be honest.
 
=/ This sucks. Lol this is my last thing and then im done with my 7.6 rl map lol. I have it 99.99% done except for this. ANYONE HELP!? Lol
 
Back
Top