Resposta ao tópico
http://www.xtibia.com/forum/topic/218216-pedido-evento-fraghora/
Informações
- É um evento simples: quem mata mais durante a duração do evento, ganha os prêmios
- Intervalo entre uma execução e outra configurável
- Duração configurável
- Feito em mod (porque é mais fácil de instalar)
- Vem com comando informativo sobre o evento
- Testado em 8.6
Código
- Crie um arquivo chamado Blood Festival.xml na sua pasta de mods com o seguinte código:
<?xml version="1.0" encoding="UTF-8"?> <!-- BLOOD FESTIVAL MOD FEITO POR LEORIC (OMEGA) Informações: http://www.xtibia.com/forum/topic/220919-the-blood-festival --> <mod name="Blood Festival" version="1.0" author="Leoric(Omega)" enabled="yes"> <config name="blood_lib"><![CDATA[ BLOOD_kills = 405050 BLOOD_global = 5152 BLOOD_time = 5153 BLOOD_config = { duration = 1 * 60 * 60, -- [1 * 60 * 60 = 1 hora] reward = {item = 1234, amount = 1, exp = 0, level = 5, money = 3000}, -- Recompensa para o vencedor do evento -- item = itemid da recompensa // amount = quantidade desse item // exp = quantidade de exp // level = quantidade de levels // money em GPs count_frags_only = false, -- [true] Conta somente frags (com skull) // [false] Conta todas as mortes PVP_enforced = true, -- [true] Tornará o servidor PVP enforced durante o evento // [false] As frags durante o evento serão contadas normalmente standard_pvp = 2, -- Se a opção acima está como true, coloque aqui o tipo de PVP do seu servidor (1 = NO-PVP, 2 = PVP, 3 = PVP-ENFORCED) -- Level mínimo para que um jogador conte como frag no evento min_level = 20, } function runBloodFestival() if getGlobalStorageValue(BLOOD_time) == -1 then setGlobalStorageValue(BLOOD_time, os.time(t)) end if os.time(t) - getGlobalStorageValue(BLOOD_time) >= BLOOD_config.duration then setGlobalStorageValue(BLOOD_time, -1) setGlobalStorageValue(BLOOD_global, -1) local winner = 0 local kills = 0 for _, pid in ipairs(getPlayersOnline()) do if getPlayerStorageValue(pid, BLOOD_kills) > kills then kills = getPlayerStorageValue(pid, BLOOD_kills) winner = pid end end if winner ~= 0 then doBroadcastMessage(getCreatureName(winner)..' has won the Blood Festival!') local reward = BLOOD_config.reward if reward.item then doPlayerAddItem(winner, reward.item, reward.amount or 1) end if reward.exp then doPlayerAddExperience(winner, reward.exp) end if reward.level then doPlayerAddSkill(winner, 8, reward.level) end if reward.money then doPlayerAddMoney(winner, reward.money) end else doBroadcastMessage('The Blood Festival has finished!') end if BLOOD_config.PVP_enforced and tonumber(BLOOD_config.standard_pvp) then setWorldType(tonumber(BLOOD_config.standard_pvp)) end return true end if getGlobalStorageValue(BLOOD_global) == -1 then doBroadcastMessage('The Blood Festival has started! Use !bloodinfo to get information about the event!') if BLOOD_config.PVP_enforced then setWorldType(WORLD_TYPE_PVP_ENFORCED) end end setGlobalStorageValue(BLOOD_global, 1) addEvent(runBloodFestival, 30000) return true end ]]></config> <globalevent name="blood_event" interval="14400000" event="script"><![CDATA[ domodlib('blood_lib') function onThink() doBroadcastMessage('The Blood Festival will start in one minute! Use !bloodinfo to get information about the event!') local func = db.query or db.executeQuery local query = func("UPDATE `player_storage` SET `value` = 0 WHERE `key` = "..BLOOD_kills..";") for _,pid in ipairs(getPlayersOnline()) do setPlayerStorageValue(pid, BLOOD_kills, 0) end addEvent(runBloodFestival, 60000) return true end ]]></globalevent> <event type="login" name="blood_login" event="script"><![CDATA[ domodlib('blood_lib') function onLogin(cid) if getGlobalStorageValue(BLOOD_global) == -1 and getPlayerStorageValue(cid, BLOOD_kills) > -1 then setPlayerStorageValue(cid, BLOOD_kills, -1) end registerCreatureEvent(cid, 'blood_kill') return true end ]]></event> <talkaction words="!bloodinfo" event="buffer"><![CDATA[ domodlib('blood_lib') local pvpname = {'NO-PVP', 'PVP', 'PVP-ENFORCED'} local active = getGlobalStorageValue(BLOOD_global) == -1 and 'OFF.' or 'ON.' local duration = getGlobalStorageValue(BLOOD_time) == -1 and '' or math.ceil((os.time(t) - getGlobalStorageValue(BLOOD_time))/60) local str = "The Blood Festival is a tournament in which you have "..math.ceil(BLOOD_config.duration / 60).. " minutes to kill as many players as you can. In the end, the winner will get a nice reward!" local str2 = "\nThe current status is: "..active local str3 = "\nOnly players level "..BLOOD_config.min_level.."+ will count for frags on the event." local str4 = active == 'OFF.' and '' or "\n"..duration.." minutes until the Blood Festival ends. PVP type is set to "..pvpname[getWorldType()].."." str = str..''..str2..''..str3..''..str4 doShowTextDialog(cid, 1965, str) return true ]]></talkaction> <event type="kill" name="blood_kill" event="script"><![CDATA[ domodlib('blood_lib') function onKill(cid, target) if not isPlayer(target) then return true elseif getGlobalStorageValue(BLOOD_global) == -1 then return true elseif BLOOD_config.count_frags_only and (getCreatureSkull(cid) < 3 or getCreatureSkull(target) >= 3) then return true elseif getPlayerLevel(target) < BLOOD_config.min_level then return true else if getPlayerStorageValue(cid, BLOOD_kills) == -1 then setPlayerStorageValue(cid, BLOOD_kills, 1) else setPlayerStorageValue(cid, BLOOD_kills, getPlayerStorageValue(cid, BLOOD_kills) + 1) end end return true end ]]></event> <globalevent name="blood_start" type="start" event="script"><![CDATA[ domodlib('blood_lib') function onStartup() if getGlobalStorageValue(BLOOD_global) > -1 then setGlobalStorageValue(BLOOD_global, -1) end return true end ]]></globalevent> </mod>
Configurações
- Configuração padrão: 1 hora de duração e 4 horas entre o início de cada evento
- A duração, os prêmios e a opção de contar somente frags unjust são feitas na primeira parte do código, chamada blood_config
- O intervalo de execução entre os eventos vem como padrão 4hs (14400000 milissegundos). Esse intervalo pode ser modificado nessa parte:
<globalevent name="blood_event" interval="14400000" event="script"><![CDATA[
Screenshot