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

TFS 1.0 | Rewards on Quest

CharlesHudson

Just alive, or just breathing...
Joined
Oct 25, 2011
Messages
98
Reaction score
14
HELLO everybody i hope are doing all well
I wanna ask for u help
I want to do a Quest who first give me one especific item
but after 24 hours starts to give me random items
Like
1st day > WAND VIP > get storage xxxxx
2nd day > check storage and if storage xxxxx >=1 random item from a list
and then restart on 24 hours to get another random and like that
Plz need your help i'm amateur on scripts
Thanks in advance :D
 
I can't script 1.x..
but here's how I'd do it on 0.3.7 more or less

untested..
Lua:
local storage = 45001
local time_between_uses = 60 * 60 * 24 -- 60 seconds * 60 minutes * 24 hours
local items = {{2148, 100}, {2152, 50}, {2160, 10}}

function onUse(cid, item, fromPosition, itemEx, toPosition)
   local cur_time = os.time()
   if getPlayerStorageValue(cid, storage) < 0 then
       doPlayerAddItem(cid, 2160, 1, true)
       setPlayerStorageValue(cid, storage, cur_time)
   elseif getPlayerStorageValue(cid, storage) >= cur_time + time_between_uses then
       local index = math.random(#items)
       doPlayerAddItem(cid, items[index][1], math.random(items[index][2]), true)
       setPlayerStorageValue(cid, storage, cur_time)
   else
       doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
       doPlayerSendCancel(cid, "You must wait a full 24 hours before another reward can be obtained.")
   end
   return true
end
 
I can't script 1.x..
but here's how I'd do it on 0.3.7 more or less

untested..
Lua:
local storage = 45001
local time_between_uses = 60 * 60 * 24 -- 60 seconds * 60 minutes * 24 hours
local items = {{2148, 100}, {2152, 50}, {2160, 10}}

function onUse(cid, item, fromPosition, itemEx, toPosition)
   local cur_time = os.time()
   if getPlayerStorageValue(cid, storage) < 0 then
       doPlayerAddItem(cid, 2160, 1, true)
       setPlayerStorageValue(cid, storage, cur_time)
   elseif getPlayerStorageValue(cid, storage) >= cur_time + time_between_uses then
       local index = math.random(#items)
       doPlayerAddItem(cid, items[index][1], math.random(items[index][2]), true)
       setPlayerStorageValue(cid, storage, cur_time)
   else
       doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
       doPlayerSendCancel(cid, "You must wait a full 24 hours before another reward can be obtained.")
   end
   return true
end
Thanks ;D now i have an ideam gonna start to try
 
Code:
local storage = 40006
local time_between_uses = 60 * 60 * 24 -- 60 seconds * 60 minutes * 24 hours
local items = {{8881, 5}, {16007, 5}, {22422, 10}, {9933, 10}, {2160,math.random(1, 50), 50}}
local chests = {
    [50501] = {itemid = 25958, count = 1},
    [50502] = {itemid = 25918, count = 1},  
}
 function onUse(player, item, fromPosition, target, toPosition, isHotkey)
   local cur_time = os.time()
   if getPlayerStorageValue(cid, 50502) < 0 and getPlayerStorageValue(cid, 50501) < 0 then
        local chest = chests[item.uid]
        local itemType = ItemType(chest.itemid)
        if itemType then
            local article = itemType:getArticle()
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have found ' .. (#article > 0 and article .. ' ' or '') .. itemType:getName() .. '.')
      
        player:addItem(chest.itemid, chest.count)
        player:setStorageValue(50501, 1)  
        player:setStorageValue(50502, 1)
       setPlayerStorageValue(cid, storage, cur_time)
   elseif getPlayerStorageValue(cid, storage) >= cur_time + time_between_uses then
       local index = math.random(#items)
       doPlayerAddItem(cid, items[index][1], math.random(items[index][2]), true)
       setPlayerStorageValue(cid, storage, cur_time)
   else
       doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
       doPlayerSendCancel(cid, "You must wait a full 24 hours before another reward can be obtained.")
   end
   return true
end
Anyone can help to adapt this script to TFS 1.0

SOLVED
 
Last edited:
Back
Top