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

Daily quest box? or Hourly?

Thylonn

New Member
Joined
Dec 15, 2012
Messages
52
Reaction score
3
Hey I'm looking for a chest script that would give you a reward every hour.
If possible I'd also like it to give it random rewards (Depending on the ones u put in the script)

Can someone make this?
 
Lua:
local config = {
	exhausttime = 3600, -- time in seconds
	exhauststorage = 2309
}

local rewarditems = {2152, 2498, 2492, 2488} -- add here the reward items

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

	if exhaustion.check(cid, config.exhauststorage) then
		local time = exhaustion.get(cid, config.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
	local chance = math.random(1, #rewarditems)
	local info = getItemInfo(rewarditems[chance])
	if chance == 1 then
		count = math.random(1, 50)	
		text = count .. " " .. info.plural
	else
		count = 1
                text = info.article .. " " .. info.name
	end
	local item = doCreateItemEx(rewarditems[chance], count)
	if(doPlayerAddItemEx(cid, item, false) ~= RETURNVALUE_NOERROR) then
		doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
		text = "You have found a reward. It is too heavy or you have not enough space."
	else
		text = "You have found " .. text .. "."
		exhaustion.set(cid, config.exhauststorage, config.exhausttime)
	end
	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, text)
	return true
end
 
This should work, and you can configure amounts... Edited from limos script.

Lua:
local config = {
	exhausttime = 3600, -- time in seconds --
	exhauststorage = 2309
	chance = 4 --put this for the amount of items there are.--
}
--add here the reward items--
local rewarditems = {
[1] = {item = 2152, amount = 1}
[2] = {item = 2498, amount = math.random(1,3)} 
[3] = {item = 2492, amount = 4}
[4] = {item = 2488, amount = 5}
}
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
 
	if exhaustion.check(cid, config.exhauststorage) then
		local time = exhaustion.get(cid, config.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 false
	end	
		if (config.chance == 1) then	
			text = "You have recieved a " ..rewarditems[1].item.. "!"
			doPlayerAddItem(cid, rewarditems[1].item, rewarditems[1].amount)
			doPlayerSendTextMessage(cid, 22, text)
			exhaustion.set(cid, config.exhauststorage, config.exhausttime)
		else
			text = "You have recieved a " ..rewarditems[chance].item.. "!"
			doPlayerAddItem(cid, rewarditems[chance].item, rewarditems[chance].amount)
			doPlayerSendTextMessage(cid, 22, text)
			exhaustion.set(cid, config.exhauststorage, config.exhausttime)
		end
return true
end
 
Lua:
local config = {
	exhausttime = 3600, -- time in seconds
	exhauststorage = 2309
}

local rewarditems = {2152, 2498, 2492, 2488} -- add here the reward items

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

	if exhaustion.check(cid, config.exhauststorage) then
		local time = exhaustion.get(cid, config.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
	local chance = math.random(1, #rewarditems)
	local info = getItemInfo(rewarditems[chance])
	if chance == 1 then
		count = math.random(1, 50)	
		text = count .. " " .. info.plural
	else
		count = 1
                text = info.article .. " " .. info.name
	end
	local item = doCreateItemEx(rewarditems[chance], count)
	if(doPlayerAddItemEx(cid, item, false) ~= RETURNVALUE_NOERROR) then
		doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
		text = "You have found a reward. It is too heavy or you have not enough space."
	else
		text = "You have found " .. text .. "."
		exhaustion.set(cid, config.exhauststorage, config.exhausttime)
	end
	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, text)
	return true
end


Exhaustion system does not seem to work, you can use the chest repeatedly.

This should work, and you can configure amounts... Edited from limos script.

Lua:
local config = {
	exhausttime = 3600, -- time in seconds --
	exhauststorage = 2309
	chance = 4 --put this for the amount of items there are.--
}
--add here the reward items--
local rewarditems = {
[1] = {item = 2152, amount = 1}
[2] = {item = 2498, amount = math.random(1,3)} 
[3] = {item = 2492, amount = 4}
[4] = {item = 2488, amount = 5}
}
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
 
	if exhaustion.check(cid, config.exhauststorage) then
		local time = exhaustion.get(cid, config.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 false
	end	
		if (config.chance == 1) then	
			text = "You have recieved a " ..rewarditems[1].item.. "!"
			doPlayerAddItem(cid, rewarditems[1].item, rewarditems[1].amount)
			doPlayerSendTextMessage(cid, 22, text)
			exhaustion.set(cid, config.exhauststorage, config.exhausttime)
		else
			text = "You have recieved a " ..rewarditems[chance].item.. "!"
			doPlayerAddItem(cid, rewarditems[chance].item, rewarditems[chance].amount)
			doPlayerSendTextMessage(cid, 22, text)
			exhaustion.set(cid, config.exhauststorage, config.exhausttime)
		end
return true
end

Your scripts has some comma's missing.
After adding missing comma's it still doesn't seem to work.

Would be great if any of you fix this script :(
 
Don't test it with a god character, they don't have exhaustion.
And all the changes gigastar made simply don't work, use mine, I tested it on TFS 0.3.6.
 
Uniqueid, because it's a chest. If it doesn't have an uniqueid players will be able to move it, throw it away or pick it up.
Adding an uniqueid to items in the map editor makes the item not movable anymore if it was.

You can use actionid if you want more items to work with the same script or if the item should still be movable.
Actionids can be used multiple times, uniqueids only 1x.
 
thx again @Limos , i have custom map and i put chest like quest with action id (2000) with the item on the RME, but in the game i dont recive nothing. i need to put an uniqueid? if i put an uniqueid then i need to put that uniqueid on action.xml ?
 
Actionid 2000 is for the system.lua script. With that script you need to add actionid 2000 to the chest and an uniqueid (for the storage and to make it not movable).
For other scripts like this one, only add an uniqueid to the chest(so no actionid) and add it with that uniqueid in actions.xml.
 
Last edited:
Back
Top