Postado Janeiro 14, 2015 10 anos Pessoal estou pedindo a ajuda de vocês pois já testei varios MOD do Rush War e não tem como funcionar perfeitamente, uso TFS 0.4 3777, 8.60, eis que o evento começa, todos os chars se registrão, todos sao teletransportado para a sala de espera, o evento começa, a separação dos times esta tudo certo, quando um player mata outro tambem está certo, a questão é que depois de um tempo ele da o RESULTADO do evento e não marca as mortes, fica 0 para cada team, e mesmo depois de ter matado todos os adversarios o evento nao termina... fiz o teste com 2vs2, com quantia de frag para ganhar 2, ou seja quando um time mata o outro o evento teria que terminar, mas isso não acontece, segue o MOD: <?xml version="1.0" encoding="ISO-8859-1"?> <mod name="Rush Event" version="1.0" author="ChaitoSoft.com" contact="[email protected]" enabled="yes"> <description> TUTORIAL DE COMO CONFIGURAR O EVENTO ACOMPANHE POR AQUI: q - mensagem que vai ser exibida quando o evento começar d_1 - posição do tempo vermelho ao começar evento d_2 - posição do tempo azul ao começar evento x - mensagem que vai ser exibida quando o evento não começar w - posição da sala de espera, onde os players vão ficar antes de começar lvl - level minimo para participar do evento v - a quantidade de frags que será necessária para o time ganhar mn - quantidade minima de players para começar o evento m - maximo de players dentro do evento o - mensagem exibida quando o time vermelho ganhar y - mensagem exibida quando o time azul ganhar i_1 - id do premio (agora é crystal coin = 2160) i_2 - quantidade do premio (agora esta 10 crystal coins) t - tempo para começar o evento (agora esta is 5 minutos) r - tempo em que os resultados da batalha serão mostrados aos players (agora esta 3 minutos) Adicione isto em 050-function.lua: ------------------------------------------------------------------------------------------------- function doPlayerRemoveLethalConditions(cid) local tmp = {1, 2, 4, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 32768, 65536} for i = 1, #tmp do if(hasCondition(cid, tmp[i])) then doRemoveCondition(cid, tmp[i]) end end return true end ------------------------------------------------------------------------------------------------- Adicione isto em login.lua: ------------------------------------------------------------------------------------------------- registerCreatureEvent(cid, "RushCombat") registerCreatureEvent(cid, "RushAttack") registerCreatureEvent(cid, "RushDead") registerCreatureEvent(cid, "RushOutfit") ------------------------------------------------------------------------------------------------- Agora daqui pra baixo você vai configurar de acordo com o tutorial acima, o resto se não tiver conhecimento não mecha em nada pois poderá bugar o evento e não daremos suporte: --Day of Week in Number para o EVENT_DAY -- Domingo, Segunda, Terca, Quarta, Quinta, Sexta, Sabado -- Sunday - 0, Monday - 1, Tuesday - 2, Wednesday - 3, Thursday - 4, Friday - 5 Saturday - 6 </description> <config name="re"><![CDATA[ t = { a = 32145, g = 32146, l = 32147, u = 32148, h = 32149, wv = 32150, c = 0, q = "Desert Battle Event has been started! Enjoy and have fun!", f = 5447, f_1 = 5448, f_2 = 5449, d_1 = {x = 728, y = 1953, z = 7}, -- red temple d_2 = {x = 680, y = 1983, z = 7}, -- blue temple x = "O evento nao aconteceu porque poucas pessoas participaram.", w = {x = 698, y = 1918, z = 7}, lvl = 8, v = 2, mn = 4, m = 40, o = "Event was completed, RED TEAM has won Desert Battle Event!", y = "Event was completed, BLUE TEAM has won Desert Battle Event!", i_1 = 2160, i_2 = 100, t = 5, r = 3, EVENT_DAY = {1,3,5} } ]]></config> <globalevent name="Recognition" interval="150000" event="script"><![CDATA[ domodlib('re') function onThink(interval, lastExecution, thinkInterval) if(getGlobalStorageValue(t.a) == 1) then for _, pid in ipairs(getPlayersOnline()) do if getPlayerStorageValue(pid, t.f) == 1 then if(getPlayerStorageValue(pid, t.f_1) == 0) then doSendAnimatedText(getCreaturePosition(pid), "RED TEAM", TEXTCOLOR_RED) elseif(getPlayerStorageValue(pid, t.f_1) == 1) then doSendAnimatedText(getCreaturePosition(pid), "BLUE TEAM", TEXTCOLOR_LIGHTBLUE) end end end return true end return true end ]]></globalevent> <talkaction words="!desert1" event="script"><![CDATA[ domodlib('re') function onSay(cid, words, param, channel) if getPlayerGroupId(cid) > 3 then setGlobalStorageValue(t.g, 1) setGlobalStorageValue(t.u, 0) setGlobalStorageValue(t.l, 0) setGlobalStorageValue(t.a, 1) setGlobalStorageValue(t.c, 0) setGlobalStorageValue(t.wv, 0) doBroadcastMessage("Attention! Immediately register to Desert Battle Event, event will start for ".. t.t .." minutes. All players can join to event typing this command: !desert", MESSAGE_STATUS_WARNING) addEvent(function() doBroadcastMessage("Desert Battle event, started in 2 minutes. If you want to join, type this command: !desert", MESSAGE_STATUS_WARNING) end, (t.t - 2) * 1000 * 60) addEvent(function() doBroadcastMessage("Desert Battle event, started in a minute. If you want to join, type this command: !desert", MESSAGE_STATUS_WARNING) end, (t.t - 1) * 1000 * 60) addEvent(start, t.t * 1000 * 60) return true end return true end function results() if(getGlobalStorageValue(t.a) == 1) then local red = getGlobalStorageValue(t.l) local blue = getGlobalStorageValue(t.u) doBroadcastMessage("Desert Battle Events, results:\nRed Team scored: ".. red .." frags.\nBlue Team scored: ".. blue .." frags.\nMatch is under way to ".. t.v .." frags.", MESSAGE_STATUS_WARNING) addEvent(results, t.r * 1000 * 60) end end function start() if(getGlobalStorageValue(t.a) == 1 and getGlobalStorageValue(t.c) >= t.mn) then doBroadcastMessage(t.q, MESSAGE_STATUS_WARNING) setGlobalStorageValue(t.wv, 1) addEvent(results, t.r * 1000 * 60) for _, pid in ipairs(getPlayersOnline()) do local red = {lookType = 268, lookHead = 94, lookBody = 94, lookLegs = 114, lookFeet = 94, lookAddons = 3} local blue = {lookType = 268, lookHead = 39, lookBody = 88, lookLegs = 0, lookFeet = 19, lookAddons = 3} if getPlayerStorageValue(pid, t.f) == 1 then doCreatureAddHealth(pid, getCreatureMaxHealth(pid)) doCreatureAddMana(pid, getCreatureMaxMana(pid)) if((getPlayerStorageValue(pid, t.g) % 2) == 1) then doSetCreatureOutfit(pid, red, 5000 * 1000) setPlayerStorageValue(pid, t.h, 0) doTeleportThing(pid, t.d_1) setPlayerStorageValue(pid, t.f, 1) setPlayerStorageValue(pid, t.f_1, 0) setPlayerStorageValue(pid, t.f_2, 1) doSendMagicEffect(getCreaturePosition(pid), 10) doPlayerSendTextMessage(pid, MESSAGE_EVENT_ADVANCE, "You are in RED TEAM!\nThis battle will continue up to ".. t.v .." frags!") else doSetCreatureOutfit(pid, blue, 5000 * 1000) doTeleportThing(pid, t.d_2) setPlayerStorageValue(pid, t.h, 0) setPlayerStorageValue(pid, t.f, 1) setPlayerStorageValue(pid, t.f_1, 1) setPlayerStorageValue(pid, t.f_2, 0) doSendMagicEffect(getCreaturePosition(pid), 10) doPlayerSendTextMessage(pid, MESSAGE_EVENT_ADVANCE, "You are in BLUE TEAM!\nThis battle will continue up to ".. t.v .." frags!") end end end elseif(getGlobalStorageValue(t.c) < t.mn) then doBroadcastMessage(t.x, MESSAGE_STATUS_WARNING) setGlobalStorageValue(t.a, 0) for _, pid in ipairs(getPlayersOnline()) do if getPlayerStorageValue(pid, t.f) == 1 then setPlayerStorageValue(pid, t.f, -1) doTeleportThing(pid, getTownTemplePosition(getPlayerTown(pid))) doSendMagicEffect(getCreaturePosition(pid), CONST_ME_TELEPORT) end end end end ]]></talkaction> <globalevent name="RushStart" time="02:23:01" event="script"><![CDATA[ domodlib('re') function onTime(interval, lastExecution) if(getRushEventOpenDay() == false) then return true; end setGlobalStorageValue(t.g, 1) setGlobalStorageValue(t.u, 0) setGlobalStorageValue(t.l, 0) setGlobalStorageValue(t.a, 1) setGlobalStorageValue(t.c, 0) setGlobalStorageValue(t.wv, 0) doBroadcastMessage("Attention! Immediately register to Desert Battle Event, event will start for ".. t.t .." minutes. All players can join to event typing this command: !desert", MESSAGE_STATUS_WARNING) addEvent(start, t.t * 1000 * 60) return true end function results() if(getGlobalStorageValue(t.a) == 1) then local red = getGlobalStorageValue(t.l) local blue = getGlobalStorageValue(t.u) doBroadcastMessage("Desert Battle Events, results:\nRed Team scored: ".. red .." frags.\nBlue Team scored: ".. blue .." frags.\nMatch is under way to ".. t.v .." frags.", MESSAGE_STATUS_WARNING) addEvent(results, t.r * 1000 * 60) end end function getRushEventOpenDay() for i = 1, #t.EVENT_DAY do if(tostring(t.EVENT_DAY[i]) == os.date("%w")) then return true end end return false end function start() if(getGlobalStorageValue(t.a) == 1 and getGlobalStorageValue(t.c) >= t.mn) then doBroadcastMessage(t.q, MESSAGE_STATUS_WARNING) setGlobalStorageValue(t.wv, 1) addEvent(results, t.r * 1000 * 60) for _, pid in ipairs(getPlayersOnline()) do local red = {lookType = 268, lookHead = 94, lookBody = 94, lookLegs = 114, lookFeet = 94, lookAddons = 3} local blue = {lookType = 268, lookHead = 39, lookBody = 88, lookLegs = 0, lookFeet = 19, lookAddons = 3} if getPlayerStorageValue(pid, t.f) == 1 then doCreatureAddHealth(pid, getCreatureMaxHealth(pid)) doCreatureAddMana(pid, getCreatureMaxMana(pid)) if((getPlayerStorageValue(pid, t.g) % 2) == 1) then doSetCreatureOutfit(pid, red, 5000 * 1000) setPlayerStorageValue(pid, t.h, 0) doTeleportThing(pid, t.d_1) doRemoveCondition(pid, CONDITION_INFIGHT) setPlayerStorageValue(pid, t.f, 1) setPlayerStorageValue(pid, t.f_1, 0) setPlayerStorageValue(pid, t.f_2, 1) doSendMagicEffect(getCreaturePosition(pid), 10) doPlayerSendTextMessage(pid, MESSAGE_EVENT_ADVANCE, "You are in RED TEAM!\nThis battle will continue up to ".. t.v .." frags!") else doSetCreatureOutfit(pid, blue, 5000 * 1000) setPlayerStorageValue(pid, t.h, 0) doTeleportThing(pid, t.d_2) doRemoveCondition(pid, CONDITION_INFIGHT) setPlayerStorageValue(pid, t.f, 1) setPlayerStorageValue(pid, t.f_1, 1) setPlayerStorageValue(pid, t.f_2, 0) doSendMagicEffect(getCreaturePosition(pid), 10) doPlayerSendTextMessage(pid, MESSAGE_EVENT_ADVANCE, "You are in BLUE TEAM!\nThis battle will continue up to ".. t.v .." frags!") end end end elseif(getGlobalStorageValue(t.c) < t.mn) then doBroadcastMessage(t.x, MESSAGE_STATUS_WARNING) setGlobalStorageValue(t.a, 0) for _, pid in ipairs(getPlayersOnline()) do if getPlayerStorageValue(pid, t.f) == 1 then setPlayerStorageValue(pid, t.f, -1) doTeleportThing(pid, getTownTemplePosition(getPlayerTown(pid))) doRemoveCondition(pid, CONDITION_INFIGHT) doSendMagicEffect(getCreaturePosition(pid), CONST_ME_TELEPORT) end end end end ]]></globalevent> <talkaction words="!desert" event="script"><![CDATA[ domodlib('re') function onSay(cid, words, param, channel) if getGlobalStorageValue(t.a) == 1 and getGlobalStorageValue(t.wv) ~= 1 then if getPlayerLevel(cid) >= t.lvl then if getPlayerStorageValue(cid, t.f) == -1 then if getTilePzInfo(getPlayerPosition(cid)) == true then if getGlobalStorageValue(t.c) < t.m then setGlobalStorageValue(t.c, getGlobalStorageValue(t.c)+1) if getGlobalStorageValue(t.c) == t.m then doPlayerSendCancel(cid, "Event is full [" .. getGlobalStorageValue(t.c) .. " players]!") else doBroadcastMessage("" .. getPlayerName(cid) .. " has joined to Desert Battle! Actually we have: " .. getGlobalStorageValue(t.c) .. " players!", 19) end setPlayerStorageValue(cid, t.f, 1) setPlayerStorageValue(cid, t.h, -1) doTeleportThing(cid, t.w) doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT) setPlayerStorageValue(cid, t.g, getGlobalStorageValue(t.g)) setGlobalStorageValue(t.g, tonumber(getGlobalStorageValue(t.g))+1) else doPlayerSendCancel(cid, "Event is full [" .. getGlobalStorageValue(t.c) .. " players]!") return true end else doPlayerSendCancel(cid, "You must be in protection zone.") return true end else doPlayerSendCancel(cid, "You are already registered in this event.") return true end else doPlayerSendCancel(cid, "Your level is too low to participate in this event.") return true end else doPlayerSendCancel(cid, "At the moment there are no records for this event.") return true end return true end ]]></talkaction> <event type="combat" name="RushCombat" event="script"><![CDATA[ domodlib('re') function onCombat(cid, target) if(getGlobalStorageValue(t.a) == 1) then if isPlayer(cid) and isPlayer(target) then if getPlayerStorageValue(cid, t.f) == 1 and getPlayerStorageValue(target, t.f) == 1 then if getPlayerStorageValue(cid, t.f_1) == getPlayerStorageValue(target, t.f_1) then return doPlayerSendCancel(cid, "Sorry, you cannot attack your own team.") and false end end end end return true end ]]></event> <event type="attack" name="RushAttack" event="script"><![CDATA[ domodlib('re') function onAttack(cid, target) if(getGlobalStorageValue(t.a) == 1) then if isPlayer(cid) and isPlayer(target) then if getPlayerStorageValue(cid, t.f) == 1 and getPlayerStorageValue(target, t.f) == 1 then if getPlayerStorageValue(cid, t.f_1) == getPlayerStorageValue(target, t.f_1) then return doPlayerSendCancel(cid, "Sorry, you cannot attack your own team.") and false end end end end return true end ]]></event> <event type="preparedeath" name="RushDead" event="script"><![CDATA[ domodlib('re') function onPrepareDeath(cid, deathList) if(not isPlayer(cid)) or (getGlobalStorageValue(t.a) ~= 1) or (getPlayerStorageValue(cid, t.f) ~= 1) then return true end if getGlobalStorageValue(t.a) == 1 then local strings = {""} local j, position, corpse = 1, 1, 0 for _, pid in ipairs(deathList) do if isCreature(pid) == true then strings[position] = j == 1 and "" or strings[position] .. ", " strings[position] = strings[position] .. getCreatureName(pid) .. "" j = j + 1 else strings[position] = j == 1 and "" or strings[position] .. ", " strings[position] = strings[position] .."a field item" j = j + 1 end end for i, str in ipairs(strings) do if(str:sub(str:len()) ~= ",") then str = str .. "." end desc = "You recognize " desc = desc .. "" .. getCreatureName(cid) .. ". He was killed by " .. str end if(getPlayerSex(cid) == 1) then corpse = doCreateItem(3058, getCreaturePosition(cid)) else corpse = doCreateItem(3065, getCreaturePosition(cid)) end doItemSetAttribute(corpse, "description", desc) if((getPlayerStorageValue(cid, t.g) % 2) == 1) then setGlobalStorageValue(t.u, getGlobalStorageValue(t.u)+1) else setGlobalStorageValue(t.l, getGlobalStorageValue(t.l)+1) end local red = getGlobalStorageValue(t.l) local blue = getGlobalStorageValue(t.u) if blue < t.v or red < t.v then if(isPlayer(cid) == false) then return true end local redoutfit = {lookType = 268, lookHead = 94, lookBody = 94, lookLegs = 114, lookFeet = 94, lookAddons = 3} local blueoutfit = {lookType = 268, lookHead = 39, lookBody = 88, lookLegs = 0, lookFeet = 19, lookAddons = 3} if((getPlayerStorageValue(cid, t.g) % 2) == 1) then doTeleportThing(cid, t.d_1) doRemoveCondition(cid, CONDITION_INFIGHT) doSendMagicEffect(getCreaturePosition(cid), 10) doCreatureAddHealth(cid, getCreatureMaxHealth(cid), MAGIC_EFFECT_UNKNOWN, COLOR_UNKNOWN, true) doCreatureAddMana(cid, getCreatureMaxMana(cid)) doPlayerRemoveLethalConditions(cid) if getCreatureSkullType(cid) == SKULL_WHITE then doCreatureSetSkullType(cid, 0) end doSetCreatureOutfit(cid, redoutfit, 5000 * 1000) else doTeleportThing(cid, t.d_2) doRemoveCondition(cid, CONDITION_INFIGHT) doSendMagicEffect(getCreaturePosition(cid), 10) doCreatureAddHealth(cid, getCreatureMaxHealth(cid), MAGIC_EFFECT_UNKNOWN, COLOR_UNKNOWN, true) doCreatureAddMana(cid, getCreatureMaxMana(cid)) doPlayerRemoveLethalConditions(cid) if getCreatureSkullType(cid) == SKULL_WHITE then doCreatureSetSkullType(cid, 0) end doSetCreatureOutfit(cid, blueoutfit, 5000 * 1000) end end if blue >= t.v then doBroadcastMessage(t.y, MESSAGE_STATUS_WARNING) setGlobalStorageValue(t.h, 1) for _, pid in ipairs(getPlayersOnline()) do if(getPlayerStorageValue(pid, t.f_1) == 1) then doPlayerAddItem(pid, t.i_1, t.i_2) doPlayerAddItem(pid, 8306, 1) end end elseif red >= t.v then doBroadcastMessage(t.o, MESSAGE_STATUS_WARNING) setGlobalStorageValue(t.h, 1) for _, pid in ipairs(getPlayersOnline()) do if(getPlayerStorageValue(pid, t.f_2) == 1) then doPlayerAddItem(pid, t.i_1, t.i_2) doPlayerAddItem(pid, 8306, 1) end end end if getGlobalStorageValue(t.h) == 1 then setGlobalStorageValue(t.a, 0) setGlobalStorageValue(t.h, 0) setGlobalStorageValue(t.wv, -1) setPlayerStorageValue(cid, t.f, -1) setPlayerStorageValue(cid, t.g, 0) setPlayerStorageValue(cid, t.l, 0) setPlayerStorageValue(cid, t.u, 0) setPlayerStorageValue(cid, t.f_1, -1) setPlayerStorageValue(cid, t.f_2, -1) setPlayerStorageValue(cid, t.h, -1) doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), true) doRemoveCondition(cid, CONDITION_INFIGHT) doSendMagicEffect(getCreaturePosition(cid), 10) doCreatureAddHealth(cid, getCreatureMaxHealth(cid), MAGIC_EFFECT_UNKNOWN, COLOR_UNKNOWN, true) doCreatureAddMana(cid, getCreatureMaxMana(cid)) doPlayerRemoveLethalConditions(cid) for _, pid in ipairs(getPlayersOnline()) do if(getPlayerStorageValue(pid, t.f_1) == 1 or getPlayerStorageValue(pid, t.f_2) == 1) then setPlayerStorageValue(pid, t.f, -1) doTeleportThing(pid, getTownTemplePosition(getPlayerTown(pid))) doRemoveCondition(pid, CONDITION_INFIGHT) doSendMagicEffect(getCreaturePosition(pid), CONST_ME_TELEPORT) setPlayerStorageValue(pid, t.g, 0) setPlayerStorageValue(pid, t.l, 0) setPlayerStorageValue(pid, t.u, 0) setPlayerStorageValue(pid, t.f_1, -1) setPlayerStorageValue(pid, t.f_2, -1) setPlayerStorageValue(pid, t.h, -1) doCreatureAddHealth(pid, getCreatureMaxHealth(pid), MAGIC_EFFECT_UNKNOWN, COLOR_UNKNOWN, true) doCreatureAddMana(pid, getCreatureMaxMana(pid)) doPlayerRemoveLethalConditions(pid) doRemoveCondition(pid, CONDITION_OUTFIT) end end return false end return false end return true end ]]></event> <event type="outfit" name="RushOutfit" event="script"><![CDATA[ domodlib('re') function onOutfit(cid, old, current) if(getGlobalStorageValue(t.a) == 1) then if getPlayerGroupId(cid) > 3 then return true end if getPlayerStorageValue(cid, t.h) == 0 then if getPlayerStorageValue(cid, t.f) > -1 then doPlayerSendCancel(cid, "You cannot change your outfit during the event.") return false end end end return true end ]]></event> </mod> Agradeço a ajuda de todos! up
Postado Janeiro 15, 2015 10 anos Só pra ter ctz... Vc adicionou isso em 050-function.lua? : function doPlayerRemoveLethalConditions(cid) local tmp = {1, 2, 4, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 32768, 65536} for i = 1, #tmp do if(hasCondition(cid, tmp[i])) then doRemoveCondition(cid, tmp[i]) end end return true end E isso em login.lua? registerCreatureEvent(cid, "RushCombat") registerCreatureEvent(cid, "RushAttack") registerCreatureEvent(cid, "RushDead") registerCreatureEvent(cid, "RushOutfit") Só estou perguntando pq pode ser que vc não tenha visto isso dentro do arquivo. Tenha só copiado e colado sem passar a vista... Te ajudei?? REP + e ficamos quites... http://www.tibiaking.com/forum/uploads/emoticons/default_happyy.png' alt=';D'> Atenciosamente, Daniel. Abraços! Meus tutoriais: Programação: Resolvendo QUALQUER erro na data base. Scripts (system's, creaturescripts, mod's, NPC's, etc): (Sistema) GOD Ambient Light Full. Adicionando novas mounts ao servidor [NPC] Papai Noel que dá presente todo ano. Web-site: Resolvendo problema de caracteres especiais em PHP Formatando textos em PHP! Mudando a cor, tamanho, fonte, etc. Criando e configurando tabelas para paginas PHP
Postado Janeiro 15, 2015 10 anos Autor Sim dani, ta tudo adicionado... Pessoal mechi algumas linhas e agora esta funcionando, porem ao termino do Evento o time Ganhador é mandado para o Templo e ganha a recompensa, mas o time que perde ainda fica no Evento, como faço para o time perdedor tambem ir para o templo? esse é o Evento funcionando agora: <?xml version="1.0" encoding="UTF-8"?> <mod name="Rush Event" version="1.0.0" author="VirrageS" enabled="yes"> <config name="config_rush_event"> <![CDATA[ configRushEvent = { storages = { main = 'rushEventMain', -- set free storage player = 'rushEventPlayer', -- set free storage joining = 'rushEventJoining', -- set free storage b_score = 'rushEventBlueScore', -- set free storage r_score = 'rushEventRedScore', -- set free storage exhaust = 'rushEventExhaust', countEvent = 'rushEventCountEvent' }, position = { blue = {x=732, y=1953, z=6}, -- posiotion to which player is teleporting red = {x=680, y=1981, z=6} -- posiotion to which player is teleporting }, room = { from = {x=663,y=1938,z=7}, -- left top corner of event room to = {x=749,y=2005,z=7} -- right bottom corner of event room }, rewards = {7720, 2157}, -- reward id which player can win (reward is random) players = { max = 30, min = 2, minLevel = 8 }, days = { ['Monday'] = {'21:00:00'}, ['Tuesday'] = {'17:00:00'}, ['Thursday'] = {'17:00:20'} }, fragLimit = 2, -- frag limit waitTime = 10, -- sekundy [ile gracz ma czekac jak padnie] delayTime = 3.0, -- time in which players who joined to event are teleporting to teleport position [miuntes] startEvent = 1, -- time from teleport to start event [seconds] stopEvent = 600, -- [seconds] text = 'Walka przez 10min lub 100 fragow, bez ue.' } ]]> </config> <lib name="lib_rush_event"> <![CDATA[ domodlib('config_rush_event') local conditionBlue = createConditionObject(CONDITION_OUTFIT) setConditionParam(conditionBlue, CONDITION_PARAM_TICKS, -1) addOutfitCondition(conditionBlue, {lookType = 130, lookHead = 87, lookBody = 87, lookLegs = 87, lookFeet = 87}) local conditionRed = createConditionObject(CONDITION_OUTFIT) setConditionParam(conditionRed, CONDITION_PARAM_TICKS, -1) addOutfitCondition(conditionRed, {lookType = 130, lookHead = 94, lookBody = 94, lookLegs = 94, lookFeet = 94}) function doStartRushEvent() doSetStorage(configRushEvent.storages.joining, -1) if configRushEvent.players.min <= doCountPlayersRushEvent()[1] then for _, cid in ipairs(getPlayersOnline()) do local p = tostring(getCreatureStorage(cid, configRushEvent.storages.player)) if p ~= '' then doTeleportThing(cid, p ~= 'blue' and configRushEvent.position.red or configRushEvent.position.blue) doCreatureSetNoMove(cid, false) doRemoveCondition(cid, CONDITION_INFIGHT) doAddCondition(cid, p ~= 'blue' and conditionRed or conditionBlue) doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, 'Get ready. Rush Event starts in '..configRushEvent.startEvent..' seconds.') end end addEvent(doSetStorage, configRushEvent.startEvent * 1000, configRushEvent.storages.main, 1) addEvent(doStopRushEvent, configRushEvent.stopEvent * 1000) doBroadcastMessage('Rush Event has started. LET\'S GO!') else for _, cid in ipairs(getPlayersOnline()) do if tostring(getCreatureStorage(cid, configRushEvent.storages.player)) ~= '' then doCreatureSetNoMove(cid, false) doRemoveCondition(cid, CONDITION_INFIGHT) doCreatureSetStorage(cid, configRushEvent.storages.player, '') end end doBroadcastMessage('Rush Event hasn\'t started beacuse there not were enough players.') end end function doStopRushEvent() if getStorage(configRushEvent.storages.main) > 0 then local team = nil if getStorage(configRushEvent.storages.b_score) == configRushEvent.fragLimit then team = 'blue' elseif getStorage(configRushEvent.storages.r_score) == configRushEvent.fragLimit then team = 'red' else if getStorage(configRushEvent.storages.r_score) >= getStorage(configRushEvent.storages.b_score) then team = 'red' else team = 'blue' end end local prize = math.random(#configRushEvent.rewards) for _, cid in ipairs(getPlayersOnline()) do if isInRange(getThingPos(cid), configRushEvent.room.from, configRushEvent.room.to) then if team == tostring(getCreatureStorage(cid, configRushEvent.storages.player)) then doPlayerAddItem(cid, configRushEvent.rewards[prize], 1) doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, 'Your team won! You have received '.. getItemNameById(configRushEvent.rewards[prize]) ..' as reward.') end doCreatureAddHealth(cid, getCreatureMaxHealth(cid) - getCreatureHealth(cid)) doCreatureAddMana(cid, getCreatureMaxMana(cid) - getCreatureMana(cid)) doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid))) doCreatureSetStorage(cid, configRushEvent.storages.player, '') doRemoveCondition(cid, CONDITION_OUTFIT) end end doBroadcastMessage('Rush Event has finished. The winner is '..team..' team ('..getStorage(configRushEvent.storages.r_score)..':'..getStorage(configRushEvent.storages.b_score)..'). Congratulations!') db.query("INSERT INTO `events` (`event_name`, `winner_name`, `won_item`, `time_win`) VALUES (\"Rush\", \""..team.."\", \""..prize.."\", "..getStorage(configRushEvent.storages.countEvent)..");") doSetStorage(configRushEvent.storages.main, -1) doSetStorage(configRushEvent.storages.countEvent, getStorage(configRushEvent.storages.countEvent) + 1) doSetStorage(configRushEvent.storages.r_score, 0) doSetStorage(configRushEvent.storages.b_score, 0) end end function doCountPlayersRushEvent() local x, blue, red = 0,0,0 for _, cid in ipairs(getPlayersOnline()) do local p = tostring(getCreatureStorage(cid, configRushEvent.storages.player)) if p ~= '' then if p ~= 'blue' then red = red + 1 else blue = blue + 1 end x = x + 1 end end return {x, blue, red} end function doStartCountingRushEvent(x) if configRushEvent.delayTime-x > 0 then doBroadcastMessage('Rush Event is going to start in '..configRushEvent.delayTime-x..' minutes. You can join to the event by saying "!rush join".') addEvent(doStartCountingRushEvent, 60*1000, x+1) end end ]]> </lib> <talkaction words="!stoprush" access="5" event="script"> <![CDATA[ domodlib("lib_rush_event") function onSay(cid, words, param) if getStorage(configRushEvent.storages.main) < 1 then return doPlayerSendCancel(cid, 'You can not do it if Rush Event is not enabled.') end doStopRushEvent() return true end ]]> </talkaction> <talkaction words="!startrush" access="5" event="script"> <![CDATA[ domodlib("lib_rush_event") function onSay(cid, words, param) if getStorage(configRushEvent.storages.main) > 0 then return doPlayerSendCancel(cid, 'Rush Event is already running.') end for _, pid in ipairs(getPlayersOnline()) do if tostring(getCreatureStorage(pid, configRushEvent.storages.player)) ~= '' then doCreatureSetStorage(pid, configRushEvent.storages.player, '') doTeleportThing(pid, getTownTemplePosition(getPlayerTown(pid)), true) doRemoveCondition(pid, CONDITION_OUTFIT) end end doStartCountingRushEvent(0) doSetStorage(configRushEvent.storages.joining, 1) addEvent(doStartRushEvent, configRushEvent.delayTime * 60 * 1000) return true end ]]> </talkaction> <talkaction words="!rush" event="script"> <![CDATA[ domodlib("lib_rush_event") function onSay(cid, words, param) if getStorage(configRushEvent.storages.joining) ~= 1 then return doPlayerSendCancel(cid, 'Rush Event hasn\'t started yet.') elseif param == '' then return doPlayerSendCancel(cid, 'Command param required (say: "!rush join" or "!rush leave.").') elseif getPlayerLevel(cid) < configRushEvent.players.minLevel then return doPlayerSendCancel(cid, 'You can\'t join to the event if you don\'t have a require '..configRushEvent.players.minLevel..' level.') elseif getTileInfo(getThingPos(cid)).protection ~= true then return doPlayerSendCancel(cid, 'You can\'t join to the event if you aren\'t in protection zone.') elseif exhaustion.check(cid, configRushEvent.storages.exhaust) ~= false then return doPlayerSendCancel(cid, 'You must wait '..exhaustion.get(cid, configRushEvent.storages.exhaust)..' seconds to use this command again.') end if param == 'join' then if tostring(getCreatureStorage(cid, configRushEvent.storages.player)) ~= '' then return doPlayerSendCancel(cid, 'You have arleady joined to event. Wait patiently for start.') elseif doCountPlayersRushEvent()[1] == configRushEvent.players.max then return doPlayerSendCancel(cid, 'Max players in the event have been reached.') end doCreatureSetNoMove(cid, true) if configRushEvent.text ~= '' then doPlayerPopupFYI(cid, configRushEvent.text) end doCreatureSetStorage(cid, configRushEvent.storages.player, doCountPlayersRushEvent()[3] >= doCountPlayersRushEvent()[2] and 'blue' or 'red') doAddCondition(cid, createConditionObject(CONDITION_INFIGHT, -1)) doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, 'You have joined to Rush Event. You can\'t move until event don\'t start. Wait patiently for the event start.') doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, 'You have joined to Rush Event.') elseif param == 'leave' then if tostring(getCreatureStorage(cid, configRushEvent.storages.player)) ~= '' then return doPlayerSendCancel(cid, 'You can\'t leave from the event if you don\'t join.') end doCreatureSetNoMove(cid, false) doRemoveCondition(cid, CONDITION_INFIGHT) doCreatureSetStorage(cid, configRushEvent.storages.player, '') doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, 'You have left from the Rush Event.') end exhaustion.set(cid, configRushEvent.storages.exhaust, 5) return true end ]]> </talkaction> <globalevent name="Rush_Event_Days" interval="1000" event="script"> <![CDATA[ domodlib("lib_rush_event") local daysOpen = {} for k, v in pairs(configRushEvent.days) do table.insert(daysOpen, k) end function onThink(cid, interval) if isInArray(daysOpen, os.date('%A')) then if isInArray(configRushEvent.days[os.date('%A')], os.date('%X', os.time())) then if getStorage(configRushEvent.storages.joining) ~= 1 then doStartCountingRushEvent(0) for _, pid in ipairs(getPlayersOnline()) do if tostring(getCreatureStorage(pid, configRushEvent.storages.player)) ~= '' then doCreatureSetStorage(pid, configRushEvent.storages.player, '') doTeleportThing(pid, getTownTemplePosition(getPlayerTown(pid)), true) doRemoveCondition(pid, CONDITION_OUTFIT) end end doSetStorage(configRushEvent.storages.joining, 1) addEvent(doStartRushEvent, configRushEvent.delayTime * 60 * 1000) end end end return true end ]]> </globalevent> <event type="statschange" name="Rush_Event_Dead" event="script"> <![CDATA[ domodlib("lib_rush_event") function onStatsChange(cid, attacker, type, combat, value) if type == 1 and getCreatureHealth(cid) <= value then if isInRange(getThingPos(cid), configRushEvent.room.from, configRushEvent.room.to) then if isPlayer(cid) then local p = tostring(getCreatureStorage(cid, configRushEvent.storages.player)) doCreatureAddHealth(cid, getCreatureMaxHealth(cid) - getCreatureHealth(cid)) doCreatureAddMana(cid, getCreatureMaxMana(cid) - getCreatureMana(cid)) doTeleportThing(cid, p ~= 'blue' and configRushEvent.position.red or configRushEvent.position.blue) doCreatureSetNoMove(cid, true) addEvent(doCreatureSetNoMove, configRushEvent.waitTime * 1000, cid, false) if p ~= 'blue' then doSetStorage(configRushEvent.storages.b_score, math.max(getStorage(configRushEvent.storages.b_score), 0) + 1) if getStorage(configRushEvent.storages.b_score) == configRushEvent.fragLimit then doStopRushEvent() end else doSetStorage(configRushEvent.storages.r_score, math.max(getStorage(configRushEvent.storages.r_score), 0) + 1) if getStorage(configRushEvent.storages.r_score) == configRushEvent.fragLimit then doStopRushEvent() end end return false end end elseif isInArray({1,3}, type) and isPlayer(attacker) and isPlayer(cid) then if isInRange(getThingPos(cid), configRushEvent.room.from, configRushEvent.room.to) then if tostring(getCreatureStorage(cid, configRushEvent.storages.player)) == tostring(getCreatureStorage(attacker, configRushEvent.storages.player)) then return false end end end return true end ]]> </event> <event type="login" name="Rush_Event_Login" event="script"> <![CDATA[ domodlib("config_rush_event") function onLogin(cid) if tostring(getCreatureStorage(cid, configRushEvent.storages.player)) ~= '' then doCreatureSetStorage(cid, configRushEvent.storages.player, '') doRemoveCondition(cid, CONDITION_OUTFIT) end registerCreatureEvent(cid, 'Rush_Event_Dead') return true end ]]> </event> <globalevent name="Rush_Event_Start" type="startup" event="script"> <![CDATA[ domodlib("config_rush_event") function onStartup() doSetStorage(configRushEvent.storages.main, -1) doSetStorage(configRushEvent.storages.r_score, 0) doSetStorage(configRushEvent.storages.b_score, 0) doSetStorage(configRushEvent.storages.joining, -1) return true end ]]> </globalevent> </mod> Só não esta manando o time perdedor para o templo...
Postado Janeiro 21, 2015 10 anos Autor UP up Pessoal não tinha reparado mas ele da um erro na distro quando termina o evento: http://prntscr.com/5v4hsj
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.