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

[Help] Easy way to make quests

HtotheN

Member
Joined
Oct 17, 2012
Messages
58
Reaction score
9
Im having problems to find a working guide of how to make a quest useing TFS 0.2.14 (9.60).
The quest itself is made, mapping way. But I'd like the player able to choose one out of 3 items.
I've tryed diffrent ways of doing it.
  • A guide by Evan, making me put the same action id along with coding in system.lua and more. -- Didn't work.
  • Put the same unique+ 2000 as action id. -- Didn't work either.

Suggestions?
Thanks from someone who haven't been working with OT's since 2008.
 
Well, Im useing TFS 0.2.14 with a custom map. The old scripts doesn't work, since the map is from 2007. The server map itself has been converted, but the quest system isn't the same anymore.
And I did try useing actions, but can't really get things to work.
 
There are two chest rewarding systems:
#1
You give the chest the itemid you should get as uniqueid. If you want to get multiple items, backpacks, etc. you have to write a special script.
#2
You add the item(s) you should get in the map editor and write actionid 2000 and a quet specific uniqueid

Which one are you using?
 
Last edited:
Second one. It works like anni, you choose one out of 3 items. But can't manage to get it work.

Edit:

Turns into this ingame, when doing as mentioned in the mapeditor:


hEhjOb.png


F5D[Wo.png


ufrQG2.png
 
Last edited:
Just put an action ID on the chest and use a script similar to this.

XML:
<action actionid="11001" event="script" value="chest.lua"/> 
<action actionid="11002" event="script" value="chest.lua"/> 
<action actionid="11003" event="script" value="chest.lua"/>
LUA:
function onUse(cid, item, frompos, item2, topos) 
       if item.actionid == 11001 then 
       queststatus = getPlayerStorageValue(cid,12345)
        if queststatus == -1 then
        doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You have found a gold coin.")
            doPlayerAddItem(cid,2148,1)
            setPlayerStorageValue(cid,12345,1)
        else
             doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "The chest is empty.")
        end 
       elseif item.actionid == 11002 then 
       queststatus = getPlayerStorageValue(cid,12345)
        if queststatus == -1 then
        doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You have found a platinum coin.")
            doPlayerAddItem(cid,2152,1)
            setPlayerStorageValue(cid,12345,1)
        else
             doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "The chest is empty.")
        end 
       elseif item.actionid == 11003 then 
       queststatus = getPlayerStorageValue(cid,12345)
        if queststatus == -1 then
        doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You have found a crystal coin.")
            doPlayerAddItem(cid,2160,1)
            setPlayerStorageValue(cid,12345,1)
        else
             doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "The chest is empty.")
        end 
    else 
        return 0 
       end 
       return 1 
end
 
Last edited:
LUA:
<action actionid="30051" event="script" value="chest.lua"/> 
<action actionid="30052" event="script" value="chest.lua"/> 
<action actionid="30053" event="script" value="chest.lua"/>

LUA:
function onUse(cid, item, frompos, item2, topos) 
       if item.actionid == 30051 then 
       queststatus = getPlayerStorageValue(cid,30050)
        if queststatus == -1 then
        doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You have found a gold coin.")
            doPlayerAddItem(cid,2148,1)
            setPlayerStorageValue(cid,30050,1)
        else
             doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "The chest is empty.")
        end 
       elseif item.actionid == 30052 then 
       queststatus = getPlayerStorageValue(cid,30050)
        if queststatus == -1 then
        doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You have found a platinum coin.")
            doPlayerAddItem(cid,2152,1)
            setPlayerStorageValue(cid,30050,1)
        else
             doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "The chest is empty.")
        end 
       elseif item.actionid == 30053 then 
       queststatus = getPlayerStorageValue(cid,30050)
        if queststatus == -1 then
        doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You have found a crystal coin.")
            doPlayerAddItem(cid,2160,1)
            setPlayerStorageValue(cid,30050,1)
        else
             doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "The chest is empty.")
        end 
    else 
        return 0 
       end 
       return 1 
end

Still wont work. Having 30051-53 in chests as action ids.
 
Last edited:
Create a new file into actions folder called system.lua

LUA:
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

In actions.xml:

Code:
	<action actionid="2000" event="script" value="system.lua"/>
	<action actionid="2001" event="script" value="system.lua"/>

So in the map editor something like this:

sysq.png


If isn't working with 2001, just try with 2000, only remember removing all quest systems from actions.xml just before doing this.
 
Back
Top