Sizaro
Advanced OT User
I want to make a system that spawns random treasure chests every (1) min on a random tile in the world (floor 7).
And if no one rightclick on the treasure chest within (1) min then it despawns and spawn on a new tile.
I think this will be a great idea for people who love to explore and let them gain a little reward now and then
btw if someone wants to use the script, feel free too ^__^
I'm guessing this can be done with globalevents but I can't figure out how >_<
I have the treasure chest already:
// Sizaro
And if no one rightclick on the treasure chest within (1) min then it despawns and spawn on a new tile.
Code:
getClosestFreeTile(cid, targetpos[, extended = false[, ignoreHouse = true]])
I think this will be a great idea for people who love to explore and let them gain a little reward now and then
btw if someone wants to use the script, feel free too ^__^
I'm guessing this can be done with globalevents but I can't figure out how >_<
I have the treasure chest already:
LUA:
local tchest1 = {2148,2152,2160}
local tchest2 = {2528,2519,2534,2462,2491,2662,2476,2487,2656,2477,2488,7730,7406,7415,7454,2392,2432,7430,8902,13872,13880,8850,8856}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local f = 1
if(item.itemid == 5675) then
local r = math.random(1,3)
if r == 1 then f = 100
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You have found 100 gold coins.')
end
if r == 2 then f = 25
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You have found 25 platinum coins.')
end
if r == 3 then f = 1
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You have found 1 crystal coin.')
end
doPlayerAddItem(cid, tchest1[r], f)
elseif(item.itemid == 5676) then
local c = math.random(1, #tchest2)
doPlayerAddItem(cid, tchest2[c], f)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You have found a ' .. getItemNameById(tchest2[c]) .. '.')
end
doRemoveItem(item.uid, 1)
doSendMagicEffect(fromPosition, CONST_ME_GIFT_WRAPS)
return true
end
// Sizaro
Last edited:
