Jump to content

evento de times, iniciar e finalizar para todos ...


Recommended Posts

Eai, preciso de ajuda aqui, estou tentando desenvolver um evento, para todos jogadores, mas que só o admin pode inicia-lo com o comando.

Basicamente só esta funcionando com o jogador que cria o evento, tipo só o Admin.

Para Finalizar o evento a mesma coisa, só finaliza para o Admin que iniciou.

Server-side

event_iniciado = 1

local spawns = { 
	{ 5460.70264, -1825.30945, 10.97057 },
	{ 5454.74805, -1884.13953, 10.29621 },
	{ 5537.57373, -1887.13306, 11.04092 },
	{ 5545.14746, -1829.44873, 10.29401 },
	{ 5501.95557, -1861.66174, 10.29621 }
}

function start_admin_event (player)
	
	if event_iniciado == 1 then
		event_iniciado = event_iniciado +1

		local accName = getAccountName ( getPlayerAccount ( player ) )
		if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Owner" ) ) then 
		
			zonapvp = createColRectangle (  5441.9, -1926.4, 119.5, 133 )
		
			function entrar_na_zona( theElement, matchingDimension )
				if ( theElement == player ) then
					outputChatBox( "Working One" )
					redirecionar_team (player)
				end
			end
			addEventHandler("onColShapeHit", zonapvp, entrar_na_zona)

			function sair_da_zona( theElement, matchingDimension )
				if ( theElement == player ) then 
					outputChatBox( "Working Two" )
					retirar_team (player)
				end
			end
			addEventHandler("onColShapeLeave", zonapvp, sair_da_zona)
		
			
			outputDebugString ("Evento Iniciado")
				
			i = 0

			pvp_1 = createTeam("PVP-Red [use /pvp]", 255, 0, 0)
			pvp_2 = createTeam("PVP-Green [use /pvp]", 0, 255, 0)
			pvp_3 = createTeam("PVP-Blue [use /pvp]", 0, 0, 255)
			pvp_4 = createTeam("PVP-Yellow [use /pvp]", 255, 255, 0)
			

			addCommandHandler ( "pvp", tele )
		end						
	else
		outputChatBox("O evento ja esta ativado", player, 255, 0, 0)
	end	
end
addCommandHandler ( "startEvent", start_admin_event )

function tele(player)		  
	local teles = math.random ( #spawns )
	if ( teles ) then
			setElementPosition(player, unpack ( spawns [ teles ] ))
	end	
end


function redirecionar_team (thePlayer)

	playerTeam = getPlayerTeam(thePlayer)

	i = i + 1
	if i > 4 then 
		i = 1
	end

	if pvp_1 and pvp_2 and pvp_3 and pvp_4 then 
		if i == 1 then 
			setPlayerTeam ( thePlayer, pvp_1 )
		end
		if i == 2 then 
			setPlayerTeam ( thePlayer, pvp_2 )
		end
		if i == 3 then 
			setPlayerTeam ( thePlayer, pvp_3 )
		end
		if i == 4 then 
			setPlayerTeam ( thePlayer, pvp_4 )
		end
	end
end
			
function retirar_team (player)
	setPlayerTeam ( player, playerTeam )
end

addCommandHandler("stopEvent",
function (player)
	 local accName = getAccountName ( getPlayerAccount ( player ) )
     if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Owner" ) ) then
		if event_iniciado >= 2 then
			destroyElement ( zonapvp )
			destroyElement ( pvp_1 )
			destroyElement ( pvp_2 )
			destroyElement ( pvp_3 )
			destroyElement ( pvp_4 )
			removeCommandHandler ( "pvp" )
			event_iniciado = 1
			retirar_team ()
		else
			outputChatBox("Não possivel parar, porque não foi iniciado", player, 255, 0, 0)
		end
	end
end)

 

Link to comment
  • Moderators

Você pode usar element-data no comando pvp setar o jogador no evento, então nos eventos colshape basta fazer e verificação:

if getElementType(theElement) == "player" then
	if getElementData(theElement, "evento-pvp") then
		outputChatBox( "Working One" )
		redirecionar_team (theElement)
	else
  		outputChatBox( "Você não está neste evento! Digite /pvp para entrar", theElement )
	end
end

 

  • Thanks 1
Link to comment
16 hours ago, DNL291 said:

 

Entendi o que você quis dizer, porem acho que agr não e mais necessario eu puxei as funções para fora assim elas funcionam para todos, porem agora tenho outra dificuldade ..

Tipo cada vez que o jogador usa o commando o evento, e retirado a informação  playerTeam = getPlayerTeam(player), porem se varios player usarem não vai salvar individualmente a de cada um então, tipo preciso que cada player retorne ao time que estava, não ao team do ultimo player  que usou o commando. sabe me dizer como faze-lo ?

 

zonapvp = createColRectangle (  5441.9, -1926.4, 119.5, 133 )

event_iniciado = 1

local spawns = { 
	{ 5460.70264, -1825.30945, 10.97057 },
	{ 5454.74805, -1884.13953, 10.29621 },
	{ 5537.57373, -1887.13306, 11.04092 },
	{ 5545.14746, -1829.44873, 10.29401 },
	{ 5501.95557, -1861.66174, 10.29621 }
}

function start_admin_event (player)
	
	if event_iniciado == 1 then			
		local accName = getAccountName ( getPlayerAccount ( player ) )
		if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Owner" ) ) then 	
			outputDebugString ("Evento Iniciado")
			event_iniciado = event_iniciado +1
			
			i = 0

			pvp_1 = createTeam("PVP-Red [use /pvp]", 255, 0, 0)
			pvp_2 = createTeam("PVP-Green [use /pvp]", 0, 255, 0)
			pvp_3 = createTeam("PVP-Blue [use /pvp]", 0, 0, 255)
			pvp_4 = createTeam("PVP-Yellow [use /pvp]", 255, 255, 0)
			

			addCommandHandler ( "pvp", tele )
		end						
	else
		outputChatBox("O evento ja esta ativado", player, 255, 0, 0)
	end	
end
addCommandHandler ( "eventStart", start_admin_event )

function entrar_na_zona( thePlayer, matchingDimension )
	if getElementType ( thePlayer ) == "player" then
		outputChatBox( "Working One" )
		redirecionar_team (thePlayer )
	end
end
addEventHandler("onColShapeHit", zonapvp, entrar_na_zona)

function sair_da_zona( thePlayer, matchingDimension )
	if getElementType ( thePlayer ) == "player" then
		outputChatBox( "Working Two" )
		retirar_team (thePlayer )
	end
end
addEventHandler("onColShapeLeave", zonapvp, sair_da_zona)


function tele(player)		  
	local teles = math.random ( #spawns )
	if ( teles ) then
			setElementPosition(player, unpack ( spawns [ teles ] ))
	end	
end


function redirecionar_team (thePlayer)

	playerTeam = getPlayerTeam(thePlayer)

	i = i + 1
	if i > 4 then 
		i = 1
	end

	if pvp_1 and pvp_2 and pvp_3 and pvp_4 then 
		if i == 1 then 
			setPlayerTeam ( thePlayer, pvp_1 )
		end
		if i == 2 then 
			setPlayerTeam ( thePlayer, pvp_2 )
		end
		if i == 3 then 
			setPlayerTeam ( thePlayer, pvp_3 )
		end
		if i == 4 then 
			setPlayerTeam ( thePlayer, pvp_4 )
		end
	end
end
			
function retirar_team (player)
	setPlayerTeam ( player, playerTeam )
end

addCommandHandler("stop123",
function (player)
	 local accName = getAccountName ( getPlayerAccount ( player ) )
     if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Owner" ) ) then
		if event_iniciado >= 2 then
			destroyElement ( pvp_1 )
			destroyElement ( pvp_2 )
			destroyElement ( pvp_3 )
			destroyElement ( pvp_4 )
			removeCommandHandler ( "pvp" )
			event_iniciado = 1
			retirar_team ()
		else
			outputChatBox("Não possivel parar, porque não foi iniciado", player, 255, 0, 0)
		end
	end
end)

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...