• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Action [TFS 1.0 / 0.2.15] Working questsystem from 0.3.7 - 0.4

zbizu

Legendary OT User
Joined
Nov 22, 2010
Messages
3,323
Solutions
26
Reaction score
2,696
Location
Poland
Known questsystem from TFS 0.3.7/0.4 - now available for 1.0 and 0.2.15
(this one where you add rewards in mapeditor and set chest actionid 2000 as quest type and uid as chest storage)

feathures:
all feathures from 0.3.7 questsystem
+ fixed item weight displaying - now as on rl
+ uses "the itemname is empty" - as on rl
+ sees difference between no room and no cap - also as on rl ^^
+ some examples of multiple chests with same storage(actionid above 2000)

actions.xml(I recommend removing old questsystem first):
XML:
<action actionid="2000" script="quests/system.lua"/>
<action fromaid="2001" toaid="2006" script="quests/system.lua"/>

quests/system.lua:
Lua:
local specialQuests = { [2001] = 30015, [2002] = 7248, [2003] = 50090, [2004] = 42361, [2005] = 42371, [2006] = 42381}
local questsExperience = { [30015] = 100000, [7248] = 150000 }

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, "The " .. getItemName(item.itemid) .. " 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 > 1 and isItemRune(reward.itemid)) then
			result = reward.type .. " charges " .. ret.name
		elseif(reward.type > 1 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.itemid)
				if(tmp.type > 1 and isItemRune(tmp.itemid)) then
					result = result .. tmp.type .. " charges " .. ret.name
				elseif(tmp.type > 1 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
		if getPlayerFreeCap(cid) < getItemWeightByUID(reward.uid) then
			result = "You have found " .. result .. " weighing " .. string.format("%.2f", getItemWeightByUID(reward.uid)) .. " oz. You have no capacity."
		else
			result = "You have found " .. result .. ", but you have no room to take it."
		end
	else
		result = "You have found " .. result .. "."
		setPlayerStorageValue(cid, storage, 1)
		if(questsExperience[storage] ~= nil) then
			doPlayerAddExpEx(cid, questsExperience[storage])
		end
	end

	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, result)
	return true
end
 
Last edited:
is to good scrip

tfs 1.0 require autosave globalevent and clean

/clean actually works, but doesn't clear protection zones, I don't know if it's configurable

TFS 1.0 should be compatible with 0.3.7 autosave, add this to global.lua and it should work without changing anything in script:
Lua:
doSaveServer = saveData

btw. again, what is current name of 0.3.7? I heard they renamed it.
 
weight formatting as on rl and showing the chest is empty instead 'it is empty'
oh and it sees difference between no room and no capacity

I didn't knew that someone rewritten it already, but code posted in my thread is still better ;d
 
Last edited:
I used the system.lua from TFS 0.3 for people who want it exactly like that, I only made it work for TFS 0.2.
But if you scroll below, you see that I also made a version for difference between cap and space message since someone asked me.
I didn't add the name of the item in the "it is empty" message because it wasn't like that in the 0.3 system.lua and no one asked me to do it.
I don't think making a new thead for that was needed.

@down

I was just saying that it isn't needed to create a thread about something that already exists.
It has been posted countless of times in other threads, and even if you didn't see it, you could also look for it.
Specialy when you post, there is now a working system.lua for TFS 0.2, like there wasn't one before.
I already told you why I didn't add the textmessage changes you did, there is no need for that attitude.
I'm just pointing out, instead of making a new thread, you could also look if it already exists and if you think the extra edit in the textmessage would be better, make a post about it.
 
Last edited:
I just didn't noticed your thread, I've rewritten this questsystem for myself, because I'm moving from 0.3.7 to 1.0. I wanted this system to be closest to this used on RL and I just published it.
If you are jealous that much I'm sorry for making better questsystem without looking at yours.

Okay, you think this thread is useless, but I still don't understand what do you want.
 
Problem

[06/10/2013 17:11:21] Lua Script Error: [Action Interface]
[06/10/2013 17:11:21] data/actions/scripts/quests/system.lua:eek:nUse
[06/10/2013 17:11:21] data/global.lua:970: attempt to compare number with nil
[06/10/2013 17:11:21] stack traceback:
[06/10/2013 17:11:21] [C]: in function '__lt'
[06/10/2013 17:11:21] data/global.lua:970: in function 'doCopyItem'
[06/10/2013 17:11:21] data/actions/scripts/quests/system.lua:58: in function <data/actions/scripts/quests/system.lua:4>
 
Back
Top