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

tobias89

Pikaz Liek Pikaz
Joined
Apr 24, 2010
Messages
110
Reaction score
0
If I have 5 Chests in a quest.. And I want only the players to get one prize.. how can I do that.
 
Go to actions folder and go start editing script anhireward or anhichests depends on how you have named the scripts, just edit Annihilator Reward Chests script and actionid`s :)

If you dont know how to edit, paste these script here and say me what rewards could be in chests and what actionids could be for chests :)
 
I only had these 2:


Rewards:

1 chest: Demon armor: 2494
2 chest: fire sword: 2392
3 chest: boh: 2195
4 chest: 30 ferns: 2801


System.lua

Code:
local specialQuests = {
	[2001] = 30015 --Annihilator
}

local questsExperience = {
	[30015] = 10000
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if(getPlayerCustomFlagValue(cid, PLAYERCUSTOMFLAG_GAMEMASTERPRIVILEGES)) then
		doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF, cid)
		return true
	end

	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[i], 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 .. "."
		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 true
end


anni.lua

Code:
local config = {
	daily = "no", -- allow only one enter per day? (like in global Tibia)
	level = 13,
	storage = 30015
	entry =
	{
		{x = 1086, y = 585, z = 5},
		{x = 1085, y = 585, z = 5},
		{x = 1084, y = 585, z = 5},
		{x = 1083, y = 585, z = 5}
	},
	destination =
	{
		{x = 1083, y = 573, z = 5},
		{x = 1082, y = 573, z = 5},
		{x = 1081, y = 573, z = 5},
		{x = 1080, y = 573, z = 5}
	}
}

config.daily = getBooleanFromString(config.daily)
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if(item.itemid == 1946) then
		if(config.daily) then
			doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
		else
			doTransformItem(item.uid, item.itemid - 1)
		end

		return true
	end

	if(item.itemid ~= 1945) then
		return true
	end

	local players = {}
	for _, position in ipairs(config.entry) do
		local pid = getTopCreature(position).uid
		if(pid == 0 or not isPlayer(pid) or getCreatureStorage(pid, config.storage) > 0 or getPlayerLevel(pid) < config.level) then
			doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
			return true
		end

		table.insert(players, pid)
	end

	for i, pid in ipairs(players) do
		doSendMagicEffect(config.entry[i], CONST_ME_POFF)
		doTeleportThing(pid, config.destination[i], false)
		doSendMagicEffect(config.destination[i], CONST_ME_ENERGYAREA)
	end

	doTransformItem(item.uid, item.itemid + 1)
	return true
end
 
What items you want to be in chests, you want 5 and you wrote in previous post 4 :huh: ?


@Edit

Go to actions folder and make: name.lua

name.lua (you can rename this)
PHP:
if item.uid == 9501 then
queststatus = getPlayerStorageValue(cid,100)
if queststatus == -1 then
doPlayerSendTextMessage(cid,22,"You have found an demon armor.")
doPlayerAddItem(cid,2494,1)
setPlayerStorageValue(cid,9500,1)
else
doPlayerSendTextMessage(cid,22,"It is empty.")
end
end
if item.uid == 9502 then
queststatus = getPlayerStorageValue(cid,100)
if queststatus ~= 1 then
doPlayerSendTextMessage(cid,22,"You have found an fire sword.")
doPlayerAddItem(cid,2392,1)
setPlayerStorageValue(cid,9500,1)
else
doPlayerSendTextMessage(cid,22,"It is empty.")
end
end
if item.uid == 9503 then
queststatus = getPlayerStorageValue(cid,100)
if queststatus ~= 1 then
doPlayerSendTextMessage(cid,22,"You have found pair a boots of haste.")
doPlayerAddItem(cid,2195,1)
setPlayerStorageValue(cid,9500,1)
else
doPlayerSendTextMessage(cid,22,"It is empty.")
end
end
if item.uid == 9504 then
queststatus = getPlayerStorageValue(cid,100)
if queststatus ~= 1 then
doPlayerSendTextMessage(cid,22,"You have found a 30 ferns.")
doPlayerAddItem(cid,2801,30)
setPlayerStorageValue(cid,9500,1)
else
doPlayerSendTextMessage(cid,22,"It is empty.")
end
end
return 1
end


Legend (put these unique.id`s on map editor (click on box -> preferences -> unique id: ex. 9502):

u.id: 9501 - Demon armor
u.id: 9502 - fire sword
u.id: 9503 - boh
u.id: 9504 - 30 ferns


PS. Script is free for use, you can edit anything.
Hope it helps,
Fresh.
 
Last edited:
@Up
Maybe you have this storage existed ?
You put right this script ?
Any bugs in console ?
What TFS you use ?
 
You added to action.xml ?:

PHP:
	<action uniqueid="9501" script="name.lua"/>
	<action uniqueid="9502" script="name.lua"/>
	<action uniqueid="9503" script="name.lua"/>
	<action uniqueid="9504" script="name.lua"/>

If you dont add, try add it now :)
 
Check this:
PHP:
if item.uid == 9501 then
queststatus = getPlayerStorageValue(cid,9500)
if queststatus == -1 then
doPlayerSendTextMessage(cid,22,"You have found an demon armor.")
doPlayerAddItem(cid,2494,1)
setPlayerStorageValue(cid,9500,1)
else
doPlayerSendTextMessage(cid,22,"It is empty.")
end
end
if item.uid == 9502 then
queststatus = getPlayerStorageValue(cid,9500)
if queststatus ~= 1 then
doPlayerSendTextMessage(cid,22,"You have found an fire sword.")
doPlayerAddItem(cid,2392,1)
setPlayerStorageValue(cid,9500,1)
else
doPlayerSendTextMessage(cid,22,"It is empty.")
end
end
if item.uid == 9503 then
queststatus = getPlayerStorageValue(cid,9500)
if queststatus ~= 1 then
doPlayerSendTextMessage(cid,22,"You have found pair a boots of haste.")
doPlayerAddItem(cid,2195,1)
setPlayerStorageValue(cid,9500,1)
else
doPlayerSendTextMessage(cid,22,"It is empty.")
end
end
if item.uid == 9504 then
queststatus = getPlayerStorageValue(cid,9500)
if queststatus ~= 1 then
doPlayerSendTextMessage(cid,22,"You have found a 30 ferns.")
doPlayerAddItem(cid,2801,30)
setPlayerStorageValue(cid,9500,1)
else
doPlayerSendTextMessage(cid,22,"It is empty.")
end
end
return 1
end
 
[13/07/2010 18:28:57] [Error - LuaScriptInterface::loadFile] data/actions/scripts/name.lua:42: '<eof>' expected near 'end'
[13/07/2010 18:28:57] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/name.lua)
[13/07/2010 18:28:57] data/actions/scripts/name.lua:42: '<eof>' expected near 'end'
[13/07/2010 18:28:57] [Error - LuaScriptInterface::loadFile] data/actions/scripts/name.lua:42: '<eof>' expected near 'end'
[13/07/2010 18:28:57] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/name.lua)
[13/07/2010 18:28:57] data/actions/scripts/name.lua:42: '<eof>' expected near 'end'
[13/07/2010 18:28:57] [Error - LuaScriptInterface::loadFile] data/actions/scripts/name.lua:42: '<eof>' expected near 'end'
[13/07/2010 18:28:57] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/name.lua)
[13/07/2010 18:28:57] data/actions/scripts/name.lua:42: '<eof>' expected near 'end'
[13/07/2010 18:28:57] [Error - LuaScriptInterface::loadFile] data/actions/scripts/name.lua:42: '<eof>' expected near 'end'
[13/07/2010 18:28:57] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/name.lua)
[13/07/2010 18:28:57] data/actions/scripts/name.lua:42: '<eof>' expected near 'end'
 
PHP:
if item.uid == 9501 then
queststatus = getPlayerStorageValue(cid,9500)
if queststatus == -1 then
doPlayerSendTextMessage(cid,22,"You have found an demon armor.")
doPlayerAddItem(cid,2494,1)
setPlayerStorageValue(cid,9500,1)
else
doPlayerSendTextMessage(cid,22,"It is empty.")
end
end
if item.uid == 9502 then
queststatus = getPlayerStorageValue(cid,9500)
if queststatus ~= 1 then
doPlayerSendTextMessage(cid,22,"You have found an fire sword.")
doPlayerAddItem(cid,2392,1)
setPlayerStorageValue(cid,9500,1)
else
doPlayerSendTextMessage(cid,22,"It is empty.")
end
end
if item.uid == 9503 then
queststatus = getPlayerStorageValue(cid,9500)
if queststatus ~= 1 then
doPlayerSendTextMessage(cid,22,"You have found pair a boots of haste.")
doPlayerAddItem(cid,2195,1)
setPlayerStorageValue(cid,9500,1)
else
doPlayerSendTextMessage(cid,22,"It is empty.")
end
end
if item.uid == 9504 then
queststatus = getPlayerStorageValue(cid,9500)
if queststatus ~= 1 then
doPlayerSendTextMessage(cid,22,"You have found a 30 ferns.")
doPlayerAddItem(cid,2801,30)
setPlayerStorageValue(cid,9500,1)
else
doPlayerSendTextMessage(cid,22,"It is empty.")
end
return 1
end
 
I get this 4 times.


Code:
[13/07/2010 19:42:29] [Error - Action Interface] 
[13/07/2010 19:42:29] data/actions/scripts/name.lua
[13/07/2010 19:42:29] Description: 
[13/07/2010 19:42:29] data/actions/scripts/name.lua:1: attempt to index global 'item' (a nil value)
[13/07/2010 19:42:29] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/name.lua)
[13/07/2010 19:42:29] cannot open data/actions/scripts/anni.lua: No such file or directory
 
Code:
local chests = {
	[1256] = {itemid=1111,count=1},
	[1257] = {itemid=2222,count=1},
	[1258] = {itemid=3333,count=1},
	[1259] = {itemid=4444,count=1},
	[1260] = {itemid=5555,count=1}
	}

function onUse(cid,item,toPosition,itemEx,fromPosition)
local r,s,v = chests.uniqueid,1525,getThingPos(cid)
	if r then
		if getPlayerStorageValue(cid,s) < 0 then
			doPlayerGiveItem(cid,r.itemid,r.count)
			doPlayerSendTextMessage(cid,27,'You\'ve gained '..getItemArticleById(r.itemid)..' '..getItemNameById(r.itemid)..'.')
			setPlayerStorageValue(cid,s,1)
			doSendMagicEffect(v,12)
		else
			doPlayerSendTextMessage(cid,27,'You\'ve already done this quest.')
			doSendMagicEffect(v,2)
		end
	end
	return true
end

[####] is the actionid.
 
Last edited:
Here's the thing, im a beginner! Im learning fast, but I can't the my head around this quest / chest system..

Im using the action id 2000 on normal quests, but when im trying to add the script you just gave me it wont work. it wont even tell me its a quest.. it just opens up the chest like any normal chest.
 
Back
Top