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

Lua Quest storage :

Mr Zool

New Member
Joined
Jul 5, 2012
Messages
216
Reaction score
2
I just want to be possible to make this quest as many times as someone want.
Only 1 time in 5h.
Can someone help ?


Code:
-- demodras chests

function onUse(cid, item, frompos, item2, topos)


if item.uid == 1303 then

queststatus = getPlayerStorageValue(cid,5010)

if queststatus == -1 then

doPlayerSendTextMessage(cid,22,"You have found a infernal bolt.")

doPlayerAddItem(cid,6529,1)

setPlayerStorageValue(cid,5010,1)

else

doPlayerSendTextMessage(cid,22,"It is empty.")

end

elseif item.uid == 1305 then

queststatus = getPlayerStorageValue(cid,5010)

if queststatus == -1 then

doPlayerSendTextMessage(cid,22,"You have found a sprite wand.")

doPlayerAddItem(cid,2453,1)

setPlayerStorageValue(cid,5010,1)

else

doPlayerSendTextMessage(cid,22,"It is empty.")

end

elseif item.uid == 1304 then

queststatus = getPlayerStorageValue(cid,5010)

if queststatus == -1 then

doPlayerSendTextMessage(cid,22,"You have found a .")

doPlayerAddItem(cid,2507,1)

setPlayerStorageValue(cid,5010,1)

else

doPlayerSendTextMessage(cid,22,"It is empty.")

end

else

return 0

end

return 1

end
 
Code:
-- demodras chests

function onUse(cid, item, frompos, item2, topos)
local time = 500-- in seconds

if exhaustion.check(cid,5000) then
    doPlayerSendCancel(cid,"You Need To Wait "..exhaustion.get(cid,5000)..".")
    return false
    end

if item.uid == 1303 then

queststatus = getPlayerStorageValue(cid,5010)

if queststatus == -1 then

doPlayerSendTextMessage(cid,22,"You have found a infernal bolt.")

doPlayerAddItem(cid,6529,1)

setPlayerStorageValue(cid,5010,1)
exhaustion.set(cid, 5000,time)

else

doPlayerSendTextMessage(cid,22,"It is empty.")

end

elseif item.uid == 1305 then

queststatus = getPlayerStorageValue(cid,5010)

if queststatus == -1 then

doPlayerSendTextMessage(cid,22,"You have found a sprite wand.")

doPlayerAddItem(cid,2453,1)

setPlayerStorageValue(cid,5010,1)
exhaustion.set(cid, 5000,time)

else

doPlayerSendTextMessage(cid,22,"It is empty.")

end

elseif item.uid == 1304 then

queststatus = getPlayerStorageValue(cid,5010)

if queststatus == -1 then

doPlayerSendTextMessage(cid,22,"You have found a .")

doPlayerAddItem(cid,2507,1)

setPlayerStorageValue(cid,5010,1)
exhaustion.set(cid, 5000,time)

else

doPlayerSendTextMessage(cid,22,"It is empty.")

end

else

return 0

end

return 1

end
 
Hmm when i wait the time, and try pick reward again it says "Its empty"
Code:
-- rook chests



function onUse(cid, item, frompos, item2, topos)

local time = 60-- in seconds



if exhaustion.check(cid,5000) then

    doPlayerSendCancel(cid,"You Need To Wait "..exhaustion.get(cid,5000)..".")

    return false

    end



if item.uid == 1200 then



queststatus = getPlayerStorageValue(cid,5005)



if queststatus == -1 then



doPlayerSendTextMessage(cid,22,"You have found a berserk potion.")



doPlayerAddItem(cid,7439,1)



setPlayerStorageValue(cid,5005,1)

exhaustion.set(cid, 5000,time)



else



doPlayerSendTextMessage(cid,22,"It is empty.")



end



elseif item.uid == 1201 then



queststatus = getPlayerStorageValue(cid,5005)



if queststatus == -1 then



doPlayerSendTextMessage(cid,22,"You have found a mastermind potion.")



doPlayerAddItem(cid,7440,1)



setPlayerStorageValue(cid,5005,1)

exhaustion.set(cid, 5000,time)



else



doPlayerSendTextMessage(cid,22,"It is empty.")



end



elseif item.uid == 1202 then



queststatus = getPlayerStorageValue(cid,5005)



if queststatus == -1 then



doPlayerSendTextMessage(cid,22,"You have found a bullseye potion.")



doPlayerAddItem(cid,7443,1)



setPlayerStorageValue(cid,5005,1)

exhaustion.set(cid, 5000,time)



else



doPlayerSendTextMessage(cid,22,"It is empty.")



end



else



return 0



end



return 1



end
 
Removed the storage and added Limos time code (credits to her) :p
Code:
local t = {
   [1200] = {7439, 1},
   [1201] = {7440, 1},
   [1202] = {7443, 1}
}

local exhaustTime, exhaustStorage = 18000, 5000
function onUse(cid, item, fromPosition, itemEx, toPosition)
   local v = t[item.uid]   
   if exhaustion.check(cid, exhaustStorage) then
   local time = exhaustion.get(cid, exhaustStorage)
   local hours, minutes, seconds = math.floor (time / 3600), math.floor ((time - ((math.floor (time / 3600)) * 3600))/ 60), time - ((math.floor (time/60)) * 60)
   if time >= 7200 then
     text = hours.." hours, "..minutes.." minutes and "..seconds.." seconds"
   elseif time >= 3600 then
     text = hours.." hour, "..minutes.." minutes and "..seconds.." seconds"
   elseif time >= 120 then
     text = minutes.." minutes and "..seconds.." seconds"
   elseif time >= 60 then
     text = minutes.." minute and "..seconds.." seconds"
   else
     text = seconds.." seconds"
   end
   
     doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
     doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "It is empty. You need to wait " .. text .. " before you can get a reward again.")
     return true
   end
   
   doPlayerAddItem(cid, v[1], v[2])
   exhaustion.set(cid, exhaustStorage, exhaustTime)
   doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You have found a " .. getItemInfo(v[1]).name .. ".")
   return true
end
 
Oh you found my old time code version :p

This is the newer one, which I used in the time chest release.
Code:
   if exhaustion.check(cid, exhaustStorage) then
     local time = exhaustion.get(cid, exhaustStorage)
     local hours, minutes, seconds = math.floor (time / 3600), math.floor ((time - ((math.floor (time / 3600)) * 3600))/ 60), time - ((math.floor (time/60)) * 60)
     if time >= 3600 then
       text = hours.." "..(hours == 1 and "hour" or "hours")..", "..minutes.." "..(minutes == 1 and "minute" or "minutes").." and "..seconds.." "..(seconds == 1 and "second" or "seconds")
     elseif time >= 120 then
       text = minutes.." "..(minutes == 1 and "minute" or "minutes").." and "..seconds.." "..(seconds == 1 and "second" or "seconds")
     else
       text = seconds.." "..(seconds == 1 and "second" or "seconds")
     end

     doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
     doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "It is empty. You need to wait "..text.." before you can get a reward again.")
     return true
   end

In total with Ninja's script.
Code:
local t = {
     [1200] = {7439, 1},
     [1201] = {7440, 1},
     [1202] = {7443, 1}
}

local exhaustTime, exhaustStorage = 18000, 5000
function onUse(cid, item, fromPosition, itemEx, toPosition)
   local v = t[item.uid]
   if exhaustion.check(cid, exhaustStorage) then
     local time = exhaustion.get(cid, exhaustStorage)
     local hours, minutes, seconds = math.floor (time / 3600), math.floor ((time - ((math.floor (time / 3600)) * 3600))/ 60), time - ((math.floor (time/60)) * 60)
     if time >= 3600 then
       text = hours.." "..(hours == 1 and "hour" or "hours")..", "..minutes.." "..(minutes == 1 and "minute" or "minutes").." and "..seconds.." "..(seconds == 1 and "second" or "seconds")
     elseif time >= 120 then
       text = minutes.." "..(minutes == 1 and "minute" or "minutes").." and "..seconds.." "..(seconds == 1 and "second" or "seconds")
     else
       text = seconds.." "..(seconds == 1 and "second" or "seconds")
     end

     doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
     doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "It is empty. You need to wait "..text.." before you can get a reward again.")
     return true
   end

   doPlayerAddItem(cid, v[1], v[2])
   exhaustion.set(cid, exhaustStorage, exhaustTime)
   doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You have found a " .. getItemInfo(v[1]).name .. ".")
   return true
end
 
Dont works i get this Error :
Loading Actions.... [Error -LuaInterface::loadfile] Data/actions/scripts/ani_solo/Ani_Solo_QuestRewards.lua:11: `=`expected near ònUse`
Cannot Load Script
Help me please


Actions.xml
Code:
    <action uniqueid="11014" script="ani_solo/ani_solo.lua"/>
    <action uniqueid="11015" script="ani_solo/Ani_solo_QuestRewards.lua"/>

Ani_solo_QuestRewards.lua

Code:
----------------chestid--------item_given----------------
local chest1 = {itemid = 1740, reward = 2436}
local chest2 = {itemid = 1740, reward = 2392}
local chest3 = {itemid = 1740, reward = 2430}
local chest4 = {itemid = 1740, reward = 7438}

local HAS_CHOSEN = 32247

local uniqueid = 11015

fucntion onUse(cid, words, param, channel)
if getPlayerStorageValue(cid, HAS_CHOSEN) == 0 then
  if item.itemid == chest1.itemid then
    if item.uid == uniqueid then
      doplayerAddItem(cid, chest1.reward, 1)
      doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_GREEN, "Congratulations you have recived your item.")
      doSendMagicEffect(getPlayerPosition(cid), 11)
      setPlayerStorageValue(cid, HAS_CHOSEN, 1)
    end
  elseif item.itemid == chest2.itemid then
    if item.uid == uniqueid then
      doplayerAddItem(cid, chest2.reward, 1)
      doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_GREEN, "Congratulations you have recived your item.")
      doSendMagicEffect(getPlayerPosition(cid), 12)
      setPlayerStorageValue(cid, HAS_CHOSEN, 1)
    end
  elseif item.itemid == chest3.itemid then
    if item.uid == uniqueid then
      doplayerAddItem(cid, chest3.reward, 1)
      doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_GREEN, "Congratulations you have recived your item.")
      doSendMagicEffect(getPlayerPosition(cid), 13)
      setPlayerStorageValue(cid, HAS_CHOSEN, 1)
    end
  elseif item.itemid == chest4.itemid then
    if item.uid == uniqueid then
      doplayerAddItem(cid, chest4.reward, 1)
      doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_GREEN, "Congratulations you have recived your item.")
      doSendMagicEffect(getPlayerPosition(cid), 14)
      setPlayerStorageValue(cid, HAS_CHOSEN, 1)
    end
  end
else
  doPlayerSendCancel(cid, "You have already chosen your item.")
return false
end
return true
end
 
Code:
fucntion onUse(cid, words, param, channel)
to
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
 
Last edited:
I made it from scratch cba to fix your script, as it doesn't work this way at all.
Code:
local config =
{
   storage = 32247,
   itemId = 1740,
   [11015] = {item = 2436, count = 1},
   [11016] = {item = 2392, count = 1},
   [11017] = {item = 2430, count = 1},
   [11018] = {item = 7438, count = 1}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
   if config.itemId == item.itemid then
     if getPlayerStorageValue(cid, config.storage) == -1 then
       if config[item.uid] then
         doPlayerAddItem(cid, config[item.uid].item, config[item.uid].count)
         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_GREEN, "Congratulations you have recived your item.")
         doSendMagicEffect(getPlayerPosition(cid), 11)
         setPlayerStorageValue(cid, config.storage, 1)
       end
     else
       doPlayerSendCancel(cid, "You already claimed your reward")
     end
   end
   return true
end
Just give all of the 4 chests the different unique id from 11015-11018 and then it should be working
 
Back
Top