Ir para conteúdo

Featured Replies

  • Respostas 31
  • Visualizações 720
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • runeraserver
    runeraserver

    Recompensa basta tu adicionar essa linha ao código na parte da recompensa, no exemplo estou usando a storage 52310. if getPlayerStorageValue(cid, 52310) < 1 then setPlayerStorageValue(cid,

  • runeraserver
    runeraserver

    Em recompensas: if getPlayerStorageValue(cid, 52310) < 1 then setPlayerStorageValue(cid, 52310, 1) else setPlayerStorageValue(cid, 52310, getPlayerStorageValue(cid, 52310) + 1) end

  • Adiciona isso em login.lua, antes do ultimo return true: if getPlayerStorageValue(cid, 52310) < 0 then setPlayerStorageValue(cid, 52310, 0) end Deve resolver o problema da storage.

Posted Images

Postado

Faltou o s no player, pois está definido como players:

_Lib_Battle_Info = {
    Reward = {9971,10},
    TeamOne = {name = "Black Assassins", storage = 140120, pos = {x=1262,y=1150,z=6}},
    TeamTwo = {name = "Red Barbarians",storage = 140121,pos = {x=1275,y=1150,z=6}},
    storage_count = 180400,
    tpPos = {x=161, y=44, z=7},
    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 = {
        {3517,{x=1270, y=1161, z=6, stackpos = 1}},
        {3517,{x=1270, y=1162, z=6, stackpos = 1}},
        {3517,{x=1270, y=1163, z=6, stackpos = 1}},
        {3517,{x=1270, 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 .. ""..#players.." Player"..(#players > 1 and "s" or "").." do time "..(getGlobalStorageValue(_Lib_Battle_Info.TeamOne.storage) == 0 and _Lib_Battle_Info.TeamTwo.name or _Lib_Battle_Info.TeamOne.name).." venceu o evento Battlefield, todos do time vencedor ganharam ".._Lib_Battle_Info.Reward[2].." "..getItemNameById(_Lib_Battle_Info.Reward[1]).."!"
    for i = 1, #players do
        doRemoveCondition(players[i], CONDITION_OUTFIT)
        doTeleportThing(players[i], getTownTemplePosition(getPlayerTown(players[i])))
        setPlayerStorageValue(players[i], storage, -1)
        setPlayerStorageValue(players[i], 52310, getPlayerStorageValue(cid, 52310) + 3)
    end
    resetBattle()
    OpenWallBattle()
    return doBroadcastMessage(str)
end

function CheckEvent(delay)
    if delay > 0 and getGlobalStorageValue(_Lib_Battle_Info.storage_count) > 0 then
        doBroadcastMessage("[BattleField Evento] Esta esperando "..getGlobalStorageValue(_Lib_Battle_Info.storage_count).." players para o evento Battlefield começar.")
        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("Evento não pode ser iniciado por falta de jogadores.")
        setGlobalStorageValue(_Lib_Battle_Info.storage_count, 0)
        resetBattle()
        removeBattleTp()
    end
    addEvent(CheckEvent, 60000, delay-1)
end
Postado

Disturbbed, essa jossa dava erro antes de editarmos? Se não, me envia a lib original e o script que chama a função getwinner por favor, acho que é globalevent

Editado por runeraserver (veja o histórico de edições)

Precisa de ajuda? Poste a versão de seu TFS.

*************************************************************************************************************

 

Servidores? Eu indico:

logo2.png

Use o cupom TIBIAKING e receba 50% de desconto na primeira mensalidade!

Pague menos de R$ 19,00 no primeiro mês!

 

protecaoddos.jpg afiliados.jpg

Postado
  • Autor

Não dava erro não, funcionava 100%

 

Lib:

 

_Lib_Battle_Info = {
Reward = {9971,10},
TeamOne = {name = "Black Assassins", storage = 140120, pos = {x=1262,y=1150,z=6}},
TeamTwo = {name = "Red Barbarians",storage = 140121,pos = {x=1275,y=1150,z=6}},
storage_count = 180400,
tpPos = {x=160, y=44, z=7},
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 = {
{3517,{x=1270, y=1161, z=6, stackpos = 1}},
{3517,{x=1270, y=1162, z=6, stackpos = 1}},
{3517,{x=1270, y=1163, z=6, stackpos = 1}},
{3517,{x=1270, y=1164, z=6, stackpos = 1}}
}
for i = 1, #B do
if getTileItemById(B[2], B[1]).uid == 0 then
doCreateItem(B[1], 1, B[2])
else
doRemoveItem(getThingfromPos(B[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,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 .. ""..#players.." Player"..(#players > 1 and "s" or "").." from team "..(getGlobalStorageValue(_Lib_Battle_Info.TeamOne.storage) == 0 and _Lib_Battle_Info.TeamTwo.name or _Lib_Battle_Info.TeamOne.name).." won the event battlefield, they received a ".._Lib_Battle_Info.Reward[2].." "..getItemNameById(_Lib_Battle_Info.Reward[1]).."!"
for i = 1, #players do
doPlayerAddItem(players, _Lib_Battle_Info.Reward[1], _Lib_Battle_Info.Reward[2])
doRemoveCondition(players, CONDITION_OUTFIT)
doTeleportThing(players, getTownTemplePosition(getPlayerTown(players)))
setPlayerStorageValue(players, storage, -1)
end
resetBattle()
OpenWallBattle()
return doBroadcastMessage(str)
end

function CheckEvent(delay)
if delay > 0 and getGlobalStorageValue(_Lib_Battle_Info.storage_count) > 0 then
doBroadcastMessage("[battleField Event] We are waiting "..getGlobalStorageValue(_Lib_Battle_Info.storage_count).." players to Battlefield starts")
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, CONDITION_OUTFIT)
doTeleportThing(players, getTownTemplePosition(getPlayerTown(players)))
setPlayerStorageValue(players, getPlayerStorageValue(players, _Lib_Battle_Info.TeamOne.storage) == 1 and _Lib_Battle_Info.TeamOne.storage or _Lib_Battle_Info.TeamTwo.storage, -1)
end
doBroadcastMessage("The event cannot be started because not had enough players.")
setGlobalStorageValue(_Lib_Battle_Info.storage_count, 0)
resetBattle()
removeBattleTp()
end
addEvent(CheckEvent, 60000, delay-1)
end

 

Getwinner em Creaturescripts

 

function onLogin(cid)
if getGlobalStorageValue(_Lib_Battle_Info.TeamOne.storage) == -1 then
setGlobalStorageValue(_Lib_Battle_Info.TeamOne.storage, 0)
setGlobalStorageValue(_Lib_Battle_Info.TeamTwo.storage, 0)
setGlobalStorageValue(_Lib_Battle_Info.storage_count, 0)
end
registerCreatureEvent(cid, "BattleTeam")
registerCreatureEvent(cid, "BattleDeath")
return true
end


function onCombat(cid, target)
if isPlayer(cid) and isPlayer(target) then
if getPlayerStorageValue(cid, _Lib_Battle_Info.TeamOne.storage) == 1 and getPlayerStorageValue(target, _Lib_Battle_Info.TeamOne.storage) == 1 then
doPlayerSendCancel(cid, "You may not attack your team mates.") return false
end
if getPlayerStorageValue(cid, _Lib_Battle_Info.TeamTwo.storage) == 1 and getPlayerStorageValue(target, _Lib_Battle_Info.TeamTwo.storage) == 1 then
doPlayerSendCancel(cid, "You may not attack your team mates.") return false
end
return true
end
return true
end
function onPrepareDeath(cid, deathList, lastHitKiller, mostDamageKiller)
if getPlayerStorageValue(cid, _Lib_Battle_Info.TeamOne.storage) >= 1 then
setPlayerStorageValue(cid, _Lib_Battle_Info.TeamOne.storage, -1)
setGlobalStorageValue(_Lib_Battle_Info.TeamOne.storage, getGlobalStorageValue(_Lib_Battle_Info.TeamOne.storage)-1)
doRemoveCondition(cid, CONDITION_OUTFIT)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "[battle Field] You Are Dead!")
if getGlobalStorageValue(_Lib_Battle_Info.TeamOne.storage) == 0 then
getWinnersBattle(_Lib_Battle_Info.TeamTwo.storage)
else
doBroadCastBattle(23,"[battleField Information] ".._Lib_Battle_Info.TeamOne.name.." "..getGlobalStorageValue(_Lib_Battle_Info.TeamOne.storage).." VS "..getGlobalStorageValue(_Lib_Battle_Info.TeamTwo.storage).." " .._Lib_Battle_Info.TeamTwo.name)
end
elseif getPlayerStorageValue(cid, _Lib_Battle_Info.TeamTwo.storage) >= 1 then
setPlayerStorageValue(cid, _Lib_Battle_Info.TeamTwo.storage, -1)
setGlobalStorageValue(_Lib_Battle_Info.TeamTwo.storage, getGlobalStorageValue(_Lib_Battle_Info.TeamTwo.storage)-1)
doRemoveCondition(cid, CONDITION_OUTFIT)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "[battle Field] You Are Dead!")
if getGlobalStorageValue(_Lib_Battle_Info.TeamTwo.storage) == 0 then
getWinnersBattle(_Lib_Battle_Info.TeamOne.storage)
else
doBroadCastBattle(23,"[battleField Information] ".._Lib_Battle_Info.TeamOne.name.." "..getGlobalStorageValue(_Lib_Battle_Info.TeamOne.storage).." VS "..getGlobalStorageValue(_Lib_Battle_Info.TeamTwo.storage).." " .._Lib_Battle_Info.TeamTwo.name)
end
end
return true
end

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.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.7k

Informação Importante

Confirmação de Termo