• 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 Simple quest mod, easy to configure! [updated]

Darad

New Member
Joined
Jun 23, 2009
Messages
119
Reaction score
1
Simple easy to use quest mod. Add unique id of the chest to the config array, add rewards and storageValue, you're done :)

Players can now receive exp too. Don't want to give a reward, but just exp, leave out the reward :)

Lua:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Quest system" version="1.0" author="Darad @ Babylon" enabled="yes">
	<config name="quest_config"><![CDATA[
		config = {
			-- wanna make an anni style quest? Make 4 chests different id's but same storage value! :)
			[5001] = { -- uniqueid of chest is quest id
				storageValue = 5001,
				rewards = {2156}, -- can be array!
			},
			[4001] = {
				storageValue = 4001,
				rewards = {2276},
				exp = 1000000
			}
		}
	]]></config>
	<action itemid="1740" allowfaruse="0" event="buffer"><![CDATA[
		-- function onUse(cid, item, fromPosition, itemEx, toPosition)
		domodlib('quest_config')
		
		local q = config[item.uid]
		if(q ~= nil) then
			-- check if player completed this quest.
			if(getPlayerStorageValue(cid, q.storageValue) == -1) then
				-- hand out reward
				if(q.rewards ~= nil) then
					for _, reward in ipairs(q.rewards) do
						doPlayerAddItem(cid, reward, 1)
						
        					doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You received a " .. getItemNameById(reward) .. ".")
        				end
        			end
        			if q.exp ~= nil then
        				doPlayerAddExperience(cid, q.exp)
        				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You received " .. q.exp .. " experience points.")
        			end
				setPlayerStorageValue(cid, q.storageValue, 1)
				doSendMagicEffect(getPlayerPosition(cid), CONST_ME_GIFT_WRAPS)
        		else
        			doPlayerSendCancel(cid, 'You have completed this quest already')
        		end
        		return true
        	end
        	return false
	]]></action>
</mod>
 
Last edited:
because its using buffer...use script instead if you use function and return true, else use _result
 
I'm getting errors when using _return. So I'll keep on using return :)
 
no.. its _result read my post...

Heres a small tutorial

well i know little about "buffer" but here is my rundown of it.

If you use "script" you include function with it and use return true/false
If you use "buffer" you dont need to include function and use _result = false/true

You probably didn't get it cause I barely did. So heres examples:

Code:
	[COLOR="Blue"]<action[/COLOR] [COLOR="Red"]itemid[/COLOR]=[COLOR="DarkOrchid"]"1981"[/COLOR] [COLOR="Red"]event[/COLOR]=[COLOR="DarkOrchid"]"buffer"[/COLOR][COLOR="Blue"]>[/COLOR][COLOR="Orange"]<![CDATA[
		if(item.actionid >= 150 and item.actionid <= 158) then
			doShowTextDialog(cid, item.itemid, getHighscoreString((item.actionid - 150)))
		else
			_result = false
		end
]]>[/COLOR][COLOR="Blue"]</action>[/COLOR]

You noticed how it didn't need to call the function OnUse? and it did not use return false, it used _result

Now a script: (Which I prefer, which is basically copy and paste from Lua to mod.)

Code:
	[COLOR="Blue"]<event [/COLOR][COLOR="Red"]type[/COLOR]=[COLOR="DarkOrchid"]"login"[/COLOR] [COLOR="Red"]name[/COLOR]=[COLOR="DarkOrchid"]"FirstItems"[/COLOR] [COLOR="Red"]event[/COLOR]=[COLOR="DarkOrchid"]"script"[/COLOR][COLOR="Blue"]>[/COLOR][COLOR="Orange"]<![CDATA[
		domodlib('firstitems_config')

		function onLogin(cid)
			if(getPlayerStorageValue(cid, config.storage) > 0) then
				return true
			end

			for _, id in ipairs(config.items) do
				doPlayerAddItem(cid, id, 1)
			end

			if(getPlayerSex(cid) == PLAYERSEX_FEMALE) then
				doPlayerAddItem(cid, 2651, 1)
			else
				doPlayerAddItem(cid, 2650, 1)
			end

			doAddContainerItem(doPlayerAddItem(cid, 1987, 1), 2674, 1)
			setPlayerStorageValue(cid, config.storage, 1)
			return true
		end
]]>[/COLOR][COLOR="Blue"]</event>[/COLOR]

You can see that it used the function line, and returns. Much easier to convert, and buffers sometimes don't work, mainly because I don't know much about them.
 
I understand what you mean. But it doesn't work. As soon as I place a _return in my code the server won't even start. Besides that return false/true without the _ works great for all my scripts.
 
omfffg reaeeeadd! RESULT_ = true, not return. And return is only for when you use "script" not buffer. >.<
 
Yea sorry, I figured after reading :) But let's keep this out of the thread from now? ^^
 
Why owned? It's off-topic. I meant that if he wanted to continue he could take it to pm. That so weird?
 
yeap, cause the forum topics arent just for you and me, they are for everyone to learn, if I show you how to make it better, I show everyone that reads this topic how to make it better. Thus teaching more than you and helping the community.
 
yeap, cause the forum topics arent just for you and me, they are for everyone to learn, if I show you how to make it better, I show everyone that reads this topic how to make it better. Thus teaching more than you and helping the community.

Bingo was his Namo.
 
Back
Top Bottom