Postado Abril 14, 2015 10 anos Ah duas versões do script, em globalevent ou talkaction use a que preferir. -- GLOBALEVENT -- globalevents.xml : <globalevent type="startup" name="RainItems" script="rainitems.lua"/> rainitems.lua local config = { items = {{8306,1}, {2157,2}, {7735,1}, {8306,1}, {2184,1}, {9932,1}, {8306,1}, {9693,1}, {2148, 100}}, interval = 1000, -- time between checks areas = { [1] = { startHour = 19, startMin = 15, waves = 10, interval = 10000, chancePerTile = 10, -- % maxItemsPerWave = 15, from = {x = 1021, y = 994, z = 7}, to = {x = 1024, y = 998, z = 7} }, [2] = { startHour = 18, startMin = 43, waves = 10, interval = 10000, chancePerTile = 10, maxItemsPerWave = 15, from = {x = 1026, y = 995, z = 7}, to = {x = 1028, y = 1001, z = 7} } } } local executed = {} function Position.isPathable(pos) local tile = Tile(pos) if tile == nil then return false end return not tile:hasFlag(TILESTATE_BLOCKSOLID) end function rainWave(arena) local from = config.areas[arena].from local to = config.areas[arena].to local items_spawned = 0 for x = from.x, to.x do for y = from.y, to.y do for z = from.z, to.z do if math.random(1, 100) < config.areas[arena].chancePerTile and items_spawned < config.areas[arena].maxItemsPerWave then local pos = {x = x, y = y, z = z} if Position(pos):isPathable() then local item = math.random(1, #config.items) doCreateItem(config.items[item][1], math.random(1, config.items[item][2]), pos) Position(pos):sendMagicEffect(CONST_ME_MAGIC_RED) items_spawned = items_spawned + 1 end end end end end end function startRain(arena) broadcastMessage("Rain item event begins!") for i = 1, config.areas[arena].waves do if i == 1 then rainWave(arena) else addEvent(rainWave, config.areas[arena].interval * (i - 1), arena) end end addEvent(broadcastMessage, config.areas[arena].interval * (config.areas[arena].waves - 1), "Rain items event ended.") end function checkRain() local hour = tonumber(os.date("%H")) local min = tonumber(os.date("%M")) if not executed[hour] then executed[hour] = {} end for i = 1, #config.areas do if hour == config.areas[i].startHour and min == config.areas[i].startMin then if not executed[hour][min] then startRain(i) addEvent(checkRain, config.interval) executed[hour][min] = true end end if tonumber(os.date("%H", os.time() + (30 * 60))) == config.areas[i].startHour and tonumber(os.date("%M", os.time() + (30 * 60))) == config.areas[i].startMin then if not executed[hour][min] then broadcastMessage("Rain items event will start in 30 minutes.") addEvent(checkRain, config.interval) executed[hour][min] = true end end if tonumber(os.date("%H", os.time() + (1 * 60))) == config.areas[i].startHour and tonumber(os.date("%M", os.time() + (1 * 60))) == config.areas[i].startMin then if not executed[hour][min] then broadcastMessage("Rain items event will start in 1 minute.") addEvent(checkRain, config.interval) executed[hour][min] = true end end end addEvent(checkRain, config.interval) end function onStartup() addEvent(checkRain, 100) end -- TALKACTION -- talkactions.xml <talkaction words="/rainitems" separator=" " script="rainitems_command.lua"/> rainitems_command.lua local config = { items = {{8306,1}, {2157,2}, {7735,1}, {8306,1}, {2184,1}, {9932,1}, {8306,1}, {9693,1}, {2148, 100}}, interval = 1000, -- time between checks areas = { [1] = { waves = 10, interval = 10000, chancePerTile = 10, -- % maxItemsPerWave = 15, from = {x = 1021, y = 994, z = 7}, to = {x = 1024, y = 998, z = 7} }, [2] = { waves = 10, interval = 10000, chancePerTile = 10, maxItemsPerWave = 15, from = {x = 1026, y = 995, z = 7}, to = {x = 1028, y = 1001, z = 7} } } } function Position.isPathable(pos) local tile = Tile(pos) if tile == nil then return false end return not tile:hasFlag(TILESTATE_BLOCKSOLID) end function rainWave(arena) local from = config.areas[arena].from local to = config.areas[arena].to local items_spawned = 0 for x = from.x, to.x do for y = from.y, to.y do for z = from.z, to.z do if math.random(1, 100) < config.areas[arena].chancePerTile and items_spawned < config.areas[arena].maxItemsPerWave then local pos = {x = x, y = y, z = z} if Position(pos):isPathable() then local item = math.random(1, #config.items) doCreateItem(config.items[item][1], math.random(1, config.items[item][2]), pos) Position(pos):sendMagicEffect(CONST_ME_MAGIC_RED) items_spawned = items_spawned + 1 end end end end end end function startRain(arena) broadcastMessage("Rain item event begins!") for i = 1, config.areas[arena].waves do if i == 1 then rainWave(arena) else addEvent(rainWave, config.areas[arena].interval * (i - 1), arena) end end addEvent(broadcastMessage, config.areas[arena].interval * (config.areas[arena].waves - 1), "Rain items event ended.") end function onSay(player, words, param) if not player:getGroup():getAccess() then return false end if tonumber(param) then startRain(tonumber(param)) else player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, words .. " eventid") end return false end Créditos zbisu. Editado Abril 14, 2015 10 anos por Linus (veja o histórico de edições) As Pessoas vivem apegadas aquilo que traduzem como correto e verdadeiro,assim elas definem a realidade. mas oque significa o correto e o verdadeiro?
Postado Abril 14, 2015 10 anos Tópico aprovado, movido para a área correta e você ganhou um rep pela contribuição, obrigado pelo conteúdo. ➥ Regras | Seções OTServ | Seções BOT
Postado Janeiro 7, 2016 9 anos tem como adaptar esse script pra 8.6?? GitHub: https://github.com/s3kk Conteúdo: [SERVER] Heromassa[GESIOR] Gesior 2012 modificado por Sekk[GESIOR] Shop Addons & Mounts - TFS 1.x[GESIOR] Outfitter para Characters e Rank[SISTEMA] Castle 24h[TALKACTION] Multi Element Wand[ACTION] Multi Elemental Arrow & Shield[PROGRAMAÇÃO] Compilar TFS 0.4 no Linux[PROGRAMAÇÃO] Compilando TFS 0.4 no MSVC(x64 e x32) [INFRAESTRUTURA] Configuração COMPLETA Google VM + Tibia 11.x
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.