If I understand everything correct, I think you are putting what we have 2 systems of, 1 is just a "1 time a server" chest, and the other is a "percent to respawn type of prize. I am not sure if this will work for you, but this is what we use for 1 time per server chest:
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local player = Player(cid)
if getEternalStorageValue(77889) <= 0 then
doPlayerAddItem(cid,itemnumberofitem,1)
setEternalStorageValue(77889, 1)
broadcastMessage("The Rare Item has been found! Congratulations!", MESSAGE_STATUS_CONSOLE_ORANGE)
setPlayerStorageValue(cid, 152, 1)
else
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE,"Sorry, someone already completed the quest and got the reward.")
end
return true
end
The other normal storage is for to show in the players quest log that he is the one who got it.
Of course that can be changed to be just a thing, and activate by movement, etc.
The other one is where the item will respawn each day until taken, then after that, there has a chance every server save to respawn again, and you could set the percent to 0, but also if you decide you do want a "second" of the item for players to take, you could set the percent to 100 for a server save. In the lib, we add:
Code:
EPICQUESTS = {
{30096,1534,1412,5,2361,2.5,1548}, -- storage,pos.x,pos.y,pos.z,item,% chance of respaw, blocking item
of all your quests, then in start up:
Lua:
for i, quest in ipairs(EPICQUESTS) do
if getEternalStorageValue(quest[1]) ~= 1 then
Game.createItem(quest[5], 1, Position(quest[2], quest[3], quest[4]))
print('>> - Epic Quest: ' .. getItemNameById(quest[5]) .. ' respawned.')
else
randomValue = math.random(100)
if quest[6] >= randomValue then
setEternalStorageValue(quest[1], 0)
Game.createItem(quest[5], 1, Position(quest[2], quest[3], quest[4]))
print('>> - Epic Quest: ' .. getItemNameById(quest[5]) .. ' respawned. Chance to spawn: ' .. quest[6] .. '%. RNG ' .. randomValue .. '/100.')
else
Game.createItem(quest[7], 1, Position(quest[2], quest[3], quest[4]))
print('>> - Epic Quest: ' .. getItemNameById(quest[5]) .. ' won\'t respaw yet. Chance to spawn: ' .. quest[6] .. '%. RNG ' .. randomValue .. '/100.')
end
end
end
Then in the movements of the item:
Lua:
function onRemoveItem(item, tile, position)
gatepos = {x=612, y=367, z=8, stackpos=1}
local lock1pos = {x=573, y=366, z=4}
local lock2pos = {x=572, y=370, z=4}
local lock3pos = {x=581, y=374, z=5}
doSummonCreature("Behemoth",lock1pos)
doSummonCreature("Behemoth",lock2pos)
doSummonCreature("Behemoth",lock3pos)
doCreateItem(1548,1,gatepos)
if getEternalStorageValue(30096) ~= 1 then
setEternalStorageValue(30096, 1)
end
broadcastMessage("The Rare Item has been found! Congratulations!", MESSAGE_STATUS_CONSOLE_ORANGE)
return true
end
For this one, it also summons monsters when you get the prize, and the blocking item (1548) is needed because if not, you can put an object on the spot and move it, which will re trigger it all.
I might not fully understand what you are trying to do and what we use might not fully work, but I hope it can help to create some ideas to get success. Peonso and Kungen did the heavy thinking of this creation, so please thank them if this helps. Good luck!