Ir para conteúdo

Battlefield Event!


Vodkart

Posts Recomendados

Ao invés de os vencedores ganharem por exemplo: 10 crystal coins, eles ganhassem os 10 crystal coins + 10k de experiencia...

 

 

<?xml version="1.0" encoding="ISO-8859-1"?>  
<mod name="BattleField" version="1.0" author="Vodkart" contact="xtibia.com" enabled="yes">  
<config name="battle_func"><![CDATA[

battle_info = {
Money = {true, 100000},
Item = {false, 2123,1},
Exp = {true, 10000},
TeamOne = {name = "Black Assassins",storages = {120020,120300},pos = {x=613,y=802,z=7}},
TeamTwo = {name = "Red Barbarians",storages = {120021,120301},pos = {x=631,y=801,z=7}},
storage_count = 150302,
tpPos = {x=158, y=57, z=7}
}

timer = {
days = {
{"Saturday","10:00",20},{"Tuesday","14:45",4}
},
limit_Time = 2 -- em minutos
}

function OpenWallBattle()
local B  = {  
{1543,{x=622, y=803, z=7, stackpos = 1}},  
{1543,{x=622, y=804, z=7, stackpos = 1}},
{1543,{x=622, y=805, z=7, stackpos = 1}},
{1543,{x=622, y=806, z=7, stackpos = 1}}  
}
for i = 1, #B do
if getTileItemById(B[i][2], B[i][1]).uid == 0 then
doCreateItem(B[i][1], 1, B[i][2])
else
doRemoveItem(getThingfromPos(B[i][2]).uid,1)
end
end
end
function resetBattle()
return setGlobalStorageValue(battle_info.TeamOne.storages[2], 0) and setGlobalStorageValue(battle_info.TeamTwo.storages[2], 0)
end
function doBroadCastBattle(type,msg)
local players = {}
for _, cid in pairs(getPlayersOnline()) do
if getPlayerStorageValue(cid, battle_info.TeamOne.storages[1]) == 1 or getPlayerStorageValue(cid,  battle_info.TeamTwo.storages[1]) == 1 then
table.insert(players, cid)
end
end
for i = 1, #players do
doPlayerSendTextMessage(players[i],type,msg)
end
return true
end
function removeTp()
       local t = getTileItemById(battle_info.tpPos, 1387)
       if t then
               doRemoveItem(t.uid, 1)
               doSendMagicEffect(battle_info.tpPos, CONST_ME_POFF)
       end
end
function getWinnersBattle(storage)
local players,str = {},""
for _, cid in pairs(getPlayersOnline()) do
if getPlayerStorageValue(cid, storage) == 1 then
table.insert(players, cid)
end
end
str = str .. ""..#players.." Player"..(#players > 1 and "s" or "").." from team "..(getGlobalStorageValue(battle_info.TeamOne.storages[2]) == 0 and battle_info.TeamTwo.name or battle_info.TeamOne.name).." won the event battlefield, they received a "..(battle_info.Money[1] == true and battle_info.Money[2].." money" or "")..""..(battle_info.Item[1] == true and ", "..battle_info.Item[3].." "..getItemNameById(battle_info.Item[2]) or "")..""..(battle_info.Exp[1] == true and ", "..battle_info.Exp[2].." Experience" or "").."!"
for i = 1, #players do
if battle_info.Money[1] == true then doPlayerAddMoney(players[i], battle_info.Money[2]) end
if battle_info.Item[1] == true then doPlayerAddItem(players[i], battle_info.Item[2], battle_info.Item[3] or 1) end
if battle_info.Exp[1] == true then doPlayerAddExperience(players[i], battle_info.Exp[2]) end
doRemoveCondition(players[i], CONDITION_OUTFIT)
doTeleportThing(players[i], getTownTemplePosition(getPlayerTown(players[i])))
setPlayerStorageValue(players[i], storage, -1)
end
resetBattle()
OpenWallBattle()
return doBroadcastMessage(str)
end
function CheckEvent(delay)
if delay > 0 and getGlobalStorageValue(battle_info.storage_count) > 0 then  
doBroadcastMessage("[battleField Event] We are waiting "..getGlobalStorageValue(battle_info.storage_count).." players to Battlefield starts")
elseif delay == 0 and getGlobalStorageValue(battle_info.storage_count) > 0 then
local players = {}
for _, cid in pairs(getPlayersOnline()) do
if getPlayerStorageValue(cid, battle_info.TeamOne.storages[1]) == 1 or getPlayerStorageValue(cid,  battle_info.TeamTwo.storages[1]) == 1 then
table.insert(players, cid)
end
end
for i = 1, #players do
doRemoveCondition(players[i], CONDITION_OUTFIT)
doTeleportThing(players[i], getTownTemplePosition(getPlayerTown(players[i])))
setPlayerStorageValue(players[i], getPlayerStorageValue(players[i], battle_info.TeamOne.storages[1]) == 1 and battle_info.TeamOne.storages[1] or battle_info.TeamTwo.storages[1], -1)
end
doBroadcastMessage("The event cannot be started because not had enough players.")
setGlobalStorageValue(battle_info.storage_count, 0)
resetBattle()
removeTp()
end
addEvent(CheckEvent, 60000, delay-1)
end]]></config>
<globalevent name="BroadEvento" interval="60" event="script"><![CDATA[
domodlib('battle_func')
function onThink(interval, lastExecution)  
for i = 1, #timer.days do
if isInArray(timer.days[i][1], os.date("%A")) and isInArray(timer.days[i][2], tostring(os.date("%X")):sub(1, 5)) and (timer.days[i][3] % 2) == 0 then
local tp = doCreateItem(1387, 1, battle_info.tpPos)
doItemSetAttribute(tp, "aid", 45000)
CheckEvent(timer.limit_Time)
doBroadcastMessage("The event BattleField was opened and We are waiting "..timer.days[i][3].." Players! Team divided into "..((timer.days[i][3])/2).." VS "..((timer.days[i][3])/2))
return setGlobalStorageValue(battle_info.storage_count, timer.days[i][3])
end
end
return true
end]]></globalevent>
<event type="login" name="Check Map" event="script"><![CDATA[  
domodlib('battle_func')
function onLogin(cid)
registerCreatureEvent(cid, "BattleNoAttack")
registerCreatureEvent(cid, "onBattleDeath")
if getGlobalStorageValue(battle_info.TeamOne.storages[2]) == -1 then
setGlobalStorageValue(battle_info.TeamOne.storages[2], 0)
setGlobalStorageValue(battle_info.TeamTwo.storages[2], 0)
setGlobalStorageValue(battle_info.storage_count, 0)
end
return true  
end]]></event>
<event type="combat" name="BattleNoAttack" event="script"><![CDATA[
domodlib('battle_func')
if isPlayer(cid) and isPlayer(target) then
if(getPlayerStorageValue(cid, battle_info.TeamOne.storages[1]) == 1 and getPlayerStorageValue(target, battle_info.TeamOne.storages[1]) == 1) or (getPlayerStorageValue(cid, battle_info.TeamTwo.storages[1]) == 1 and getPlayerStorageValue(target, battle_info.TeamTwo.storages[1]) == 1) then
doPlayerSendCancel(cid, "You may not attack your team mates.")
return false
end
end
return true]]></event>
<event type="preparedeath" name="onBattleDeath" event="script"><![CDATA[
domodlib('battle_func')  
function onPrepareDeath(cid, deathList, lastHitKiller, mostDamageKiller)
if getPlayerStorageValue(cid, battle_info.TeamOne.storages[1]) >= 1 or getPlayerStorageValue(cid, battle_info.TeamTwo.storages[1]) >= 1 then
local gs = getPlayerStorageValue(cid, battle_info.TeamOne.storages[1]) == 1 and battle_info.TeamOne.storages[2] or battle_info.TeamTwo.storages[2]
local winner = getPlayerStorageValue(cid, battle_info.TeamOne.storages[1]) == 1 and battle_info.TeamTwo.storages[1] or battle_info.TeamOne.storages[1]
setPlayerStorageValue(cid, getPlayerStorageValue(cid, battle_info.TeamOne.storages[1]) == 1 and battle_info.TeamOne.storages[1] or battle_info.TeamTwo.storages[1], -1)
setGlobalStorageValue(gs, getGlobalStorageValue(gs)-1)
doRemoveCondition(cid, CONDITION_OUTFIT)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "[battle Field] You Are Dead!")
       if getGlobalStorageValue(gs) == 0 then
getWinnersBattle(winner)
       else
doBroadCastBattle(23,"[battleField Information] "..battle_info.TeamOne.name.." "..getGlobalStorageValue(battle_info.TeamOne.storages[2]).." VS "..getGlobalStorageValue(battle_info.TeamTwo.storages[2]).." " ..battle_info.TeamTwo.name)
       end
end
return true
end]]></event>
<movevent type="StepIn" actionid="45000" event="script"><![CDATA[
domodlib('battle_func')
local conditionBlack = createConditionObject(CONDITION_OUTFIT)
setConditionParam(conditionBlack, CONDITION_PARAM_TICKS, -1)
addOutfitCondition(conditionBlack, {lookType = 134, lookHead = 114, lookBody = 114, lookLegs = 114, lookFeet = 114})
local conditionRed = createConditionObject(CONDITION_OUTFIT)
setConditionParam(conditionRed, CONDITION_PARAM_TICKS, -1)
addOutfitCondition(conditionRed, {lookType = 143, lookHead = 94, lookBody = 94, lookLegs = 94, lookFeet = 94})
function onStepIn(cid, item, position, fromPosition)
if getPlayerAccess(cid) > 3 then
doTeleportThing(cid, battle_info.TeamOne.pos) return false
elseif getGlobalStorageValue(battle_info.storage_count) > 0 then
setGlobalStorageValue(battle_info.storage_count, getGlobalStorageValue(battle_info.storage_count)-1)
end        
if getGlobalStorageValue(battle_info.storage_count) >= 0 then
         if getGlobalStorageValue(battle_info.TeamOne.storages[2]) <  getGlobalStorageValue(battle_info.TeamTwo.storages[2]) then
setPlayerStorageValue(cid, battle_info.TeamOne.storages[1], 1)
            doAddCondition(cid, conditionBlack)
setGlobalStorageValue(battle_info.TeamOne.storages[2], getGlobalStorageValue(battle_info.TeamOne.storages[2])+1)
doTeleportThing(cid, battle_info.TeamOne.pos)  
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You will join the team " .. battle_info.TeamOne.name .. "!")      
else
setPlayerStorageValue(cid, battle_info.TeamTwo.storages[1], 1)
doAddCondition(cid, conditionRed)
setGlobalStorageValue(battle_info.TeamTwo.storages[2], getGlobalStorageValue(battle_info.TeamTwo.storages[2])+1)
doTeleportThing(cid, battle_info.TeamTwo.pos)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You will join the team " .. battle_info.TeamTwo.name .. "!")
end
end
if getGlobalStorageValue(battle_info.storage_count) == 0 then
removeTp()
doBroadcastMessage("Battlefield will start in 5 minutes, please create your strategy!")
addEvent(doBroadcastMessage, 2*60*1000-500, "BattleField will begin now!")
addEvent(OpenWallBattle, 2*60*1000)
end
return true
end]]></movevent>
</mod>

 

 

Money = {true, 100000}, -- quantidade de money q vai receber

Item = {false, 2123,1}, -- id do item e quantidade

Exp = {true, 10000}, -- quantidade de exp q vai ganhar

 

true para receber o premio e false para não receber[/code]

 

Editado por Vodkart
Link para o comentário
Compartilhar em outros sites

tem como alguem passar o mapa desse evento ??

 

sou um horrivel mapper.. hahaha

 

Uma amiga minha ficou de fazer o mapa, assim que ela fizer, e se fizer, eu anexo junto ao tópico!

 

abraços

Link para o comentário
Compartilhar em outros sites

tem como alguem passar o mapa desse evento ??

 

sou um horrivel mapper.. hahaha

 

Uma amiga minha ficou de fazer o mapa, assim que ela fizer, e se fizer, eu anexo junto ao tópico!

 

abraços

 

 

fmz cara...

vlw , vlw msm! reep +

e outra coisa..

funciona em linux normal ?

Link para o comentário
Compartilhar em outros sites

tem como alguem passar o mapa desse evento ??

 

sou um horrivel mapper.. hahaha

 

Uma amiga minha ficou de fazer o mapa, assim que ela fizer, e se fizer, eu anexo junto ao tópico!

 

abraços

 

 

fmz cara...

vlw , vlw msm! reep +

e outra coisa..

funciona em linux normal ?

 

não sei te dizer, se você puder testar eu agradeceria

Link para o comentário
Compartilhar em outros sites

eu fisso test aqui não sei se bem isso bug mais da pra entra no portal com 2 player um mata o outro e ganhar premiu depois ir de novo e só 2 player ganhar premiu de novo

ressumindo

ir

1x1

e ir de novo

1x1

 

mas o TP não fecha quanto o último entra?

 

outra coisa, se vc entra no evento n tem como sair...

 

claro se os dois players que entrarem, sair, e entrar de novo vai fecha o tp e soh os dois vao ganha premio

Editado por Vodkart
Link para o comentário
Compartilhar em outros sites

Vo testa aki no meu ot, se fufa vai fica mto loco...

 

aki nem funfou ;// teria alguma forma de colocar uma talk pra realizar o evento??? exemplo: /battlefield start 4. (4 numero de players)

Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...