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

Lua Complete Quest action

multrayzor

New Member
Joined
Mar 17, 2014
Messages
58
Reaction score
2
So...with all the distros i used none of them came with a simple well explained quest chest action, and i didnt have any luck finding a good one, so i started working on this:

Code:
specialquests = {
{5803, 6528, 2453}, --poi
{2400, 2494, 2431, 2112} --anni
}

special = false

function onUse(cid, item, frompos, item2, topos)
   prize = item.uid
   for i, quests in ipairs(specialquests) do
     result = 0
     for j, reward in ipairs(quests) do
       result = result + getPlayerStorageValue(cid, reward)
       if reward == prize then
         special = true
         if result == -j then
           doPlayerAddItem(cid, prize, 1)
           doPlayerSendTextMessage(cid,22,'You have found something inside!')
           setPlayerStorageValue(cid, reward, 1)
           result = 0
         else
           doPlayerSendTextMessage(cid,22,"It is empty.")
         end
       else
         return 0
       end
     end
   end
   if not special and prize > 0 and prize < 9000 then
     queststatus = getPlayerStorageValue(cid,prize)

     if queststatus == -1 then
       doPlayerSendTextMessage(cid,22,'You have found something inside!')
       doPlayerAddItem(cid,prize,1)
       setPlayerStorageValue(cid,prize,1)
     else
       doPlayerSendTextMessage(cid,22,"It is empty.")
     end

     return 1
   else
     return 0
   end
end

The concept is, whichever reward you want, you just have to put it as the chest unique id, but for the quests where you have to chose from certain rewards, all you will have to do is add a list with the reward ids on this script. I havent test it yet, but would love to have some feedback on this.

Yours,
Gabe
 
after some fooling around with the script, i finished with this version:

Code:
specialquests = {
{5803, 6528, 2453}, --poi
{2400, 2494, 2431, 2112} --anni
{10544, 10545, 10546} --test
}

special = false

function onUse(cid, item, frompos, item2, topos)
   prize = item.uid
   for i, quests in ipairs(specialquests) do
     for j, reward in ipairs(quests) do
       if reward == prize
         special = true
         if getPlayerStorageValue(cid, prize) == -1 then
           doPlayerAddItem(cid, prize, 1)
           doPlayerSendTextMessage(cid,22,'You have found something inside!')
           for k, element in ipairs(specialquests[i]) do
             setPlayerStorageValue(cid, element, 1)
           end
         else
           doPlayerSendTextMessage(cid,22,"It is empty.")
         end
         break
       end
     end
   end
   if not special and prize > 0 and prize < 9000 then
     queststatus = getPlayerStorageValue(cid,prize)

     if queststatus == -1 then
       doPlayerSendTextMessage(cid,22,'You have found something inside!')
       doPlayerAddItem(cid,prize,1)
       setPlayerStorageValue(cid,prize,1)
     else
       doPlayerSendTextMessage(cid,22,"It is empty.")
     end
   end
end

Feedback is still welcome, also looking forward for making an integrated script that is easy to edit for all types of quests.
 
Back
Top