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
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
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
Don't test it with a god character, they don't have exhaustion.