O evento se resume a cada x horário configurável, é escolhido dentre os player online, 1 pessoa e ela recebe uma surprise bag (com items aleatórios para ganhar também configurável).
Globalevents/scripts ---> lottery.lua
local config = { lottery_hour = "1 Hours", -- after how many hours should lottery begin, explains itself really... reward_count = 4, -- How much items/rewards? so you want 4 random items then write 4... website = 1 -- Doesn't need explanation } function onThink(interval, lastExecution) local players = getPlayersOnline() local list = {} for i, tid in ipairs(players) do list[i] = tid end local winner = list[math.random(1, #list)] if(config.website == 1) then db.executeQuery("INSERT INTO `lottery` (`name`) VALUES ('".. getCreatureName(winner) .."');") end doBroadcastMessage('[LOTTERY SYSTEM] Winner: '.. getCreatureName(winner) ..', Reward: Suprise Bag' ..'! - Congratulations! (Next Lottery in '.. config.lottery_hour ..')') doPlayerAddItem(winner, 6571,config.reward_count) return TRUE end
globalevents.xml
<globalevent name="lottery" interval="4050000" event="script" value="lottery.lua"/>
Actions/scripts --> surprisebag.lua
-- CREATED BY GHETTOBIRD --! local PRESENT_BLUE = {2494, 2472} -- Add more items if you want just seperate them with an item id... local PRESENT_RED = {2160, 2514} -- same as above function onUse(cid, item, fromPosition, itemEx, toPosition) local count = 1 if(item.itemid == 6570) then local randomChance = math.random(1, #PRESENT_BLUE) if(randomChance == 1) then count = 2 elseif(randomChance == 2) then count = 2 end doPlayerAddItem(cid, PRESENT_BLUE[randomChance], count) elseif(item.itemid == 6571) then local randomChance = math.random(1, #PRESENT_RED) if randomChance > 0 and randomChance < 4 then count = 2 end doPlayerAddItem(cid, PRESENT_RED[randomChance], count) end doSendMagicEffect(fromPosition, CONST_ME_GIFT_WRAPS) doRemoveItem(item.uid, 1) return true end
actions.xml
<action fromid="6570" toid="6571" event="script" value="surprisebag.lua"/>
Créditos : ghetobird