Ir para conteúdo
Banner com Efeitos

(Resolvido)[logica de programacao] como balancear times?

Featured Replies

Postado

Na variável index

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 9
  • Visualizações 728
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • Ve se entende faz assim ó: function BalancearTime(){ Pega a  QtdTime, QtdPlayers, QtdPorTime QtdPorTime = QtdPlayer/QtdTime; } Sendo assim QtdPorTime ja vai ter a qtd de players que balanceada por

  • local times = { [1] = globalStorage do time1, [2] = globalStorage do time2, [3] = globalStorage do time3,  ​[4] = globalStorage do time4 } local minor = getGlobalStorageValue(times[1]) -- seta um va

  • ja tem um script aki no Tibiaking de Balanceamento de 4 Times > http://www.tibiaking.com/forum/topic/28325-fctf-flexible-capture-the-flag/

Postado
  • Autor

Ok. Vou postar o script inteiro do sistema, porfavor ignore o resto.  Nao terminei o script

Seguinte, o for nao ta salvando nada na variavel. Tentei com a index e a for. Quem sabe estou usando no lugar errado. Tentei colocar local tb, e nao deu certo.

Erro:

[7/11/2014 12:13:10] [Error - CreatureScript Interface] 
[7/11/2014 12:13:10] data/creaturescripts/scripts/definirtime.lua:onLogin
[7/11/2014 12:13:10] Description: 
[7/11/2014 12:13:10] data/creaturescripts/scripts/definirtime.lua:88: attempt to concatenate global 'index' (a nil value)
[7/11/2014 12:13:10] stack traceback:
[7/11/2014 12:13:10] 	data/creaturescripts/scripts/definirtime.lua:88: in function <data/creaturescripts/scripts/definirtime.lua:1>

Uma curiosidade, o codigo que tu postou primeiro, a colchetes na linha "​[4] = globalStorage do time4" dava erro. Ai substitui o colchetes e foi normal. Coisas de propgramação O_o

Porfavor se puder nao entregue o codigo pronto, só me diga oque tem de errado. Obrigado :D


Wolf, consegui arrumar.  Não sei explicar oq era. Só sei que esta funcionando perfeitamente. Fiz varios testes e esta tudo ok. Vou postar o script final que pode servir de base de conhecimento para algo do genero. Muito bom!

 

 

O script nao esta terminado, mas o balanceamento esta perfeito. 

 

function onLogin(cid)


	if getGlobalStorageValue(15100) == 1 then
return true
	end	
	
	if getGlobalStorageValue(15100) == 2 then

if getGlobalStorageValue(15101) >=  getGlobalStorageValue(15102) then 
-- COLOCAR O JOGADOR NO TIME BRANCO -- 15002

setGlobalStorageValue(15102, getGlobalStorageValue(15102) + 1)
setPlayerStorageValue(cid, 15099, 2)
        
		
		
		-- OUTFIT
        local outfit = getCreatureOutfit(cid) 
        outfit.lookHead = 0
        outfit.lookBody = 114
        outfit.lookLegs = 114
        outfit.lookFeet = 114 
        doCreatureChangeOutfit(cid, outfit) 
		
		-- TOWN
		
       doPlayerSetTown(cid, getGlobalStorageValue(15202) )
	   doTeleportThing(cid, getTownTemplePosition(getGlobalStorageValue(15202)), true)


else
-- COLOCAR O JOGADOR NO TIME PRETO -- 15101
setGlobalStorageValue(15101, getGlobalStorageValue(15101) + 1)
setPlayerStorageValue(cid, 15099, 1)
     
	 
	 -- OUTFIT
	      local outfit = getCreatureOutfit(cid) 
        outfit.lookHead = 114
        outfit.lookBody = 0
        outfit.lookLegs = 0
        outfit.lookFeet = 0 
        doCreatureChangeOutfit(cid, outfit) 

		
			-- TOWN
		
       doPlayerSetTown(cid, getGlobalStorageValue(15201) )
	   doTeleportThing(cid, getTownTemplePosition(getGlobalStorageValue(15201)), true)
	
	
	
	
	
	end	

return true
	end	

		
		
	if getGlobalStorageValue(15100) == 3 then
return true
	end	
		
	if getGlobalStorageValue(15100) == 4 then

	
	local times = {
[1] = 15101, 
[2] = 15102,
[3] = 15103, 
[4] = 15104
}

local minor = getGlobalStorageValue(times[1]) -- seta um valor inicial

for _, v in pairs (times) do
if getGlobalStorageValue(v) <= minor then
minor = getGlobalStorageValue(v)
index = v

end

end
 setGlobalStorageValue(index, getGlobalStorageValue(index) + 1)

	
	
	
	
	
	
	
	
	return true
	end	
		
	
	
	
	


return true
end


Obrigado a todos.

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

Postado

O problema foi que vc tava usando o getglobal do v... eu havia dito que era no index! O v só existe dentro do for. Em todo caso se a dúvida foi resolvida, apenas clique em "melhor resposta" pra deixar como resolvido e clique em gostei nos comentários de quem te ajudou.

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
  • Autor

Sim realmente era esse o erro. Aqui o script final. Espero que ajudem alguem :D Resolvido.

 

 

@Nextbr   Sim, tem a função quando dar logout e quando morrer dar baixa. :D

function onLogin(cid)







if getGlobalStorageValue(15100) == 1 then
setGlobalStorageValue(15101, getGlobalStorageValue(15101) + 1)
setPlayerStorageValue(cid, 15099, 1)
     
		-- OUTFIT
        local outfit = getCreatureOutfit(cid) 
        outfit.lookHead = math.random(0, 132)
        outfit.lookBody = math.random(0, 132)
        outfit.lookLegs = math.random(0, 132)
        outfit.lookFeet = math.random(0, 132)
        doCreatureChangeOutfit(cid, outfit) 
		
		-- TOWN
		
       doPlayerSetTown(cid, getGlobalStorageValue(math.random(15201, 15204)) )
	   doTeleportThing(cid, getTownTemplePosition(getGlobalStorageValue(math.random(15201, 15204))), true)









return true
end
	







	if getGlobalStorageValue(15100) == 2 then

if getGlobalStorageValue(15101) >=  getGlobalStorageValue(15102) then 
-- COLOCAR O JOGADOR NO TIME BRANCO -- 15002

setGlobalStorageValue(15102, getGlobalStorageValue(15102) + 1)
setPlayerStorageValue(cid, 15099, 2)
        
		
		
		-- OUTFIT
        local outfit = getCreatureOutfit(cid) 
        outfit.lookHead = 0
        outfit.lookBody = 114
        outfit.lookLegs = 114
        outfit.lookFeet = 114 
        doCreatureChangeOutfit(cid, outfit) 
		
		-- TOWN
		
       doPlayerSetTown(cid, getGlobalStorageValue(15202) )
	   doTeleportThing(cid, getTownTemplePosition(getGlobalStorageValue(15202)), true)


else
-- COLOCAR O JOGADOR NO TIME PRETO -- 15101
setGlobalStorageValue(15101, getGlobalStorageValue(15101) + 1)
setPlayerStorageValue(cid, 15099, 1)
     
	 
	 -- OUTFIT
	      local outfit = getCreatureOutfit(cid) 
        outfit.lookHead = 114
        outfit.lookBody = 0
        outfit.lookLegs = 0
        outfit.lookFeet = 0 
        doCreatureChangeOutfit(cid, outfit) 

		
			-- TOWN
		
       doPlayerSetTown(cid, getGlobalStorageValue(15201) )
	   doTeleportThing(cid, getTownTemplePosition(getGlobalStorageValue(15201)), true)
	
	
	
	
	
	end	

return true
	end	

		
	
	
	
	
	
	
	
	
	
	
	
if getGlobalStorageValue(15100) == 3 then

	
	local times = {
[1] = 15101, 
[2] = 15102,
[3] = 15103
}

local minor = getGlobalStorageValue(times[1]) -- seta um valor inicial

for _, v in pairs (times) do
if getGlobalStorageValue(v) <= minor then
minor = getGlobalStorageValue(v)
index = v

end

end
 
if index == 15101 then
setGlobalStorageValue(index, getGlobalStorageValue(index) + 1)
setPlayerStorageValue(cid, 15099, 1)
     
		-- OUTFIT
        local outfit = getCreatureOutfit(cid) 
        outfit.lookHead = 114
        outfit.lookBody = 0
        outfit.lookLegs = 0
        outfit.lookFeet = 0
        doCreatureChangeOutfit(cid, outfit) 
		
		-- TOWN
		
       doPlayerSetTown(cid, getGlobalStorageValue(15201) )
	   doTeleportThing(cid, getTownTemplePosition(getGlobalStorageValue(15201)), true)
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	elseif index == 15102	then
setGlobalStorageValue(index, getGlobalStorageValue(index) + 1)
setPlayerStorageValue(cid, 15099, 2)
     
		-- OUTFIT
        local outfit = getCreatureOutfit(cid) 
        outfit.lookHead = 0
        outfit.lookBody = 114
        outfit.lookLegs = 114
        outfit.lookFeet = 114 
        doCreatureChangeOutfit(cid, outfit) 
		
		-- TOWN
		
       doPlayerSetTown(cid, getGlobalStorageValue(15202) )
	   doTeleportThing(cid, getTownTemplePosition(getGlobalStorageValue(15202)), true)


	   
	   
	   elseif index == 15103 then
setGlobalStorageValue(index, getGlobalStorageValue(index) + 1)
setPlayerStorageValue(cid, 15099, 3)
     
		-- OUTFIT
        local outfit = getCreatureOutfit(cid) 
        outfit.lookHead = 114
        outfit.lookBody = 88
        outfit.lookLegs = 88
        outfit.lookFeet = 88
        doCreatureChangeOutfit(cid, outfit) 
		
		-- TOWN
		
       doPlayerSetTown(cid, getGlobalStorageValue(15203) )
	   doTeleportThing(cid, getTownTemplePosition(getGlobalStorageValue(15203)), true)

	   
	   

	   
	   
	 
end	


	return true
	end	
		


		
		
		
		
		
	
	if getGlobalStorageValue(15100) == 4 then

	
	local times = {
[1] = 15101, 
[2] = 15102,
[3] = 15103, 
[4] = 15104
}

local minor = getGlobalStorageValue(times[1]) -- seta um valor inicial

for _, v in pairs (times) do
if getGlobalStorageValue(v) <= minor then
minor = getGlobalStorageValue(v)
index = v

end

end
 
if index == 15101 then
setGlobalStorageValue(index, getGlobalStorageValue(index) + 1)
setPlayerStorageValue(cid, 15099, 1)
     
		-- OUTFIT
        local outfit = getCreatureOutfit(cid) 
        outfit.lookHead = 114
        outfit.lookBody = 0
        outfit.lookLegs = 0
        outfit.lookFeet = 0
        doCreatureChangeOutfit(cid, outfit) 
		
		-- TOWN
		
       doPlayerSetTown(cid, getGlobalStorageValue(15201) )
	   doTeleportThing(cid, getTownTemplePosition(getGlobalStorageValue(15201)), true)
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	elseif index == 15102	then
setGlobalStorageValue(index, getGlobalStorageValue(index) + 1)
setPlayerStorageValue(cid, 15099, 2)
     
		-- OUTFIT
        local outfit = getCreatureOutfit(cid) 
        outfit.lookHead = 0
        outfit.lookBody = 114
        outfit.lookLegs = 114
        outfit.lookFeet = 114 
        doCreatureChangeOutfit(cid, outfit) 
		
		-- TOWN
		
       doPlayerSetTown(cid, getGlobalStorageValue(15202) )
	   doTeleportThing(cid, getTownTemplePosition(getGlobalStorageValue(15202)), true)


	   
	   
	   elseif index == 15103 then
setGlobalStorageValue(index, getGlobalStorageValue(index) + 1)
setPlayerStorageValue(cid, 15099, 3)
     
		-- OUTFIT
        local outfit = getCreatureOutfit(cid) 
        outfit.lookHead = 114
        outfit.lookBody = 88
        outfit.lookLegs = 88
        outfit.lookFeet = 88
        doCreatureChangeOutfit(cid, outfit) 
		
		-- TOWN
		
       doPlayerSetTown(cid, getGlobalStorageValue(15203) )
	   doTeleportThing(cid, getTownTemplePosition(getGlobalStorageValue(15203)), true)

	   
	   

	   
	   
	   
	   elseif index == 15104 then
setGlobalStorageValue(index, getGlobalStorageValue(index) + 1)
setPlayerStorageValue(cid, 15099, 4)
     
		-- OUTFIT
        local outfit = getCreatureOutfit(cid) 
        outfit.lookHead = 0
        outfit.lookBody = 81
        outfit.lookLegs = 81
        outfit.lookFeet = 81
        doCreatureChangeOutfit(cid, outfit) 
		
		-- TOWN
		
       doPlayerSetTown(cid, getGlobalStorageValue(15204) )
	   doTeleportThing(cid, getTownTemplePosition(getGlobalStorageValue(15204)), true)
end	
	
	
	
	
	return true
	end	
		
	
	
	
	


return true
end


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

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.6k

Informação Importante

Confirmação de Termo