Jump to content

tempo para entrar no carro


Recommended Posts

Olá novamente, esqueci de perguntar uma coisa, o market devo criar no lado server ou no client

se eu criar no client como vou fazer para detectar o veiculo que foi criado no lado server ?

Mfim6 = createMarker (213.45134, 1908.39001, 17.64063 -1, "cylinder", 2, 0 ,255 ,0, 255)
Bfim6 = createBlipAttachedTo ( Mfim6, 19 )

 

Link to comment
  • Moderators

Tô meio sem entender do que é essa marker e o blip. Se for de uma execução relacionada ao jogador local deixe no lado client. E sobre o veículo, depende de qual forma ele vai precisar ser "detectado", mas isso é usando um trigger no lado server.

Link to comment
12 hours ago, DNL291 said:

Tô meio sem entender do que é essa marker e o blip. Se for de uma execução relacionada ao jogador local deixe no lado client. E sobre o veículo, depende de qual forma ele vai precisar ser "detectado", mas isso é usando um trigger no lado server.

O marker é o final da missão, onde voçê deve ir depois de pegar o veiculo

Link to comment
  • Other Languages Moderators
1 minute ago, kevincouto6 said:

O marker é o final da missão, onde voçê deve ir depois de pegar o veiculo

Creio que o marker fique melhor server-side. Mas você vai precisar definir o jogador como "dono" do marker pra outro usuário não finalizar a missão no lugar dele.

E pare de usar Ç na palavra você.

Link to comment
24 minutes ago, Lord Henry said:

Creio que o marker fique melhor server-side. Mas você vai precisar definir o jogador como "dono" do marker pra outro usuário não finalizar a missão no lugar dele.

E pare de usar Ç na palavra você.

porém como vou definir que o marker vai ser para apenas o player que esta na missão no lado server ?

este é o modo que eu estava tentando

Client-side 

function finalCarMission6 ( veh6 )

	Mfim6 = createMarker (213.45134, 1908.39001, 17.64063 -1, "cylinder", 2, 0 ,255 ,0, 255)
	Bfim6 = createBlipAttachedTo ( Mfim6, 19 )

	function finalmission6 (source)
		if veh6[source] and isElement(veh6[source]) then
			outputDebugString("Test")
		else
		end
	end
	addEventHandler("onClientMarkerHit", Mfim6, finalmission6)

end
addEvent ("final6car", true)
addEventHandler ("final6car", getRootElement(), finalCarMission6)

Server-side

    function entrar6 (thePlayer)
        if isTimer (timerVeh6[thePlayer]) then 
            killTimer (timerVeh6[thePlayer])
            outputChatBox("Você entrou no veiculo", player , 255, 0, 0)
            destroyElement( Bfim6 )
            triggerClientEvent (thePlayer, "final6car", thePlayer, veh6)
        end
    end
    addEventHandler ("onVehicleEnter", veh6[client], entrar6)

Porem e possivel completar com qualquer carro, eu não consegui especificar o player da missão e o veiculo da missão

 

Edited by kevincouto6
Link to comment

Eu editei o post acima, se tiver como usar aquele, me avise, vou tentar fazer no formato que você falou

modo server !

	function entrar6 (thePlayer)
		if isTimer (timerVeh6[thePlayer]) then 
			killTimer (timerVeh6[thePlayer])
			outputChatBox("Você entrou no veiculo", player , 255, 0, 0)
			destroyElement( Bfim6 )
			--triggerClientEvent (thePlayer, "final6car", thePlayer, veh6)
			aposEstarVeh6 ( )
		end
	end
	addEventHandler ("onVehicleEnter", veh6[client], entrar6)

	function aposEstarVeh6 ()
		Mfim6 = createMarker (213.45134, 1908.39001, 17.64063 -1, "cylinder", 2, 0 ,255 ,0, 255)
		Bfim6 = createBlipAttachedTo ( Mfim6, 19 )

		function missionCompleted6 (client)
			if veh6[client] and isElement(veh6[client]) then
				destroyElement (veh6[client])
				destroyElement (Mfim6)
				destroyElement (Bfim6)
				veh6[client] = nil
				setElementData( client, "Trabalho", nil, false )
			end
		end
		addEventHandler ("onMarkerHit", Mfim6, missionCompleted6)
		end

modo client

function finalCarMission6 ( veh6 )

	Mfim6 = createMarker (213.45134, 1908.39001, 17.64063 -1, "cylinder", 2, 0 ,255 ,0, 255)
	Bfim6 = createBlipAttachedTo ( Mfim6, 19 )

	function finalmission6 (source)
		if veh6[source] and isElement(veh6[source]) then
			outputDebugString("Test")
		else
		end
	end
	addEventHandler("onClientMarkerHit", Mfim6, finalmission6)

end
addEvent ("final6car", true)
addEventHandler ("final6car", getRootElement(), finalCarMission6)

modo client no lado serve

    function entrar6 (thePlayer)
        if isTimer (timerVeh6[thePlayer]) then 
            killTimer (timerVeh6[thePlayer])
            outputChatBox("Você entrou no veiculo", player , 255, 0, 0)
            destroyElement( Bfim6 )
            triggerClientEvent (thePlayer, "final6car", thePlayer, veh6)
        end
    end
    addEventHandler ("onVehicleEnter", veh6[client], entrar6)

porem ambos os modos tem o mesmo problema e possivel completar com qualquer veiculo

qual modo devo usar, e como resolver na hora de detectar o veiculo e o jogador ?

Edited by kevincouto6
Link to comment
  • Moderators

Difícil entender o seu código no client já que não vimos o seu código completo. 

Você pode detectar que o veículo é o mesmo da missão setando um element-data quando o veículo é criado. Exemplo:

setElementData( veh6[client], "Owner", client )

Client:

function finalmission6 (hitElement, md)
	if getElementType(hitElement) == "vehicle" and getElementData(hitElement, "Owner") == localPlayer and md then
		--O veículo da missão atingiu a marker
	end
end
addEventHandler("onClientMarkerHit", Mfim6, finalmission6)

 

Edited by DNL291
Link to comment

@DNL291

Aqui esta o lado client

local localitionveh6 = {
    [1] = {401, 213.33366, 1871.35400, 13.14063, 0, 0, 270},
    [2] = {401, 213.33366, 1871.35400, 13.14063, 0, 0, 270},
    [3] = {401, 213.33366, 1871.35400, 13.14063, 0, 0, 270},
    [4] = {401, 213.33366, 1871.35400, 13.14063, 0, 0, 270},
    [5] = {401, 213.33366, 1871.35400, 13.14063, 0, 0, 270},
}
local i = 1 

function createPlayerLocation6()

    local vx ,vy, vz, vrot = localitionveh6[ i ][ 2 ], localitionveh6[ i ][ 3 ], localitionveh6[ i ][ 4 ], localitionveh6[ i ][ 7 ]
    i = i + 1
    if i > #localitionveh6 then 
        i = 1
    end
    
    triggerServerEvent( "iniciaJob6", localPlayer, vx, vy, vz, vrot )
    
end

function finalCarMission6 ( veh6 )
    Mfim6 = createMarker (213.45134, 1908.39001, 17.64063 -1, "cylinder", 2, 0 ,255 ,0, 255)
    Bfim6 = createBlipAttachedTo ( Mfim6, 19 )
    
    function finalmission6 (hitElement, md)
        if getElementType(hitElement) == "vehicle" and getElementData(hitElement, "Owner") == localPlayer and md then
            outputChatBox ("funcionado")
        end
    end
    addEventHandler("onClientMarkerHit", Mfim6, finalmission6)
end
addEvent ("final6car", true)
addEventHandler ("final6car", getRootElement(), finalCarMission6)

Aqui esta o lado Server

local veh6 = {}
local timerVeh6 = {}

function inicio6 ( vx, vy, vz, vrot )
	if client ~= source or not (vrot) then return end -- cheater detected!
	if isElement (veh6[client]) then 
		destroyElement (veh6[client])
	end
	
	setElementData( client, "Trabalho", true, false ) -- seta o jogador no element-data "Trabalho"; sinc com o client desativada
	
	veh6[client] = createVehicle ( 401, vx, vy, vz, 0, 0, vrot )
	outputChatBox ("#ffff00Drive the vehicle to the checkpoint. Note: You cannot leave the car during the mission.", client, 0, 0, 0, true)
	
	timerVeh6[client] = setTimer( addEndMissionTimer, 60000, 1,  client )
	
	local Bfim6 = createBlipAttachedTo ( veh6[client], 15 )
	
	local player = client
	addEventHandler ( "onVehicleExplode", veh6[player], function ()
		destroyElement (source)
		veh6[player] = nil
		takePlayerMoney ( player, 5000 )
		setElementData( player, "Trabalho", nil, false )
		outputChatBox("Mission failed, your veh6icle blew up.", player , 255, 0, 0)
	end)
	
	function entrar6 (thePlayer)
		if isTimer (timerVeh6[thePlayer]) then 
			killTimer (timerVeh6[thePlayer])
			outputChatBox("Você entrou no veiculo", player , 255, 0, 0)
			destroyElement( Bfim6 )
			triggerClientEvent (thePlayer, "final6car", thePlayer, veh6[client])
		end
	end
	addEventHandler ("onVehicleEnter", veh6[client], entrar6)
	
end
addEvent ("iniciaJob6", true) 
addEventHandler ("iniciaJob6", getRootElement(), inicio6)

function playerDead6()
	if veh6[source] then
		outputChatBox ( "Missão falhou: Você morreu!", source, 255, 255, 255, true )
		destroyElement (veh6[source])
		veh6[source] = nil
		setElementData( source, "Trabalho", nil, false )
	end
end
addEventHandler ( "onPlayerWasted", getRootElement(), playerDead6)

function sair6 (thePlayer) --If you leave the vehicle for more than 1 min and do not return then the vehicle will disappear and the mission will failled--
	if source == veh6[thePlayer] then 
		if isTimer (timerVeh6[thePlayer]) then 
			resetTimer (timerVeh6[thePlayer]) 
		else 
			timerVeh6[thePlayer] = setTimer( addEndMissionTimer, 60000, 1,  thePlayer )
		end
	end
end
addEventHandler ("onVehicleExit", getRootElement(), sair6)

function addEndMissionTimer( player )
	if player then
		if not ( isElement( veh6[player] ) ) then return end
		
		if getVehicleController( veh6[player] ) ~= player then
			outputChatBox ( "Voçê Nao entrou no veiculo a tempo mission failed", player, 255, 255, 255, true )
			destroyElement ( veh6[player] )
			veh6[player] = nil
			setElementData( player, "Trabalho", nil, false ) 
		end
	end
end

 

Okay eu add o script completo, 

Este setElementData( client, "Trabalho", true, false ) e ativado quando a missão e ativada, porem ele não especifica o Veh tentei fazer do jeito que você sugerio porem não funcionou, and no debug não aparece nenhum erro

Link to comment
  • Moderators

Esse setElementData já é outra coisa. O que eu mostrei é só colar depois do createVehicle:

function inicio6 ( vx, vy, vz, vrot )
	if client ~= source or not (vrot) then return end -- cheater detected!
	if isElement (veh6[client]) then 
		destroyElement (veh6[client])
	end
	
	setElementData( client, "Trabalho", true, false ) -- seta o jogador no element-data "Trabalho"; sinc com o client desativada
	
	veh6[client] = createVehicle ( 401, vx, vy, vz, 0, 0, vrot )
	setElementData( veh6[client], "Owner", client )
	outputChatBox ("#ffff00Drive the vehicle to the checkpoint. Note: You cannot leave the car during the mission.", client, 0, 0, 0, true)
	
	timerVeh6[client] = setTimer( addEndMissionTimer, 60000, 1,  client )
	
	local Bfim6 = createBlipAttachedTo ( veh6[client], 15 )
	
	local player = client
	addEventHandler ( "onVehicleExplode", veh6[player], function ()
		destroyElement (source)
		veh6[player] = nil
		takePlayerMoney ( player, 5000 )
		setElementData( player, "Trabalho", nil, false )
		outputChatBox("Mission failed, your veh6icle blew up.", player , 255, 0, 0)
	end)
	
	function entrar6 (thePlayer)
		if isTimer (timerVeh6[thePlayer]) then 
			killTimer (timerVeh6[thePlayer])
			outputChatBox("Você entrou no veiculo", player , 255, 0, 0)
			destroyElement( Bfim6 )
			triggerClientEvent (thePlayer, "final6car", thePlayer, veh6[client])
		end
	end
	addEventHandler ("onVehicleEnter", veh6[client], entrar6)
	
end
addEvent ("iniciaJob6", true) 
addEventHandler ("iniciaJob6", getRootElement(), inicio6)

 

12 hours ago, kevincouto6 said:

Aqui esta o lado client


local localitionveh6 = {
    [1] = {401, 213.33366, 1871.35400, 13.14063, 0, 0, 270},
    [2] = {401, 213.33366, 1871.35400, 13.14063, 0, 0, 270},
    [3] = {401, 213.33366, 1871.35400, 13.14063, 0, 0, 270},
    [4] = {401, 213.33366, 1871.35400, 13.14063, 0, 0, 270},
    [5] = {401, 213.33366, 1871.35400, 13.14063, 0, 0, 270},
}
local i = 1 

function createPlayerLocation6()

    local vx ,vy, vz, vrot = localitionveh6[ i ][ 2 ], localitionveh6[ i ][ 3 ], localitionveh6[ i ][ 4 ], localitionveh6[ i ][ 7 ]
    i = i + 1
    if i > #localitionveh6 then 
        i = 1
    end
    
    triggerServerEvent( "iniciaJob6", localPlayer, vx, vy, vz, vrot )
    
end

function finalCarMission6 ( veh6 )
    Mfim6 = createMarker (213.45134, 1908.39001, 17.64063 -1, "cylinder", 2, 0 ,255 ,0, 255)
    Bfim6 = createBlipAttachedTo ( Mfim6, 19 )
    
    function finalmission6 (hitElement, md)
        if getElementType(hitElement) == "vehicle" and getElementData(hitElement, "Owner") == localPlayer and md then
            outputChatBox ("funcionado")
        end
    end
    addEventHandler("onClientMarkerHit", Mfim6, finalmission6)
end
addEvent ("final6car", true)
addEventHandler ("final6car", getRootElement(), finalCarMission6)

 

Eu esperava por um código do client maior sinceramente, até porque já tem mais de 5 meses que você criou esse post e esses nomes: "finalCarMission6", "final6car", "Mfim6" me levou a pensar que o script funciona com a criação de várias rotas. Mas enfim, o triggerClientEvent na linha 33 tem o veículo sendo passado desnecessariamente, remova veh6[client] do último argumento.

Link to comment

Eu testei oq vc pediu pra mim fazer, porem não funcionou, no lado client.

Porem no debug não aparece nenhum erro, onclientHitmarker esta funcionando porem na hora de detectar o setElementData q foi criado no lado server não e possivel

Sobre o tempo de 5 meses eu estava ocupado com a escola e trabalho mas agor estou de ferias então posso me dedicar mais 

Edited by kevincouto6
Link to comment
  • Moderators

Só o onClientMarkerHit não funcionou?

Encontrei o problema nele, o parâmetro é hitPlayer e eu tinha verificado se é o veículo. Corrigido:

function finalCarMission6 ( veh6 )
    Mfim6 = createMarker (213.45134, 1908.39001, 17.64063 -1, "cylinder", 2, 0 ,255 ,0, 255)
    Bfim6 = createBlipAttachedTo ( Mfim6, 19 )
    
    function finalmission6 (hitPlayer, md)
		local playerVeh = getPedOccupiedVehicle(hitPlayer)
        if hitPlayer == localPlayer and playerVeh and getElementData(playerVeh, "Owner") == hitPlayer and md then
            outputChatBox ("funcionado")
        end
    end
    addEventHandler("onClientMarkerHit", Mfim6, finalmission6)
end
addEvent ("final6car", true)
addEventHandler ("final6car", getRootElement(), finalCarMission6)

 

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