Erro:
Meu codigo da lib:
_Lib_Battle_Info = {
Reward = 3,
TeamOne = {name = "Black Team", storage = 140120, pos = {x=1287,y=1135,z=7}},
TeamTwo = {name = "Red Team",storage = 140121,pos = {x=1256,y=1135,z=7}},
storage_count = 180400,
tpPos = {x=1272, y=1143, z=6},
limit_Time = 10 -- em minutos
}
function resetBattle()
return setGlobalStorageValue(_Lib_Battle_Info.TeamOne.storage, 0) and setGlobalStorageValue(_Lib_Battle_Info.TeamTwo.storage, 0)
end
function OpenWallBattle()
local B = {
{12519,{x=1271, y=1161, z=6, stackpos = 1}},
{12519,{x=1271, y=1162, z=6, stackpos = 1}},
{12519,{x=1271, y=1163, z=6, stackpos = 1}},
{12519,{x=1271, y=1164, z=6, 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 doBroadCastBattle(type,msg)
local players = {}
for _, cid in pairs(getPlayersOnline()) do
if getPlayerStorageValue(cid, _Lib_Battle_Info.TeamOne.storage) == 1 or getPlayerStorageValue(cid, _Lib_Battle_Info.TeamTwo.storage) == 1 then
table.insert(players, cid)
end
end
for i = 1, #players do
doPlayerSendTextMessage(players[i],type,msg)
end
end
function removeBattleTp()
local t = getTileItemById(_Lib_Battle_Info.tpPos, 1387).uid
return t > 0 and doRemoveItem(t) and doSendMagicEffect(_Lib_Battle_Info.tpPos, CONST_ME_POFF)
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 .. "Time "..(getGlobalStorageValue(_Lib_Battle_Info.TeamOne.storage) == 0 and _Lib_Battle_Info.TeamTwo.name or _Lib_Battle_Info.TeamOne.name).." venceu o evento PVPWAR. Time vencedor ganhou: 3 PVP Points e o time perdedor: 1 PVP Point"
for i = 1, #players do
if isCreature(players[i]) then
db.executeQuery('UPDATE accounts SET pvp_points=pvp_points+' .. _Lib_Battle_Info.Reward ..' WHERE id=' .. getPlayerAccountId(players[i]))
doRemoveCondition(players[i], CONDITION_OUTFIT)
doTeleportThing(players[i], getTownTemplePosition(getPlayerTown(players[i])))
setPlayerStorageValue(players[i], storage, -1)
setPlayerStorageValue(players[i], 52310, getPlayerStorageValue(players[i], 52310) + 3)
end
end
resetBattle()
OpenWallBattle()
return doBroadcastMessage(str)
end
function CheckEvent(delay)
if delay > 0 and getGlobalStorageValue(_Lib_Battle_Info.storage_count) > 0 then
doBroadcastMessage('[PVPWAR] Esta esperando '..getGlobalStorageValue(_Lib_Battle_Info.storage_count)..' players para o evento começar [Nesse evento voce ganha PVP Points que sao usados para comprar os melhores SETs e ARMAS]', MESSAGE_STATUS_CONSOLE_RED)
elseif delay == 0 and getGlobalStorageValue(_Lib_Battle_Info.storage_count) > 0 then
local players = {}
for _, cid in pairs(getPlayersOnline()) do
if getPlayerStorageValue(cid, _Lib_Battle_Info.TeamOne.storage) == 1 or getPlayerStorageValue(cid, _Lib_Battle_Info.TeamTwo.storage) == 1 then
table.insert(players, cid)
end
end
for i = 1, #players do
doRemoveCondition(players[i], CONDITION_OUTFIT)
setPlayerStorageValue(players[i], 52310, getPlayerStorageValue(cid, 52310) + 1)
doTeleportThing(players[i], getTownTemplePosition(getPlayerTown(players[i])))
setPlayerStorageValue(players[i], getPlayerStorageValue(players[i], _Lib_Battle_Info.TeamOne.storage) == 1 and _Lib_Battle_Info.TeamOne.storage or _Lib_Battle_Info.TeamTwo.storage, -1)
end
doBroadcastMessage('[PVPWAR] Não pode ser iniciado por falta de jogadores.', MESSAGE_STATUS_CONSOLE_RED)
setGlobalStorageValue(_Lib_Battle_Info.storage_count, 0)
doTeleportThing(players[i], getTownTemplePosition(getPlayerTown(players[i])))
resetBattle()
removeBattleTp()
end
addEvent(CheckEvent, 60000, delay-1)
end
Globalevents:
function onThink(interval, lastExecution)
_Lib_Battle_Days = {
["Monday"] = {
["00:00"] = {players = 10},
["00:30"] = {players = 10},
["01:00"] = {players = 10},
["01:30"] = {players = 10},
["02:00"] = {players = 10},
["02:30"] = {players = 10},
["03:00"] = {players = 10},
["03:30"] = {players = 10},
["04:00"] = {players = 10},
["04:30"] = {players = 10},
["05:00"] = {players = 10},
["05:30"] = {players = 10},
["06:00"] = {players = 10},
["06:30"] = {players = 10},
["07:00"] = {players = 10},
["07:30"] = {players = 10},
["08:00"] = {players = 10},
["08:30"] = {players = 10},
["09:00"] = {players = 10},
["09:30"] = {players = 10},
["10:00"] = {players = 10},
["10:30"] = {players = 10},
["11:00"] = {players = 10},
["11:30"] = {players = 10},
["12:30"] = {players = 10},
["13:00"] = {players = 10},
["13:30"] = {players = 10},
["14:00"] = {players = 10},
["14:30"] = {players = 10},
["15:00"] = {players = 10},
["15:30"] = {players = 10},
["16:00"] = {players = 10},
["16:30"] = {players = 10},
["17:02"] = {players = 10},
["17:30"] = {players = 10},
["18:00"] = {players = 10},
["18:30"] = {players = 10},
["19:00"] = {players = 10},
["19:30"] = {players = 10},
["20:00"] = {players = 10},
["20:30"] = {players = 10},
["21:00"] = {players = 10},
["21:30"] = {players = 10},
["22:00"] = {players = 10},
["23:00"] = {players = 10},
["23:30"] = {players = 10}
},
["Tuesday"] = {
["00:00"] = {players = 10},
["00:30"] = {players = 10},
["01:00"] = {players = 10},
["01:30"] = {players = 10},
["02:00"] = {players = 10},
["02:30"] = {players = 10},
["03:00"] = {players = 10},
["03:30"] = {players = 10},
["04:00"] = {players = 10},
["04:30"] = {players = 10},
["05:00"] = {players = 10},
["05:30"] = {players = 10},
["06:00"] = {players = 10},
["06:30"] = {players = 10},
["07:00"] = {players = 10},
["07:30"] = {players = 10},
["08:00"] = {players = 10},
["08:30"] = {players = 10},
["09:00"] = {players = 10},
["09:30"] = {players = 10},
["10:00"] = {players = 10},
["10:30"] = {players = 10},
["11:00"] = {players = 10},
["11:30"] = {players = 10},
["12:30"] = {players = 10},
["13:00"] = {players = 10},
["13:30"] = {players = 10},
["14:00"] = {players = 10},
["14:30"] = {players = 10},
["15:00"] = {players = 10},
["15:30"] = {players = 10},
["16:00"] = {players = 10},
["16:30"] = {players = 10},
["17:00"] = {players = 10},
["17:30"] = {players = 10},
["18:00"] = {players = 10},
["18:30"] = {players = 10},
["19:00"] = {players = 10},
["19:30"] = {players = 10},
["20:00"] = {players = 10},
["20:30"] = {players = 10},
["21:00"] = {players = 10},
["21:30"] = {players = 10},
["22:00"] = {players = 10},
["23:00"] = {players = 10},
["23:30"] = {players = 10}
},
["Wednesday"] = {
["00:00"] = {players = 10},
["00:30"] = {players = 10},
["01:00"] = {players = 10},
["01:30"] = {players = 10},
["02:00"] = {players = 10},
["02:30"] = {players = 10},
["03:00"] = {players = 10},
["03:30"] = {players = 10},
["04:00"] = {players = 10},
["04:30"] = {players = 10},
["05:00"] = {players = 10},
["05:30"] = {players = 10},
["06:00"] = {players = 10},
["06:30"] = {players = 10},
["07:00"] = {players = 10},
["07:30"] = {players = 10},
["08:00"] = {players = 10},
["08:30"] = {players = 10},
["09:00"] = {players = 10},
["09:30"] = {players = 10},
["10:00"] = {players = 10},
["10:30"] = {players = 10},
["11:00"] = {players = 10},
["11:30"] = {players = 10},
["12:30"] = {players = 10},
["13:00"] = {players = 10},
["13:30"] = {players = 10},
["14:00"] = {players = 10},
["14:30"] = {players = 10},
["15:00"] = {players = 10},
["15:30"] = {players = 10},
["16:00"] = {players = 10},
["16:30"] = {players = 10},
["17:00"] = {players = 10},
["17:30"] = {players = 10},
["18:00"] = {players = 10},
["18:30"] = {players = 10},
["19:00"] = {players = 10},
["19:30"] = {players = 10},
["20:00"] = {players = 10},
["20:30"] = {players = 10},
["21:00"] = {players = 10},
["21:30"] = {players = 10},
["22:00"] = {players = 10},
["23:00"] = {players = 10},
["23:30"] = {players = 10}
},
["Thursday"] = {
["00:00"] = {players = 10},
["00:30"] = {players = 10},
["01:00"] = {players = 10},
["01:30"] = {players = 10},
["02:00"] = {players = 10},
["02:30"] = {players = 10},
["03:00"] = {players = 10},
["03:30"] = {players = 10},
["04:00"] = {players = 10},
["04:30"] = {players = 10},
["05:00"] = {players = 10},
["05:30"] = {players = 10},
["06:00"] = {players = 10},
["06:30"] = {players = 10},
["07:00"] = {players = 10},
["07:30"] = {players = 10},
["08:00"] = {players = 10},
["08:30"] = {players = 10},
["09:00"] = {players = 10},
["09:30"] = {players = 10},
["10:00"] = {players = 10},
["10:30"] = {players = 10},
["11:00"] = {players = 10},
["11:30"] = {players = 10},
["12:30"] = {players = 10},
["13:00"] = {players = 10},
["13:30"] = {players = 10},
["14:00"] = {players = 10},
["14:30"] = {players = 10},
["15:00"] = {players = 10},
["15:30"] = {players = 10},
["16:00"] = {players = 10},
["16:30"] = {players = 10},
["17:00"] = {players = 10},
["17:30"] = {players = 10},
["18:00"] = {players = 10},
["18:30"] = {players = 10},
["19:00"] = {players = 10},
["19:30"] = {players = 10},
["20:00"] = {players = 10},
["20:30"] = {players = 10},
["21:00"] = {players = 10},
["21:30"] = {players = 10},
["22:00"] = {players = 10},
["23:00"] = {players = 10},
["23:30"] = {players = 10}
},
["Friday"] = {
["00:00"] = {players = 10},
["00:30"] = {players = 10},
["01:00"] = {players = 10},
["01:30"] = {players = 10},
["02:00"] = {players = 10},
["02:30"] = {players = 10},
["03:00"] = {players = 10},
["03:30"] = {players = 10},
["04:00"] = {players = 10},
["04:30"] = {players = 10},
["05:00"] = {players = 10},
["05:30"] = {players = 10},
["06:00"] = {players = 10},
["06:30"] = {players = 10},
["07:00"] = {players = 10},
["07:30"] = {players = 10},
["08:00"] = {players = 10},
["08:30"] = {players = 10},
["09:00"] = {players = 10},
["09:30"] = {players = 10},
["10:00"] = {players = 10},
["10:30"] = {players = 10},
["11:00"] = {players = 10},
["11:30"] = {players = 10},
["12:30"] = {players = 10},
["13:00"] = {players = 10},
["13:30"] = {players = 10},
["14:00"] = {players = 10},
["14:30"] = {players = 10},
["15:00"] = {players = 10},
["15:30"] = {players = 10},
["16:00"] = {players = 10},
["16:30"] = {players = 10},
["17:00"] = {players = 10},
["17:30"] = {players = 10},
["18:00"] = {players = 10},
["18:30"] = {players = 10},
["19:00"] = {players = 10},
["19:30"] = {players = 10},
["20:00"] = {players = 10},
["20:30"] = {players = 10},
["21:00"] = {players = 10},
["21:30"] = {players = 10},
["22:00"] = {players = 10},
["23:00"] = {players = 10},
["23:30"] = {players = 10}
},
["Saturday"] = {
["00:00"] = {players = 10},
["00:30"] = {players = 10},
["01:00"] = {players = 10},
["01:30"] = {players = 10},
["02:00"] = {players = 10},
["02:30"] = {players = 10},
["03:00"] = {players = 10},
["03:30"] = {players = 10},
["04:00"] = {players = 10},
["04:30"] = {players = 10},
["05:00"] = {players = 10},
["05:30"] = {players = 10},
["06:00"] = {players = 10},
["06:30"] = {players = 10},
["07:00"] = {players = 10},
["07:30"] = {players = 10},
["08:00"] = {players = 10},
["08:30"] = {players = 10},
["09:00"] = {players = 10},
["09:30"] = {players = 10},
["10:00"] = {players = 10},
["10:30"] = {players = 10},
["11:00"] = {players = 10},
["11:30"] = {players = 10},
["12:30"] = {players = 10},
["13:00"] = {players = 10},
["13:30"] = {players = 10},
["14:00"] = {players = 10},
["14:30"] = {players = 10},
["15:00"] = {players = 10},
["15:30"] = {players = 10},
["16:00"] = {players = 10},
["16:30"] = {players = 10},
["17:00"] = {players = 10},
["17:30"] = {players = 10},
["18:00"] = {players = 10},
["18:30"] = {players = 10},
["19:00"] = {players = 10},
["19:30"] = {players = 10},
["20:00"] = {players = 10},
["20:30"] = {players = 10},
["21:00"] = {players = 10},
["21:30"] = {players = 10},
["22:00"] = {players = 10},
["23:00"] = {players = 10},
["23:30"] = {players = 10}
},
["Sunday"] = {
["00:00"] = {players = 10},
["00:30"] = {players = 10},
["01:00"] = {players = 10},
["01:30"] = {players = 10},
["02:00"] = {players = 10},
["02:30"] = {players = 10},
["03:00"] = {players = 10},
["03:30"] = {players = 10},
["04:00"] = {players = 10},
["04:30"] = {players = 10},
["05:00"] = {players = 10},
["05:30"] = {players = 10},
["06:00"] = {players = 10},
["06:30"] = {players = 10},
["07:00"] = {players = 10},
["07:30"] = {players = 10},
["08:00"] = {players = 10},
["08:30"] = {players = 10},
["09:00"] = {players = 10},
["09:30"] = {players = 10},
["10:00"] = {players = 10},
["10:30"] = {players = 10},
["11:00"] = {players = 10},
["11:30"] = {players = 10},
["12:30"] = {players = 10},
["13:00"] = {players = 10},
["13:30"] = {players = 10},
["14:00"] = {players = 10},
["14:30"] = {players = 10},
["15:00"] = {players = 10},
["15:30"] = {players = 10},
["16:00"] = {players = 10},
["16:30"] = {players = 10},
["17:00"] = {players = 10},
["17:30"] = {players = 10},
["18:00"] = {players = 10},
["18:30"] = {players = 10},
["19:00"] = {players = 10},
["19:30"] = {players = 10},
["20:00"] = {players = 10},
["20:30"] = {players = 10},
["21:00"] = {players = 10},
["21:30"] = {players = 10},
["22:00"] = {players = 10},
["23:00"] = {players = 10},
["23:30"] = {players = 10}
},
}
if _Lib_Battle_Days[os.date("%A")] then
hours = tostring(os.date("%X")):sub(1, 5)
tb = _Lib_Battle_Days[os.date("%A")][hours]
if tb and (tb.players % 2 == 0) then
local tp = doCreateItem(1387, 1, _Lib_Battle_Info.tpPos)
doItemSetAttribute(tp, "aid", 45000)
CheckEvent(_Lib_Battle_Info.limit_Time)
doBroadcastMessage('[PVPWAR] Evento aberto! Esperando 10 players (5 VS 5) [Nesse evento voce ganha PVP Points que sao usados para comprar os melhores SETs e ARMAS]', MESSAGE_STATUS_CONSOLE_RED)
return setGlobalStorageValue(_Lib_Battle_Info.storage_count, tb.players)
end
end
return true
end