-- Dice Arena Event criado por Killua, XTibia.com function onUse(cid, item, fromPosition, itemEx, toPosition) local check = 0 local players = {} if item.actionid == 8733 then for i = 1, #dice_cfg.positions_ do if isPlayer(getTopCreature(dice_cfg.positions_[i]).uid) then check = check + 1 end end if check == #dice_cfg.positions_ then if getGlobalStorageValue(182221) == -1 then for j = 1, #dice_cfg.positions_ do table.insert(players, getTopCreature(dice_cfg.positions_[j]).uid) end for e = 1, #players do if getPlayerStorageValue(players[e], 181293) > os.time() then check = check- 1 end end if check == #dice_cfg.positions_ then for u = 1, #players do doTeleportThing(players[u], dice_cfg.arena_pos, false) doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945) doPlayerSendTextMessage(players[u], MESSAGE_STATUS_CONSOLE_BLUE, "You have entered...") setGlobalStorageValue(182221, #dice_cfg.positions_ - 1) doPlayerSetStorageValue(players[u], 181293, os.time() + dice_cfg.wait_) addEvent(function() if isInArea(getThingPos(players[u]), dice_cfg.arena_frompos, dice_cfg.arena_topos) then doTeleportThing(players[u], getTownTemplePosition(getPlayerTown(players[u])), false) setGlobalStorageValue(182221, -1) removeDiceMonsters() end end, dice_cfg.max_time * 1000) end else doPlayerSendCancel(cid, "Someone from your team is already inside from last "..dice_cfg.wait_" second.") end else doPlayerSendCancel(cid, "Someone is in there, please wait...") end else doPlayerSendCancel(cid, "At least "..#dice_cfg.positions_.." are needed to enter.") end elseif item.uid == 8734 then if getPlayerStorageValue(cid, 281811) <= os.time() then doPlayerSetStorageValue(cid, 281811, os.time() + dice_cfg.wait_ - dice_cfg.wait_ / 3) local value = math.random(5792, 5797) doSendMagicEffect(fromPosition, CONST_ME_CRAPS) doTransformItem(item.uid, value) doCreatureSay(cid, getCreatureName(cid) .. " rolled a " .. value - 5791 .. ".", TALKTYPE_ORANGE_1) if dice_cfg.numbers[value - 5791] then local rand = math.random(1, #dice_cfg.numbers[value - 5791]) doCreateMonster(dice_cfg.numbers[value - 5791][rand], getClosestFreeTile(cid, fromPosition)) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You created "..dice_cfg.numbers[value - 5791][rand].."! a monster level " .. value - 5791 .. ", defeat to get a prize!") end else doPlayerSendCancel(cid, "You can only use a dice again after "..getPlayerStorageValue(cid, 281811) - os.time().." seconds.") end end return true end