Ir para conteúdo
  • Cadastre-se

(Resolvido)Ajuda encontrar quantidade de player no script


Posts Recomendados

Bom dia comunidade, estou utilizando um script realteambattle, ele está funcionando perfeitamente porém estou com dúvidas onde encontrar a configuração dos players para entrar no evento atualmente esta para 2 player entrar e ja iniciar o evento, gostaria de aumentar para 30 player. Já reli o script 100x minha cabeça está até doendo e nao consigo achar, estou pensando que a quantidade de player para o evento depende de quantos estiver online.. Me ajudem plx

 

arquivo lib

 

Spoiler

--[[    

            Real Team Battle Event
    Desenvolvido por Vítor Bertolucci (Killua)

]]

realTeamBattle = {

    countStorage = 722385,
    teamStorage = 722386,
    checkStorage = 722387,
    rewards = {{2157,100}, {9971,50}},

    redTeam = {name = "Red Assassins", startPos = {x = 1807, y = 1488, z = 7}, storage = 1},
    blueTeam = {name = "Blue Norsemen", startPos = {x = 1842, y = 1486, z = 7}, storage = 2},

    stonePositions = {
    {x = 1826, y = 1497, z = 6},
    {x = 1826, y = 1498, z = 6},
    {x = 1826, y = 1499, z = 6},  
    {x = 1826, y = 1500, z = 6}
    },

    teleportPosition = {x = 383, y = 1152, z = 5},
    exit = {x = 1910, y = 1010, z = 7},
    ips = {}

}

function realTeamBattle.cleanPlayer(cid)
    doPlayerSetStorageValue(cid,realTeamBattle.teamStorage,-1)
    doRemoveCondition(cid,CONDITION_OUTFIT)
end

function realTeamBattle.announce0(times)
    if times == 0 then
        realTeamBattle.removeTeleport()
        doBroadcastMessage("[Team Battle] O evento não atingiu o número de jogadores necessário para iniciar e foi cancelado.")
        for _, pid in pairs(getPlayersOnline()) do
            if getPlayerStorageValue(pid,realTeamBattle.teamStorage) > 0 then
                realTeamBattle.cleanPlayer(pid)
                doTeleportThing(pid,realTeamBattle.exit)
            end
        end
        return;
    end
    if getGlobalStorageValue(realTeamBattle.countStorage) > 0 then
        doBroadcastMessage("[Team Battle] Estamos esperando "..getGlobalStorageValue(realTeamBattle.countStorage).." jogadores para iniciar o evento, o teleporte está na area de eventos!")
        addEvent(realTeamBattle.announce,30000,times - 1)
    else
        realTeamBattle.broadcast(MESSAGE_STATUS_WARNING,"[Team Battle] A guerra vai começar daqui 1 minuto, se preparem!")
        addEvent(realTeamBattle.start,60000)
    end
end

function realTeamBattle.open(players)
    setGlobalStorageValue(realTeamBattle.checkStorage,0)
    setGlobalStorageValue(realTeamBattle.countStorage,players)
    doBroadcastMessage("[Team Battle] Teleporte criado na area de evento, estamos esperando "..players.." jogadores para iniciar o evento.")
    local creature = getTopCreature(realTeamBattle.teleportPosition)
    if creature and creature.uid and creature.uid > 0 and isPlayer(creature.uid) then doTeleportThing(creature.uid,getTownTemplePosition(1)) end
    doCleanTile(realTeamBattle.teleportPosition)
    local tp = doCreateItem(1387,1,realTeamBattle.teleportPosition)
    doItemSetAttribute(tp,"aid",61485)
    realTeamBattle.announce(20)
end

function realTeamBattle.removeStones()
    for a,b in pairs(realTeamBattle.stonePositions) do
        local stone = getTileItemById(b,3517)
        if stone and stone.uid and stone.uid > 0 then
            doRemoveItem(stone.uid)
        end
    end
end

function realTeamBattle.createStones()
    for a,b in pairs(realTeamBattle.stonePositions) do
        doCreateItem(3517,1,b)
    end
end

function realTeamBattle.broadcast(type,msg)
    for _, pid in pairs(getPlayersOnline()) do
        if getPlayerStorageValue(pid,realTeamBattle.teamStorage) > 0 then
            doPlayerSendTextMessage(pid,type,msg)
        end
    end
end

function realTeamBattle.start()
    realTeamBattle.removeStones()
    realTeamBattle.broadcast(MESSAGE_STATUS_WARNING,"[Team Battle] O evento começou, boa sorte a todos!")
end

function  realTeamBattle.getPlayers()
    local players = {}
    for a,pid in pairs(getPlayersOnline()) do
        if getPlayerStorageValue(pid,realTeamBattle.teamStorage) > 0 then
            table.insert(players,pid)
        end
    end
    return players
end

function realTeamBattle.winEvent(team,ammount)
    local teams = {"Red Assassins","Blue Norsemen","Black Hunters","Green Beggars"}
    for _, pid in pairs(realTeamBattle.getPlayers()) do
        if getPlayerStorageValue(pid,realTeamBattle.teamStorage) == team then
            doPlayerAddItem(pid, 6527, 120)
            doPlayerSendTextMessage(pid,25,"[Team Battle] Parabéns por vencer o evento, você ganhou 80 Event Coins!")
        end
        realTeamBattle.cleanPlayer(pid)
        doTeleportThing(pid,realTeamBattle.exit)
    end
    setGlobalStorageValue(realTeamBattle.countStorage,0)
    setGlobalStorageValue(realTeamBattle.checkStorage,-1)
    realTeamBattle.createStones()
    doBroadcastMessage("[Team Battle] "..ammount.." jogadores do time "..teams[team].." venceram o evento e ganharam 120 Event Coins e 50kk!")
end

function realTeamBattle.empate(team1,team2)
    local teams = {"Red Assassins","Blue Norsemen"}
    for _, pid in pairs(realTeamBattle.getPlayers()) do
        local sto = getPlayerStorageValue(pid,realTeamBattle.teamStorage)
        if sto == team1 or sto == team2 then
            doPlayerAddItem(pid, 6527, 120)
            doPlayerSendTextMessage(pid,25,"[Team Battle] Parabéns por vencer o evento, você ganhou 120 Event Coins e 50kk!")
        end
        realTeamBattle.cleanPlayer(pid)
        doTeleportThing(pid,realTeamBattle.exit)
    end
    setGlobalStorageValue(realTeamBattle.countStorage,0)
    setGlobalStorageValue(realTeamBattle.checkStorage,-1)
    realTeamBattle.createStones()
    doBroadcastMessage("[Team Battle] O evento empatou ficando apenas um jogador do time "..teams[team1].." e um do time "..teams[team2]..". Cada um deles ganhou 120 Event Coins e 50kk!")
end

function realTeamBattle.checkTeams()
    local red, blue, black, green = 0,0,0,0
    local table_, ammount, ppteam = {}, 0, {}
    local players = realTeamBattle.getPlayers()
    if #players >= 1 then
        for _, pid in pairs(players) do
            local team = getPlayerStorageValue(pid,realTeamBattle.teamStorage)
            if team == 1 then
                red = red + 1
            elseif team == 2 then
                blue = blue + 1
            end
        end
        if red > 0 then
            table.insert(table_,1)
            ammount = red
            ppteam[1] = red
        end
        if blue > 0 then
            table.insert(table_,2)
            ammount = blue
            ppteam[2] = blue
        end

        if #table_ == 1 then
            addEvent(realTeamBattle.winEvent,1000,table_[1],ammount)
        elseif #table_ == 2 then
            for a,b in pairs(ppteam) do
                if b > 1 then
                    return;
                end
            end
            addEvent(realTeamBattle.empate,1000,table_[1],table_[2])
        end
    end
end

function realTeamBattle.removeTeleport()
    local tp = getTileItemById(realTeamBattle.teleportPosition,1387)
    if tp and tp.uid and tp.uid > 0 then
        doRemoveItem(tp.uid)
        doSendMagicEffect(realTeamBattle.teleportPosition,CONST_ME_POFF)
    end
end
 

 

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

                                                       “Enquanto nos derem ao menos 1% de chance, seguiremos lutando.

                                                     E venceremos! Esse é o verdadeiro e único Clube da Fé! Vai São Paulo!”

                                                                                       spfc.png

Link para o post
Compartilhar em outros sites
8 horas atrás, Dwarfer disse:

Provavelmente está no globalevents, mas envie o restante dos arquivos.

 

Segue o globalevents, mas creio que não seja aqui

 

Spoiler

--[[    

            Real Team Battle Event
    Desenvolvido por Vítor Bertolucci (Killua)

]]

function onTime()
    realTeamBattle.open(2)
    return true
end

 

e o movements.lua

Spoiler

--[[    

            Real Team Battle Event
    Desenvolvido por Vítor Bertolucci (Killua)

]]

local conditionRed = createConditionObject(CONDITION_OUTFIT)
setConditionParam(conditionRed, CONDITION_PARAM_TICKS, -1)
addOutfitCondition(conditionRed, {lookType = 152, lookHead = 94, lookBody = 94, lookLegs = 94, lookFeet = 94, lookAddons = 3})

local conditionBlue = createConditionObject(CONDITION_OUTFIT)
setConditionParam(conditionBlue, CONDITION_PARAM_TICKS, -1)
addOutfitCondition(conditionBlue, {lookType = 251, lookHead = 86, lookBody = 86, lookLegs = 86, lookFeet = 86, lookAddons = 3})


function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
    if getPlayerLevel(cid) < 100 then
        doTeleportThing(cid,lastPosition)
        doCreatureSay(cid,"Somente level 100+",TALKTYPE_ORANGE_1)
        return true
    end

    
    local ring = getPlayerSlotItem(cid,CONST_SLOT_RING)
    if ring and ring.uid and ring.uid > 0 and ring.itemid == 2165 then
        doRemoveItem(ring.uid)
    end

    local check = getGlobalStorageValue(realTeamBattle.checkStorage)
    if check == 0 then
        doPlayerSetStorageValue(cid,realTeamBattle.teamStorage,realTeamBattle.redTeam.storage)
        doAddCondition(cid,conditionRed)
        doTeleportThing(cid,realTeamBattle.redTeam.startPos)
        doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_ORANGE,"[Team Battle] Você entrou para o time "..realTeamBattle.redTeam.name..". Aguarde o evento iniciar.")
        setGlobalStorageValue(realTeamBattle.countStorage, getGlobalStorageValue(realTeamBattle.countStorage) - 1)
        setGlobalStorageValue(realTeamBattle.checkStorage,1)

    elseif check == 1 then
        doPlayerSetStorageValue(cid,realTeamBattle.teamStorage,realTeamBattle.blueTeam.storage)
        doAddCondition(cid,conditionBlue)
        doTeleportThing(cid,realTeamBattle.blueTeam.startPos)
        doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_ORANGE,"[Team Battle] Você entrou para o time "..realTeamBattle.blueTeam.name..". Aguarde o evento iniciar.")
        setGlobalStorageValue(realTeamBattle.countStorage, getGlobalStorageValue(realTeamBattle.countStorage) - 1)
        setGlobalStorageValue(realTeamBattle.checkStorage,2)
    end

    if getGlobalStorageValue(realTeamBattle.countStorage) == 0 then
        realTeamBattle.removeTeleport()
    end
    return true
end
 

 

creaturescript

Spoiler

--[[    

            Real Team Battle Event
    Desenvolvido por Vítor Bertolucci (Killua)

]]

function onCombat(cid, target)
    if isPlayer(cid) and isPlayer(target) then
        local sto = getPlayerStorageValue(cid, realTeamBattle.teamStorage)
        if sto > 0 then
            if sto == getPlayerStorageValue(target, realTeamBattle.teamStorage) then
                return false
            end
        end
    end
    return true
end

function onTarget(cid, target)
    if isPlayer(cid) and isPlayer(target) then
        local sto = getPlayerStorageValue(cid, realTeamBattle.teamStorage)
        if sto > 0 then
            if sto == getPlayerStorageValue(target, realTeamBattle.teamStorage) then
                doPlayerSendCancel(cid,"Você não pode atacar seu companheiro de time.")
                return false
            end
        end
    end
    return true
end

function onPrepareDeath(cid, deathList)
    if isPlayer(cid) then
        local sto = getPlayerStorageValue(cid,realTeamBattle.teamStorage)
        if sto > 0 then
            local times = {"Red Assassins", "Blue Norsemen", "Black Hunters", "Green Beggars"}
            realTeamBattle.broadcast(MESSAGE_STATUS_CONSOLE_ORANGE,"[Team Battle] O jogador "..getCreatureName(cid).." do time "..times[sto].." foi morto!")
            doPlayerSendTextMessage(cid,MESSAGE_STATUS_WARNING,"[Team Battle] You are dead!")
            realTeamBattle.cleanPlayer(cid)
            realTeamBattle.checkTeams()
        end
    end
    return true
end

function onLogin(cid)
    doPlayerSetStorageValue(cid, realTeamBattle.teamStorage,-1)
    registerCreatureEvent(cid, "realTeamBattleDeath")
    registerCreatureEvent(cid, "realTeamBattleCombat")
    registerCreatureEvent(cid, "realTeamBattleTarget")
    return true
end

 

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

                                                       “Enquanto nos derem ao menos 1% de chance, seguiremos lutando.

                                                     E venceremos! Esse é o verdadeiro e único Clube da Fé! Vai São Paulo!”

                                                                                       spfc.png

Link para o post
Compartilhar em outros sites
53 minutos atrás, victor4312 disse:

está em lib.

a lib eu postei no tópico, nao consegui encontra la tbm

                                                       “Enquanto nos derem ao menos 1% de chance, seguiremos lutando.

                                                     E venceremos! Esse é o verdadeiro e único Clube da Fé! Vai São Paulo!”

                                                                                       spfc.png

Link para o post
Compartilhar em outros sites

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

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo