• 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

Spo teh pro

New Member
Joined
Jan 3, 2008
Messages
319
Reaction score
1
Hello i know how to make a quest only with mapeditor

But i dont know how to make a quest that requires to have a decent level to get the reward
for example

A level 20+ is allowed to get the reward from the quest and a 1-19 not
 
Should work, untested
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)

   	if item.uid == 20003 then
   		queststatus = getPlayerStorageValue(cid,20007)
   		if queststatus == -1 and getPlayerLevel(cid) >= 20 then
			doPlayerAddItem(cid, 2533, 1)
   			doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You have a griffin shield.")
   			setPlayerStorageValue(cid,20007,1)
   		else
   			doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "It's empty")
   		else
   			doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You need level 20 to open this chest.")
   		end
	end
   	return 1
end
 
with config.


PHP:
local config = {
uniqueatchest = 20003, -- Put this Unique At Chest with map editor.
lvl = 20, -- Level Player Need. 
reward = 1111, -- id of item that player will got.
rewardcount = 1, -- count ...
itemfound = "You have a xXxX.", -- msg when player open the chest.
alreadygot = "You have already got it!", -- msg if player already completed that quest.
levelneedmsg = "You need level 20 to open this chest.", -- msg if player don't have level 20+ yet.
storage = 20003 -- stogare ID, change this for each quest.
} 

function onUse(cid, item, fromPosition, itemEx, toPosition)

if item.uid == config.uniqueatchest then
local queststatus = getPlayerStorageValue(cid, config.storage)
if queststatus == -1 and getPlayerLevel(cid) >= config.lvl then
doPlayerAddItem(cid, config.reward, config.rewardcount)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, config.itemfound)
setPlayerStorageValue(cid, config.storage ,1)
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, config.alreadygot)
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, config.levelneedmsg)
end
end
return TRUE
end
 
both script doesnt work O.o

I used 20003 as unique id in my chest
action id = 0

and there always came the error
[11/04/2009 03:14:45] data/actions/scripts/quests/banshee.lua:11: 'end' expected (to close 'if' at line 5) near 'else'
 
PHP:
local config = {
    level = 20,
    reward = { 1000 , 1 } -- itemid, count
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerStorageValue(cid, item.uid) == -1 then
        if getPlayerLevel(cid) >= config.level then
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found a " .. getItemNameById(config.reward[0]) .. ".")
            doPlayerAddItem(cid, config.reward[0], config.reward[1])
            setPlayerStorageValue(cid, item.uid, 1)
        else
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need to be atleast level " .. config.level .. " to recieve the reward.")
        end
    else
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "It is empty.")
    end
    return TRUE
end
 
This happens when i click on the quest

03:44 You have found a .

local config = {
level = 20,
reward = {2152, 100} -- itemid, count
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
if getPlayerStorageValue(cid, item.uid) == -1 then
if getPlayerLevel(cid) >= config.level then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found a " .. getItemNameById(config.reward[0]) .. ".")
doPlayerAddItem(cid, config.reward[0], config.reward[1])
setPlayerStorageValue(cid, item.uid, 1)
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need to be atleast level " .. config.level .. " to recieve the reward.")
end
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "It is empty.")
end
return TRUE
end

<action uniqueid="20003" event="script" value="quests/banshee.lua"/>

I called the file "banshee" & did inmapeditor unique id 20003

anyone knows the problem?
 
Are you using TFS 0.2? If so, please change the 'getItemNameById' function to 'getItemName'.
 
My script looks like this now
local config = {
level = 20,
reward = {2152, 100} -- itemid, count
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
if getPlayerStorageValue(cid, item.uid) == -1 then
if getPlayerLevel(cid) >= config.level then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found a " .. getItemNameById(config.reward[1]) .. ".")
doPlayerAddItem(cid, config.reward[0], config.reward[1])
setPlayerStorageValue(cid, item.uid, 1)
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need to be atleast level " .. config.level .. " to recieve the reward.")
end
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "It is empty.")
end
return TRUE
end

When i open chest it says
You have found a platinum coin.

(but i dont get anything in my bp)

This error appears
[11/04/2009 04:28:58] luaDoPlayerAddItem(). Item not found
 
Oh yeah, my bad. Was thinking PHP ;-) Anyways, better change to this.

PHP:
local config = {
    level = 20,
    reward = { 1000 , 1 } -- itemid, count
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerStorageValue(cid, item.uid) == -1 then
        if getPlayerLevel(cid) >= config.level then
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found " .. config.reward[2] .. " " .. getItemNameById(config.reward[1]) .. ".")
            doPlayerAddItem(cid, config.reward[1], config.reward[2])
            setPlayerStorageValue(cid, item.uid, 1)
        else
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need to be atleast level " .. config.level .. " to recieve the reward.")
        end
    else
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "It is empty.")
    end
    return TRUE
end
 
Moderator Message: Please create threads in the correct sections at this forum, if you need help with scripts like this, the "Request and Support" section seem to fit.

Thread moved.
 
Back
Top