Ir para conteúdo

Featured Replies

Postado

dá uma olhada nisso daqui e vê se vc consegue extrair a parte que separa os times pra colocar numa function onLogin:
http://www.tibiaking.com/forum/topic/16699-sistema-battlefield-event/

Todos os meus trabalhos importantes estão na seção "Sobre mim" no meu perfil; Dá uma passada lá!

"Há três caminhos para o fracasso: não ensinar o que se sabe, não praticar o que se ensina, e não perguntar o que se ignora." - São Beda

I7Pm6ih.png

(obg ao @Beeny por fazer essa linda sign <3)

  • Respostas 50
  • Visualizações 2.5k
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • vai no seu globalevents e cria um arquivo chamado balance:

  • viu antes de voce mexer em algo ve se esta balanceando troca seu !online  por esse aki : *Vai em Talkactions online.lua e troca por esse aki:   esse comando mostra se esta balanceando os tim

  • * setPlayerStorageValue(cid, STORAGE_TEAM_ID, 0)   <<< Essa Funçao Remove a Storage agora e so voce por Para quando o Jogador Morre ou Logar.

Posted Images

Postado
  • Autor

Consegui 1 script aqui que atende, ele vai balanceando certinho no login. Porém tem 1 problema:
- Vamos supor que entraram 4 players, 2 azuis e 2 vermelhos, acontece que se 1 do azul relogar ou morrer, ele cai no vermelho, e vice versa, ficando errado o time, assim: (1 azul e 3 vermelhos). Dai so relogando novamente pra ficar certo denovo: 2 azuis e 2 vermelhos...

Aqui está as funções do script:

function mudarRopa(cid)  
        local colors = WAR_COLORS[getPlayerStorageValue(cid, 12000)]  -- verifica qual time é.
        local outfit = getCreatureOutfit(cid) 
        outfit.lookHead = colors[1] 
        outfit.lookBody = colors[2] 
        outfit.lookLegs = colors[3] 
        outfit.lookFeet = colors[4] 
        doCreatureChangeOutfit(cid, outfit) 
end -- fim do mudar roupas


function getTeamSpawn(cid)  
    return getTownTemplePosition(mapas[getGlobalStorageValue(15000)][getPlayerStorageValue(cid,12000)][math.random(1,2)]) 
end 

function getTeamMembers(id) 
    local players = getPlayersOnline() 
    local team = {} 
    if #players == 1 then 
        return team 
    end 
    for i, cid in ipairs(players) do 
        if getPlayerStorageValue(cid, 12000) == id and getPlayerGroupId(cid) < 3 then 
            table.insert(team, cid) 
        end 
    end 
    return team 
end 

function setTeam(cid) 
        local team1 = getTeamMembers(1) 
        local team2 = getTeamMembers(2) 
        if #team1 >= #team2 then 
            setPlayerStorageValue(cid, 12000, 2) 
        else 
            setPlayerStorageValue(cid, 12000, 1) 
        end 
        mudarRopa(cid) 
        doTeleportThing(cid,getTeamSpawn(cid),false)
end 

Aonde está o erro que ocasiona o que eu citei acima?

Desde já agradeço.

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

Postado

se a função é a onLogin ele vai executar ao logar. Teria que ter um checador que se o player morrer ou deslogar ele seja retirado da table teamX e ao logar a checagem seria refeita, vendo que o timeX estaria com menos players doque o timeY e inserindo o player novamente no timeX. Eu pessoalmente não sei como fazer isso mas se a function é onLogin acho q dá pra fazer uma onDeath ou uma onThink pra ficar constantemente checando se #teamX > #teamY 

Todos os meus trabalhos importantes estão na seção "Sobre mim" no meu perfil; Dá uma passada lá!

"Há três caminhos para o fracasso: não ensinar o que se sabe, não praticar o que se ensina, e não perguntar o que se ignora." - São Beda

I7Pm6ih.png

(obg ao @Beeny por fazer essa linda sign <3)

Postado

- Esse Script ae e de Minha Autoria e do Gesior.pl Que desenvolvemos para Friday War 13 e Mini Games War!

* Funciona em Todas as versoes de OT SERVER!

 

vai na sua lib e cria um arquivo chamado war.lua e add isso aki :

 

 

-- config --


WAR_MAP_NAMES = {'FIBULA', 'EDRON', ' VENORE', 'THAIS', 'ARENA', 'ARENA 3', 'ARENA 1', 'ARENA 2'}
WAR_SPAWNS = {}
WAR_SPAWNS[1] = {{2,2},{3,3}} -- map 1
WAR_SPAWNS[2] = {{5,5},{6,6}} -- map 2
WAR_SPAWNS[3] = {{8,8},{9,9}} -- map 3
WAR_SPAWNS[4] = {{11,11},{12,12}} -- map 4
WAR_SPAWNS[5] = {{36,36},{36,36}} -- map 5
WAR_SPAWNS[6] = {{37,37},{38,38}} -- map 6
WAR_SPAWNS[7] = {{39,39},{40,40}} -- map 7
WAR_SPAWNS[8] = {{41,41},{42,42}} -- map 8




WAR_MAP_CYCLE = {{1,2},{2,3},{3,4},{4,5},{5,6},{6,7},{7,8},{8,1}}
WAR_COLORS = {{98,94,94,94},{89,89,89,89}}
WAR_TEAM_NAMES = {'Team Red','Team Blue'}
WAR_BROADCAST_INTERVAL_TOP5 = 213

WAR_START_LEVEL = 140
WAR_TEAMS = 1

WAR_POINTS_FOR_KILL = 3
WAR_POINTS_FOR_KILL_ASSIST = 1

--------------------------------------------------------
STORAGE_LAST_KILLER_GUID = 10100
STORAGE_LAST_KILLER_GUID_TIMES = 10101
STORAGE_LAST_KILLER_IP = 10200
STORAGE_LAST_KILLER_IP_TIMES = 10201
STORAGE_LAST_KILLER_ACCOUNT = 10300
STORAGE_LAST_KILLER_ACCOUNT_TIMES = 10301
STORAGE_POINTS = 11000
STORAGE_TEAM_ID = 12000
STORAGE_SKULL = 13000
STORAGE_DEPOT = 14000

GLOBAL_STORAGE_MAP = 500
GLOBAL_STORAGE_MAP_CHANGE_TIME = 501
GLOBAL_STORAGE_TEAM_1_FRAGS = 600
GLOBAL_STORAGE_TEAM_2_FRAGS = 700
GLOBAL_STORAGE_BROADCAST_TOP5 = 800

warInitialized = 0
function getTime(s)
local n = math. floor(s / 60)
s = s - (60 * n)
return n, s
end

function getSpawn(cid)
local map_info = WAR_MAP_CYCLE[getGlobalStorageValue(GLOBAL_STORAGE_MAP)]
local map_id = map_info[1]
local map_spawns = WAR_SPAWNS[map_id]
local team_spawns = map_spawns[getPlayerStorageValue(cid, STORAGE_TEAM_ID)]
return getTownTemplePosition(team_spawns[math.random(1,#team_spawns)])
end

function getTeamMembers(id)
local players = getPlayersOnline()
local team = {}
if #players == 0 then
return team
end
for i, cid in ipairs(players) do
if getPlayerStorageValue(cid, STORAGE_TEAM_ID) == id and getPlayerGroupId(cid) == 1 then
table.insert(team, cid)
end
end
return team
end

function updateOutfit(cid)
if WAR_TEAMS == 1 then --outfit
local colors = WAR_COLORS[getPlayerStorageValue(cid, STORAGE_TEAM_ID)]
local outfit = getCreatureOutfit(cid)
outfit.lookHead = colors[1]
outfit.lookBody = colors[2]
outfit.lookLegs = colors[3]
outfit.lookFeet = colors[4]
doCreatureChangeOutfit(cid, outfit)
end
end

function setTeam(cid)
if WAR_TEAMS ~= 1 then
setPlayerStorageValue(cid, STORAGE_TEAM_ID, 1)
else
local team1 = getTeamMembers(1)
local team2 = getTeamMembers(2)
if #team1 >= #team2 then
setPlayerStorageValue(cid, STORAGE_TEAM_ID, 2)
else
setPlayerStorageValue(cid, STORAGE_TEAM_ID, 1)
end
updateOutfit(cid)
end
end

function cronWar()
if getGlobalStorageValue(GLOBAL_STORAGE_MAP_CHANGE_TIME) < os.time() then -- change map
local map_info = WAR_MAP_CYCLE[getNextMapId()]
local map_id = map_info[1]
doTeleportThing(pid,getTeamSpawn(pid),false) -- teleporta para a base


if WAR_TEAMS == 1 then
doBroadcastMessage(getTeamScore(), MESSAGE_STATUS_DEFAULT)
end
setMap(getNextMapId())

elseif getGlobalStorageValue(GLOBAL_STORAGE_BROADCAST_TOP5) < os.time() then -- broadcast top 5
setGlobalStorageValue(GLOBAL_STORAGE_BROADCAST_TOP5, os.time()+WAR_BROADCAST_INTERVAL_TOP5)
addEvent(doBroadcastMessage, 1000, getTop5Players(), MESSAGE_STATUS_CONSOLE_ORANGE)
end
addEvent(cronWar, 1000)
end

function getNextMapId()
if getGlobalStorageValue(GLOBAL_STORAGE_MAP) == #WAR_MAP_CYCLE then
return 1
end
return getGlobalStorageValue(GLOBAL_STORAGE_MAP)+1
end

function getTop5Players()
local players = getPlayersOnline()
if #players == 0 then
return top5text
end
local player1 = {0,-1}
local player2 = {0,-1}
local player3 = {0,-1}
local player4 = {0,-1}
local player5 = {0,-1}
local top5text = "Top 5 Fragers Online"
for i, cid in ipairs(players) do
if getPlayerStorageValue(cid,19999) > player1[2] then
player5 = {player4[1], player4[2]}
player4 = {player3[1], player3[2]}
player3 = {player2[1], player2[2]}
player2 = {player1[1], player1[2]}
player1 = {cid, getPlayerStorageValue(cid,19999)}
elseif getPlayerStorageValue(cid,19999) > player2[2] then
player5 = {player4[1], player4[2]}
player4 = {player3[1], player3[2]}
player3 = {player2[1], player2[2]}
player2 = {cid, getPlayerStorageValue(cid,19999)}
elseif getPlayerStorageValue(cid,19999) > player3[2] then
player5 = {player4[1], player4[2]}
player4 = {player3[1], player3[2]}
player3 = {cid, getPlayerStorageValue(cid,19999)}
elseif getPlayerStorageValue(cid,19999) > player4[2] then
player5 = {player4[1], player4[2]}
player4 = {cid, getPlayerStorageValue(cid,19999)}
elseif getPlayerStorageValue(cid,19999) > player1[2] then
player5 = {cid, getPlayerStorageValue(cid,19999)}
end
end
if player1[1] > 0 then
top5text = top5text .. "\n1. " .. getCreatureName(player1[1]) .. " - " .. player1[2]+1 .. " frags"
end
if player2[1] > 0 then
top5text = top5text .. "\n2. " .. getCreatureName(player2[1]) .. " - " .. player2[2]+1 .. " frags"
end
if player3[1] > 0 then
top5text = top5text .. "\n3. " .. getCreatureName(player3[1]) .. " - " .. player3[2]+1 .. " frags"
end
if player4[1] > 0 then
top5text = top5text .. "\n4. " .. getCreatureName(player4[1]) .. " - " .. player4[2]+1 .. " frags"
end
if player5[1] > 0 then
top5text = top5text .. "\n5. " .. getCreatureName(player5[1]) .. " - " .. player5[2]+1 .. " frags"
end
return top5text
end
function getTeamScore()
return WAR_TEAM_NAMES[1] .. " - " .. getGlobalStorageValue(GLOBAL_STORAGE_TEAM_1_FRAGS) .. " : " .. getGlobalStorageValue(GLOBAL_STORAGE_TEAM_2_FRAGS) .. " - " .. WAR_TEAM_NAMES[2]
end

function setMap(id)
local map_info = WAR_MAP_CYCLE[id]
setGlobalStorageValue(GLOBAL_STORAGE_MAP,id)
setGlobalStorageValue(GLOBAL_STORAGE_MAP_CHANGE_TIME,os.time()+60*40)
local players = getPlayersOnline()
for i, cid in ipairs(players) do
addEvent(doRemoveCreature, 5*1000, cid, true)
setPlayerStorageValue(cid,17778,0) -- seta verificacao de bandeira em 0
setPlayerStorageValue(cid,17777,0) -- seta verificacao de bandeira em 0
setGlobalStorageValue(17778,0) -- ninguem ficar com bandeira time verde!
setGlobalStorageValue(17779,0) -- ninguem ficar com bandeira time vermelho!
setGlobalStorageValue(18888,0) -- ninguem ficar com bandeira time verde!
setGlobalStorageValue(18889,0) -- ninguem ficar com bandeira time vermelho!!
setGlobalStorageValue(5002,0) -- ninguem ficar com bandeira time verde!
setGlobalStorageValue(5001,0) -- ninguem ficar com bandeira time verde!
setGlobalStorageValue(4002,0) -- ninguem ficar com bandeira time verde!
setGlobalStorageValue(4001,0) -- ninguem ficar com bandeira time verde!
setGlobalStorageValue(11544 ,0) -- ninguem ficar com bandeira time verde!
setGlobalStorageValue(11543,0) -- ninguem ficar com bandeira time verde!
doCreatureSetSkullType(cid, 0)
doCreatureAddHealth(cid, getCreatureMaxHealth(cid))
doCreatureAddMana(cid, getCreatureMaxMana(cid))
doChangeSpeed(cid, -getCreatureSpeed(cid) + getCreatureBaseSpeed(cid))
doTeleportThing(cid, getSpawn(cid), TRUE)
removeConditions(cid)
end
end

function removeConditions(cid)
doRemoveCondition(cid, CONDITION_INFIGHT)
doRemoveCondition(cid, CONDITION_PARALYZE)
doRemoveCondition(cid, CONDITION_ENERGY)
doRemoveCondition(cid, CONDITION_FIRE)
doRemoveCondition(cid, CONDITION_POISON)
doRemoveCondition(cid, CONDITION_DRUNK)
end

 

- Depois vai em creaturesripts e cria um arquivo war.lua:

 

function onLogin(cid)


doPlayerAddAddons(cid, 2)
doPlayerAddAddons(cid, 1)
if warInitialized == 0 then
warInitialized = 1
setPlayerStorageValue(cid, STORAGE_TEAM_ID, 1)
setMap(1)
cronWar()
end
setPlayerStorageValue(cid, STORAGE_TEAM_ID, 0)
setPlayerStorageValue(cid, STORAGE_DEPOT, 0)
setTeam(cid)
doTeleportThing(cid, getSpawn(cid), TRUE)
return TRUE
end

 

- Depois vai em globalevents e cria um arquivo map.lua:

 

function onThink(interval, lastExecution)


broadcastMessage("Change Map change in 10 second.", MESSAGE_STATUS_CONSOLE_BLUE)
addEvent(onThink2, 1000)
return TRUE
end

function onThink2(interval, lastExecution)
broadcastMessage("Change Map change in 9 seconds.", MESSAGE_STATUS_CONSOLE_BLUE)
addEvent(onThink3, 1000)
return TRUE
end

function onThink3(interval, lastExecution)
broadcastMessage("Change Map change in 8 seconds.", MESSAGE_STATUS_CONSOLE_BLUE)
addEvent(onThink4, 1000)
return TRUE
end

function onThink4(interval, lastExecution)
broadcastMessage("Change Map change in 7 seconds.", MESSAGE_STATUS_CONSOLE_BLUE)
addEvent(onThink5, 1000)
return TRUE
end

function onThink5(interval, lastExecution)
broadcastMessage("Change Map change in 6 seconds.", MESSAGE_STATUS_CONSOLE_BLUE)
addEvent(onThink6, 1000)
return TRUE
end

function onThink6(interval, lastExecution)
broadcastMessage("Change Map change in 5 seconds.", MESSAGE_STATUS_CONSOLE_BLUE)
addEvent(onThink7, 1000)
return TRUE
end

function onThink7(interval, lastExecution)
broadcastMessage("Change Map change in 4 seconds.", MESSAGE_STATUS_CONSOLE_BLUE)
addEvent(onThink8, 1000)
return TRUE
end

function onThink8(interval, lastExecution)
broadcastMessage("Change Map change in 3 seconds.", MESSAGE_STATUS_CONSOLE_BLUE)
addEvent(onThink9, 1000)
return TRUE
end

function onThink9(interval, lastExecution)
broadcastMessage("Change Map change in 2 seconds.", MESSAGE_STATUS_CONSOLE_BLUE)
addEvent(onThink10, 1000)
return TRUE
end

function onThink10(interval, lastExecution)
broadcastMessage(" Change Map in 1 seconds.", MESSAGE_STATUS_CONSOLE_BLUE)
addEvent(onThink11, 1000)
return TRUE
end

function onThink11(interval)
setMap(getNextMapId())
return TRUE
end

 

* Config:

WAR_SPAWNS[1] = {{2,2},{3,3}} -- OS NUMEROS 2 E 3 SAO AS TOWN ID DO MAPA EDITOR OU SEJA VOCE TERA QUE ADICIONAR NO MAPA EDITOR AS BASES DOS TIMES E ADICIONAR A TOWN ID, NO SCRIPT ESTA CONFIGURADO [8] MAPAS

 

- WAR_MAP_CYCLE = {{1,2},{2,3},{3,4},{4,5},{5,6},{6,7},{7,8},{8,1}} ---- E O CICLO DO MAPA COMEÇANDO COM O MAPA [1]  E ASSIM FAZENDO SEU CICLO VOLTANDO PARA [1] , NO SCRIPT ESTA CONFIGURADO [8] MAPAS

 

 

se a função é a onLogin ele vai executar ao logar. Teria que ter um checador que se o player morrer ou deslogar ele seja retirado da table teamX e ao logar a checagem seria refeita, vendo que o timeX estaria com menos players doque o timeY e inserindo o player novamente no timeX. Eu pessoalmente não sei como fazer isso mas se a function é onLogin acho q dá pra fazer uma onDeath ou uma onThink pra ficar constantemente checando se #teamX > #teamY 

* Nao vai desbalancear os times quando morrer e simplesmente ao contrario: OS TIMES VAI BALANCEAR QUANDO ALGUM JOGADOR MORRER , se o Autor do Topico quiser o Sistema de [Cheking Team Balance] em Tempo Real: Durante o jogo qualquer um player podera ser Trocado de Time [Automatico] é so me Mandar um PM! Ate +

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


 

 

Postado

Consegui 1 script aqui que atende, ele vai balanceando certinho no login. Porém tem 1 problema:

- Vamos supor que entraram 4 players, 2 azuis e 2 vermelhos, acontece que se 1 do azul relogar ou morrer, ele cai no vermelho, e vice versa, ficando errado o time, assim: (1 azul e 3 vermelhos). Dai so relogando novamente pra ficar certo denovo: 2 azuis e 2 vermelhos...

Aqui está as funções do script:

function mudarRopa(cid)  
        local colors = WAR_COLORS[getPlayerStorageValue(cid, 12000)]  -- verifica qual time é.
        local outfit = getCreatureOutfit(cid) 
        outfit.lookHead = colors[1] 
        outfit.lookBody = colors[2] 
        outfit.lookLegs = colors[3] 
        outfit.lookFeet = colors[4] 
        doCreatureChangeOutfit(cid, outfit) 
end -- fim do mudar roupas


function getTeamSpawn(cid)  
    return getTownTemplePosition(mapas[getGlobalStorageValue(15000)][getPlayerStorageValue(cid,12000)][math.random(1,2)]) 
end 

function getTeamMembers(id) 
    local players = getPlayersOnline() 
    local team = {} 
    if #players == 1 then 
        return team 
    end 
    for i, cid in ipairs(players) do 
        if getPlayerStorageValue(cid, 12000) == id and getPlayerGroupId(cid) < 3 then 
            table.insert(team, cid) 
        end 
    end 
    return team 
end 

function setTeam(cid) 
        local team1 = getTeamMembers(1) 
        local team2 = getTeamMembers(2) 
        if #team1 >= #team2 then 
            setPlayerStorageValue(cid, 12000, 2) 
        else 
            setPlayerStorageValue(cid, 12000, 1) 
        end 
        mudarRopa(cid) 
        doTeleportThing(cid,getTeamSpawn(cid),false)
end 

Aonde está o erro que ocasiona o que eu citei acima?

Desde já agradeço.

 

 

isso por que ele adiciona um storage, acho que se fizer uma função onlogout para remover o storage quando ele logar novamente já ira fazer a checagem normalmente..

 

 

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