Jump to content

Guincho Trabalho ajuda


Recommended Posts

Server-side

local veh7 = {}
local vehGuincho7 = {}

local timerVeh7 = {}

function inicio7 ( vx7, vy7, vz7, vrot7, vxGuin7, vyGuin7, vzGuin7, vrotGuin7 )
	if client ~= source or not (vrot7) then return end -- cheater detected!
	if isElement (veh7[client]) then 
		destroyElement (veh7[client])
	end
	
	setElementData( client, "Trabalho7", true, false ) -- seta o jogador no element-data "Trabalho"; sinc com o client desativada
	
	veh7[client] = createVehicle ( 525, vx7, vy7, vz7, 0, 0, vrot7 )
	outputChatBox ("#ffff00Drive the vehicle to the checkpoint. Note: You cannot leave the car during the mission.", client, 0, 0, 0, true)
	warpPedIntoVehicle (client, veh7[client])
	
	vehGuincho7[client] = createVehicle ( 602, vxGuin7, vyGuin7 + 5, vzGuin7, 0, 0, vrotGuin7 )
	GuinchoPed = createPed ( 120, vxGuin7 ,vyGuin7, vzGuin7 )
	warpPedIntoVehicle ( GuinchoPed, vehGuincho7[client] )
	setVehicleEngineState  ( vehGuincho7[client], false )
	
	--setElementData( vehGuincho7[client], "Owner7", client )
	
	triggerClientEvent (client, "createMakerFim7", client, GuinchoPed) 
	
	timerVeh7[client] = setTimer( addEndMissionTimer7, 5000, 1,  client )
	
	local player = client
	addEventHandler ( "onVehicleExplode", veh7[player], function ()
		destroyElement (source)
		veh7[player] = nil
		takePlayerMoney ( player, 5000 )
		setElementData( player, "Trabalho7", nil, false )
		setElementData( player, "Owner7", nil )
		outputChatBox("Mission failed, your veh6icle blew up.", player , 255, 0, 0)
		triggerClientEvent (player, "destroyMarkerAndBlips7", player)		
	end)
	
	function entrar7 (thePlayer)
		if isTimer (timerVeh7[thePlayer]) then 
			killTimer (timerVeh7[thePlayer]) 
		end
	end
	addEventHandler ("onVehicleEnter", veh7[client], entrar7)
end
addEvent ("iniciaJob7", true) 
addEventHandler ("iniciaJob7", getRootElement(), inicio7)

function playerDead7()
	if veh7[source] then
		outputChatBox ( "Missão falhou: Você morreu!", source, 255, 255, 255, true )
		destroyElement (veh7[source])
		veh7[source] = nil
		setElementData( source, "Trabalho7", nil, false )
		setElementData( source, "Owner7", nil )
		triggerClientEvent (source, "destroyMarkerAndBlips7", source) 
	end
end
addEventHandler ( "onPlayerWasted", getRootElement(), playerDead7)

function sair7 (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 == veh7[thePlayer] then 
		if isTimer (timerVeh7[thePlayer]) then 
			resetTimer (timerVeh7[thePlayer]) 
		else 
			timerVeh7[thePlayer] = setTimer( addEndMissionTimer7, 5000, 1,  thePlayer )
		end
	end
end
addEventHandler ("onVehicleExit", getRootElement(), sair7)

function addEndMissionTimer7( player )
	if player then
		if not ( isElement( veh7[player] ) ) then return end
		
		if getVehicleController( veh7[player] ) ~= player then
			outputChatBox ( "Voçê Nao entrou no veiculo a tempo mission failed", player, 255, 255, 255, true )
			destroyElement ( veh7[player] )
			veh7[player] = nil
			setElementData( player, "Trabalho7", nil, false )
			setElementData( player, "Owner7", nil )
			triggerClientEvent (player, "destroyMarkerAndBlips7", player) 
		end
	end
end

function completedMission7 ()
	if veh7[source] then
		outputChatBox ( "Completou a missão!", source, 255, 255, 255, true )
		destroyElement (veh7[source])
		veh7[source] = nil
		setElementData( source, "Trabalho7", nil, false )
		setElementData( source, "Owner7", nil )
		triggerClientEvent (source, "destroyMarkerAndBlips7", source)
	end
end
addEvent ("completedFinalMission7", true) 
addEventHandler ("completedFinalMission7", getRootElement(), completedMission7)

function abandenedMission7 ()
		outputChatBox ( "Mission abandoned", source, 255, 255, 255, true )
		destroyElement (veh7[source])
		veh7[source] = nil
		setElementData( source, "Trabalho7", nil, false )
		setElementData( source, "Owner7", nil )
		triggerClientEvent (source, "destroyMarkerAndBlips7", source)
end
addEvent ("abandenedMission7", true) 
addEventHandler ("abandenedMission7", getRootElement(), abandenedMission7)

Client-side

localitionveh7 = {
	[1] = {525, 212.63116, 1906.95349, 17.64063, 0, 0, 270},
	[2] = {525, 212.63116, 1906.95349, 17.64063, 0, 0, 270},
	[3] = {525, 212.63116, 1906.95349, 17.64063, 0, 0, 270},
	[4] = {525, 212.63116, 1906.95349, 17.64063, 0, 0, 270},
	[5] = {525, 212.63116, 1906.95349, 17.64063, 0, 0, 270},
}

localitionGuinchoVeh7 = {
	[1] = {525, 212.63116, 1906.95349, 17.64063, 0, 0, 270},
	[2] = {525, 212.63116, 1906.95349, 17.64063, 0, 0, 270},
	[3] = {525, 212.63116, 1906.95349, 17.64063, 0, 0, 270},
	[4] = {525, 212.63116, 1906.95349, 17.64063, 0, 0, 270},
	[5] = {525, 212.63116, 1906.95349, 17.64063, 0, 0, 270},
}

local i = 1 
local iGuin = 1 

function createPlayerLocation7()
	
	local vx7 ,vy7, vz7, vrot7 = localitionveh7[ i ][ 2 ], localitionveh7[ i ][ 3 ], localitionveh7[ i ][ 4 ], localitionveh7[ i ][ 7 ]
	i = i + 1
	if i > #localitionveh7 then 
		i = 1
	end
	
	local vxGuin7 ,vyGuin7, vzGuin7, vrotGuin7 = localitionGuinchoVeh7[ iGuin ][ 2 ], localitionGuinchoVeh7[ iGuin ][ 3 ], localitionGuinchoVeh7[ iGuin ][ 4 ], localitionGuinchoVeh7[ iGuin ][ 7 ]
	iGuin = iGuin + 1
	if iGuin > #localitionGuinchoVeh7 then 
		iGuin = 1
	end
	
	triggerServerEvent( "iniciaJob7", localPlayer, vxGuin7, vyGuin7, vzGuin7, vrotGuin7, vx7 ,vy7, vz7, vrot7 )
	
end

function finalCarMission7 ( GuinchoPed )

	Mfim7 = createMarker (201.09660, 1902.68530, 17.64063 -1, "cylinder", 2, 0 ,255 ,0, 255)
	Bfim7 = createBlipAttachedTo ( Mfim7, 19 )
 
    function finalmission7 ()
        
		if isPedInVehicle ( GuinchoPed )  then
			triggerServerEvent( "completedFinalMission7", localPlayer )
        end
    end
    addEventHandler("onClientMarkerHit", Mfim7, finalmission7)
	
end
addEvent ("createMakerFim7", true)
addEventHandler ("createMakerFim7", getRootElement(), finalCarMission7)


function destroyMarker7 ()

	--completMission ()

	if isElement ( Mfim7 ) then
		destroyElement ( Mfim7 )
	end
	
	if isElement ( Bfim7 ) then
		destroyElement ( Bfim7 )
	end
end
addEvent ("destroyMarkerAndBlips7", true) 
addEventHandler ("destroyMarkerAndBlips7", getRootElement(), destroyMarker7)

Estou Projetando uma missão de guincho ou seja, algumas coisas funcionaram me b mas preciso especificar alguma coisas e resolver erros podem me ajudar 

* O guincho não consegue puxar o veiculo com o PED dentro, ache q fosse devido o carro ficar ligado então tentei "setVehicleEngineState  ( vehGuincho7[client], false )" para desligar o veiculo enquanto o PED estava dentro porem mesmo assim não funcionou.

* No final da missão onde voçê encontra o Marker, eu consegui especificar que o PED esta no veiculo, mas na hora do "onClientMarkerHit" ele vai funcionar apenas se eu passar com o veiculo não vai detectar se o  carro guinchado esta junto.

*o warpPedIntoVehicle, que puxa o jogador para o veiculo da  missão tem um problema, ele funciona normalmente comigo, mas quando online ele não funciona com os outros jogadores, mas ainda sim continua funcionando comigo

Link to comment
  • Moderators

Seria bom se você descrevesse como o script funciona pra quem for ajudar ao menos entender a lógica sem ter que tentar entender olhando pelo código.

Debugscript mostra erros? Tentou rebocar o veículo sem o ped estar dentro?

9 hours ago, kevincouto6 said:

*o warpPedIntoVehicle, que puxa o jogador para o veiculo da  missão tem um problema, ele funciona normalmente comigo, mas quando online ele não funciona com os outros jogadores, mas ainda sim continua funcionando comigo

Não sei se entendi bem aqui, mas o certo é o script funcionar apenas para o client/dono do veículo. E a variável GuinchoPed é melhor deixá-la numa tabela também.

Creio que estas funções serão úteis pra você:

getVehicleTowedByVehicle
getVehicleTowingVehicle

 

Link to comment
16 hours ago, DNL291 said:

Seria bom se você descrevesse como o script funciona pra quem for ajudar ao menos entender a lógica sem ter que tentar entender olhando pelo código.

Debugscript mostra erros? Tentou rebocar o veículo sem o ped estar dentro?

Não sei se entendi bem aqui, mas o certo é o script funcionar apenas para o client/dono do veículo. E a variável GuinchoPed é melhor deixá-la numa tabela também.

Creio que estas funções serão úteis pra você:


getVehicleTowedByVehiclegetVehicleTowingVehicle

 

Eu decidi remover o PED, pois não consegui resolver o bug do ped dentro do veiculo

então até agora não encontrei mais bugs porem aqui não sei como fazer

BcarLocal7 = seria onde o veiculo de ser encontrado, Ou seja o veiculo que precisa ser guinchado, eu gostaria de fazer um detector para destruir e para criar  "BcarLocal7" 

Quando estiver guinchado (" destroy BcarLocal7")

Quando não estiver guinchado (" create BcarLocal7")

como não existe uma função "onVehicleTowedByVehicle"  para usar no EventHandler eu usei "onClientRender" para fazer varios detectamentos até o veiculo esta guinchado, isso esta certo ou existe outra forma mais correta de fazer

"nenhum bug encontrado no debugscript 3"

Client Side

function finalCarMission7 ( veh7, client, vehGuincho7 )

	BcarLocal7 = createBlipAttachedTo ( veh7[client], 13 )
	
	function vehTowingVeh7 ()
		if ( getVehicleTowingVehicle ( veh7[client] ) == vehGuincho7[client] ) then -- if it attached
			Mfim7 = createMarker (201.09660, 1902.68530, 17.64063 -1, "cylinder", 2, 0 ,255 ,0, 255)
			Bfim7 = createBlipAttachedTo ( Mfim7, 19 )
			destroyElement (BcarLocal7)
			removeEventHandler("onClientRender", getRootElement(), vehTowingVeh7)
		end
	end
	addEventHandler ( "onClientRender", getRootElement(), vehTowingVeh7 )
	
	function finalmissionRender7 ()
		if isElement ( Mfim7 ) then
		removeEventHandler("onClientRender", getRootElement(), vehTowingVeh7)
			if isElement ( Mfim7 ) then
				function finalmission7 ()
					if ( getVehicleTowingVehicle ( veh7[client] ) == vehGuincho7[client] ) then -- if it attached
						triggerServerEvent( "completedFinalMission7", localPlayer )
					else
						outputChatBox ("testing")
					end
				end
				addEventHandler("onClientMarkerHit", Mfim7, finalmission7)
			end
		end
	end
	addEventHandler ( "onClientRender", getRootElement(), finalmissionRender7 )		
	
end
addEvent ("createMakerFim7", true)
addEventHandler ("createMakerFim7", getRootElement(), finalCarMission7)

 

Link to comment
  • Moderators

Tem o evento "onTrailerAttach", mas parece ser só para trailer de caminhões... Sobre o "onClientRender", uma opção melhor seria usar setTimer no lado server.

Para alternar entre a criação e destruição do blip do local (o BcarLocal7) você vai precisar primeiro avançar a primeira parte. Faça a detecção de quando anexar um veículo no outro, feito isso você vai saber quando deve criar/destruir o blip.

Link to comment
13 hours ago, DNL291 said:

 

Eu não entendi muito bem como fazer usando o setTimer.

Tentei este modo porem so funciona uma vez, depois para de funcionar não aparece bug no debugscript 3, porem acho que o erro esta nesta parte, onde e verificado se o veiculo não esta guinchado

" if not ( getVehicleTowingVehicle ( veh7[client] ) == vehGuincho7[client] ) then " 

	function vehNotTowingVeh7 ()
		if not ( getVehicleTowingVehicle ( veh7[client] ) == vehGuincho7[client] ) then -- if it attached
			if not isElement (BcarLocal7) then
				BcarLocal7 = createBlipAttachedTo ( veh7[client], 13 )
			end
			if isElement (Mfim7) and isElement (Bfim7) then
				destroyElement (Mfim7)
				destroyElement (Bfim7)
			end			
		end
	end
	addEventHandler ( "onClientRender", getRootElement(), vehNotTowingVeh7 )
	
	function vehTowingVeh7 ()
		if ( getVehicleTowingVehicle ( veh7[client] ) == vehGuincho7[client] ) then -- if it attached
			Mfim7 = createMarker (201.09660, 1902.68530, 17.64063 -1, "cylinder", 2, 0 ,255 ,0, 255)
			Bfim7 = createBlipAttachedTo ( Mfim7, 19 )
			destroyElement (BcarLocal7)
			outputDebugString("destruido o criar Bcar")
		end
	end
	addEventHandler ( "onClientRender", getRootElement(), vehTowingVeh7 )

 

Link to comment
  • Moderators

Aqui está um exemplo da verificação com setTimer:

local trabalhoGuincho_players = {} -- jogadores nesse trabalho
local g_isAttached = {} -- verifica se o veículo do player está anexado ou não

addEventHandler( "onResourceStart", resourceRoot,
	function()
		setTimer( function()
			if #trabalhoGuincho_players > 0 then -- verifica se tem ao menos 1 pessoa no trabalho
				for _,player in ipairs(trabalhoGuincho_players) do
					-- esse trecho verifica quando anexa o veículo ao outro
					if ( getVehicleTowingVehicle ( veh7[player] ) == vehGuincho7[player] ) and g_isAttached[player] ~= true then -- if it attached
						if isElement(Bfim7[player]) then destroyElement(Bfim7[player]) end
						if isElement(Mfim7[player]) then destroyElement(Mfim7[player]) end
						outputChatBox( "Veículo anexado", player )
						g_isAttached[player] = true
					-- aqui verifica quando solta do veículo guinchado
					elseif (getVehicleTowingVehicle ( veh7[player] ) == vehGuincho7[player]) ~= true and g_isAttached[player] then
						if isElement(Mfim7[player]) ~= true then Mfim7[player] = createMarker (201.09660, 1902.68530, 17.64063 -1, "cylinder", 2, 0 ,255 ,0, 255) end
						if isElement(Bfim7[player]) ~= true then Bfim7[player] = createBlipAttachedTo ( Mfim7[player], 19 ) end
						
						g_isAttached[player] = false
						outputChatBox( "O veículo foi solto", player )
					end
				end
			end
		end, 200, 0 ) -- irá executar esse código a cada 200ms (ou seja 5x por segundo)
	end
)

 

Edited by DNL291
Link to comment
13 hours ago, DNL291 said:

 

Tentei usar o que voçê me sugerio assima porem não funcionou no client, e nem no server, então me baseei no que você mandou e fiz assim, porem estou com um erro

Mission_client

 


localitionveh7 = {
	[1] = {525, 212.63116, 1906.95349, 17.64063, 0, 0, 270},
	[2] = {525, 212.63116, 1906.95349, 17.64063, 0, 0, 270},
	[3] = {525, 212.63116, 1906.95349, 17.64063, 0, 0, 270},
	[4] = {525, 212.63116, 1906.95349, 17.64063, 0, 0, 270},
	[5] = {525, 212.63116, 1906.95349, 17.64063, 0, 0, 270},
}

localitionGuinchoVeh7 = {
	[1] = {525, 224.94553, 1912.85986, 17.85481, 0, 0, 270},
	[2] = {525, 224.94553, 1912.85986, 17.85481, 0, 0, 270},
	[3] = {525, 224.94553, 1912.85986, 17.85481, 0, 0, 270},
	[4] = {525, 224.94553, 1912.85986, 17.85481, 0, 0, 270},
	[5] = {525, 224.94553, 1912.85986, 17.85481, 0, 0, 270},
}

local i = 1 
local iGuin = 1 

function createPlayerLocation7()
	
	local vxGuin7 ,vyGuin7, vzGuin7, vrotGuin7 = localitionGuinchoVeh7[ iGuin ][ 2 ], localitionGuinchoVeh7[ iGuin ][ 3 ], localitionGuinchoVeh7[ iGuin ][ 4 ], localitionGuinchoVeh7[ iGuin ][ 7 ]
	iGuin = iGuin + 1
	if iGuin > #localitionGuinchoVeh7 then 
		iGuin = 1
	end
	
	local vx7 ,vy7, vz7, vrot7 = localitionveh7[ i ][ 2 ], localitionveh7[ i ][ 3 ], localitionveh7[ i ][ 4 ], localitionveh7[ i ][ 7 ]
	i = i + 1
	if i > #localitionveh7 then 
		i = 1
	end
	
	triggerServerEvent( "iniciaJob7", localPlayer, vxGuin7, vyGuin7, vzGuin7, vrotGuin7, vx7 ,vy7, vz7, vrot7 )
	
end

addEvent( "createMakerFim7", true )
addEventHandler( "createMakerFim7", getRootElement(),
	function( vehGuincho7, veh7, client, client )
		local timerBlip7 = setTimer( function()
			if ( getVehicleTowingVehicle ( vehGuincho7[client] ) == veh7[client] ) ~= true then -- if it attached
				if isElement(Bfim7) then destroyElement(Bfim7) end
				if isElement(Mfim7) then destroyElement(Mfim7) end
				if not isElement(BcarLocal7) then BcarLocal7 = createBlipAttachedTo ( vehGuincho7[client], 12 ) end
				--outputChatBox( "O veículo foi solto", player )
			elseif (getVehicleTowingVehicle ( vehGuincho7[client] ) == veh7[client]) ~= false then
				if isElement(Mfim7) ~= true then Mfim7 = createMarker (201.09660, 1902.68530, 17.64063 -1, "cylinder", 2, 0 ,255 ,0, 255) end
				if isElement(Bfim7) ~= true then Bfim7 = createBlipAttachedTo ( Mfim7, 19 ) end
				if isElement(BcarLocal7) then destroyElement(BcarLocal7) end
				--outputChatBox( "Veículo anexado", player )
			end
		end, 200, 0 )

		local timerFinal7 = setTimer( function()
			if isElement ( Mfim7 ) then
					function finalmission7 ()
						if ( getVehicleTowingVehicle ( vehGuincho7[client] ) == veh7[client] ) then -- if it attached
							if isTimer ( timerFinal7 ) ~= false then killTimer ( timerFinal7 ) end
							if isTimer ( timerBlip7 ) ~= false then killTimer ( timerBlip7 ) end
							triggerServerEvent( "completedFinalMission7", localPlayer )
						end
					end
					addEventHandler("onClientMarkerHit", Mfim7, finalmission7)
			end
		end, 200, 0 )
	end
)

function destroyMarker7 ()

	--completMission ()

	if isElement ( BcarLocal7 ) then
		destroyElement ( BcarLocal7 )
	end
	
	if isElement ( Mfim7 ) then
		destroyElement ( Mfim7 )
	end
	
	if isElement ( Bfim7 ) then
		destroyElement ( Bfim7 )
	end
end
addEvent ("destroyMarkerAndBlips7", true) 
addEventHandler ("destroyMarkerAndBlips7", getRootElement(), destroyMarker7)

mission_sever

local veh7 = {}
local vehGuincho7 = {}
local timerVeh7 = {}

function inicio7 (  vxGuin7, vyGuin7, vzGuin7, vrotGuin7, vx7, vy7, vz7, vrot7 )
	if client ~= source or not (vrot7) then return end -- cheater detected!
	if isElement (veh7[client]) then 
		destroyElement (veh7[client])
	end
	
	if client ~= source or not (vrotGuin7) then return end -- cheater detected!
	if isElement (vehGuincho7[client]) then 
		destroyElement (vehGuincho7[client])
	end
	
	
	setElementData( client, "Trabalho7", true, false ) -- seta o jogador no element-data "Trabalho"; sinc com o client desativada
	
	veh7[client] = createVehicle ( 525, vx7, vy7, vz7, 0, 0, vrot7 )
	outputChatBox ("#ffff00Drive the vehicle to the checkpoint. Note: You cannot leave the car during the mission.", client, 0, 0, 0, true)
	warpPedIntoVehicle (client, veh7[client])
	
	vehGuincho7[client] = createVehicle ( 602, vxGuin7, vyGuin7, vzGuin7, 0, 0, vrotGuin7 )
		
	triggerClientEvent (client, "createMakerFim7", client, vehGuincho7, veh7, client, client ) 
	
	timerVeh7[client] = setTimer( addEndMissionTimer7, 50000, 1,  client )
	
	local player = client
	addEventHandler ( "onVehicleExplode", veh7[player], function ()
		destroyElement (source)
		destroyElement (vehGuincho7[player])
		veh7[player] = nil
		vehGuincho7[player] = nil
		takePlayerMoney ( player, 5000 )
		setElementData( player, "Trabalho7", nil, false )
		outputChatBox("Mission failed, your veh6icle blew up.", player , 255, 0, 0)
		triggerClientEvent (player, "destroyMarkerAndBlips7", player)		
	end)
		
	addEventHandler ( "onVehicleExplode", vehGuincho7[player], function ()
		destroyElement (veh7[player])
		destroyElement (source)
		veh7[player] = nil
		vehGuincho7[player] = nil
		takePlayerMoney ( player, 5000 )
		setElementData( player, "Trabalho7", nil, false )
		outputChatBox("Mission failed, your veh6icle blew up.", player , 255, 0, 0)
		triggerClientEvent (player, "destroyMarkerAndBlips7", player)		
	end)
	
	function entrar7 (thePlayer)
		if isTimer (timerVeh7[thePlayer]) then 
			killTimer (timerVeh7[thePlayer]) 
		end
	end
	addEventHandler ("onVehicleEnter", veh7[client], entrar7)
end
addEvent ("iniciaJob7", true) 
addEventHandler ("iniciaJob7", getRootElement(), inicio7)

function playerDead7()
	if veh7[source] or vehGuincho7[source] then
		outputChatBox ( "Missão falhou: Você morreu!", source, 255, 255, 255, true )
		destroyElement (veh7[source])
		destroyElement (vehGuincho7[source])
		veh7[source] = nil
		vehGuincho7[source] = nil
		setElementData( source, "Trabalho7", nil, false )
		triggerClientEvent (source, "destroyMarkerAndBlips7", source) 
	end
end
addEventHandler ( "onPlayerWasted", getRootElement(), playerDead7)

function sair7 (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 == veh7[thePlayer] then 
		if isTimer (timerVeh7[thePlayer]) then 
			resetTimer (timerVeh7[thePlayer]) 
		else 
			timerVeh7[thePlayer] = setTimer( addEndMissionTimer7, 50000, 1,  thePlayer )
		end
	end
end
addEventHandler ("onVehicleExit", getRootElement(), sair7)

function addEndMissionTimer7( player )
	if player then
		if not ( isElement( veh7[player] ) ) then return end
		
		if getVehicleController( veh7[player] ) ~= player then
			outputChatBox ( "Voçê Nao entrou no veiculo a tempo mission failed", player, 255, 255, 255, true )
			destroyElement ( veh7[player] )
			destroyElement (vehGuincho7[player])
			veh7[player] = nil
			vehGuincho7[player] = nil
			setElementData( player, "Trabalho7", nil, false )
			triggerClientEvent (player, "destroyMarkerAndBlips7", player) 
		end
	end
end

function completedMission7 ()
	if veh7[source] then
		outputChatBox ( "Completou a missão!", source, 255, 255, 255, true )
		destroyElement (veh7[source])
		destroyElement (vehGuincho7[source])
		veh7[source] = nil
		vehGuincho7[source] = nil
		setElementData( source, "Trabalho7", nil, false )
		triggerClientEvent (source, "destroyMarkerAndBlips7", source)
	end
end
addEvent ("completedFinalMission7", true) 
addEventHandler ("completedFinalMission7", getRootElement(), completedMission7)

function abandenedMission7 ()
		outputChatBox ( "Mission abandoned", source, 255, 255, 255, true )
		destroyElement (veh7[source])
		destroyElement (vehGuincho7[source])
		veh7[source] = nil
		vehGuincho7[source] = nil
		setElementData( source, "Trabalho7", nil, false )
		triggerClientEvent (source, "destroyMarkerAndBlips7", source)
end
addEvent ("abandenedMission7", true) 
addEventHandler ("abandenedMission7", getRootElement(), abandenedMission7)

porem a só acontece após fazer a primeira vez a missão

exemplo: fiz a missão normalmente tudo funcionando, quando vou Refaze-la, ou seja iniciar novamente ela aparece o erro ao completa-la

WARNING: GUImision/c.mission.lua:106: Bad argument @ 'getVehicleTowingVehicle' [Expected vehicle at argument 1]

e tambem tenho o problema com warpPedIntoVehicle  ( client, veh7[client] ) não aparece nenhum erro no debug, mas funciona apenas em mim, nos outros jogadores não funciona

Edited by kevincouto6
Link to comment
16 minutes ago, Lord Henry said:

Vc por acaso sabe inglês? É pq ajuda bastante a entender os erros se vc souber inglês.

Podemos dizer que meu inglês não é muito bom, mas consigo entender os erros porem não sei porque acontecem,  não tenho curso de .lua ou de lógica de progamação, estou aprendendo muito com vcs do forum que me ajudam, mas tem coisas que tenho muita dificuldade como  #tabelas, #for _player esta partes ainda não compreendi muito como funciona, sobre os erros 

Tipo aparece q o argumento 1 não foi especificado, porem na primeira vez q a missão é feita funciona sem erro, então significa q da primeira vez q foi feita a missão, o veh tinha sido especificado, porem na segunda vez não, por isso não compreendi o erro, se não tivesse funcionado a primeira vez eu saberia q estava errado porem como funcionou, eu não consegui encontrar o erro.

Pude perceber uma coisa este erro apare x29 ou seja, acho q pode estar sendo causado pelo seTimer, será q meu killTimer não esta funcionado ?

Link to comment
  • Other Languages Moderators
8 hours ago, kevincouto6 said:

[...] não tenho curso de .lua ou de lógica de progamação, [...]

https://www.youtube.com/watch?v=M2Af7gkbbro&list=PLHz_AreHm4dmSj0MHol_aoNYCSGFqvfXV&index=2&t=20

Ta ae seu curso. Boa sorte.

-----------------------

Creio que o erro acontece pois na segunda vez a variável client não existe. Na minha opinião, a variável client só deve ser usada no server-side para funções que foram chamadas pelo client-side.

Edited by Lord Henry
Link to comment

Okay, eu tinha as exportado do tringgerEvent do lado server para client, teriam alguma sugestão de como eu poderia fazer para verificar se é o veiculo correto, o veiculo foi criado no lado server, devo usar um setElementData ou algo do tipo para detectar

se é o jogador da missão  

se é o guincho da missão q foi criado pelo jogador da missão

se o carro que precisa ser rebocado e o do jogador

Tenho que fazer estas 3 verificações anter de completar a missão, o script esta acima, podem me sugerir algo?

Fiz o marker do final no lado client para ser visto apenas pelo jogador da missão, 

 

Edited by kevincouto6
Link to comment
  • Moderators

Código bem bagunçado... O timer eu fiz no lado server pois imaginei que você fosse criar os elementos lá. O erro na warpPedIntoVehicle não é em você, é em quem afinal? O veículo do client vai servir para outros jogadores também? Porque da forma que os elementos estão sendo gerenciados (criados para um jogador especifico) não vai permitir que funcione para um segundo jogador.

Sinceramente fica muito difícil pra alguém te ajudar, sem nem entender como as coisas funcionam e começa a montar os trechos de qualquer jeito. Comece estudar programação, o básico, você tá perdido da forma que está. E ajudaremos com explicações e te ajudar a entender como tudo funciona, caso contrário, você vai ficar na mesma sempre, vai ser difícil até pra alguém responder seus posts - eu mesmo já nem tô mais afim.

Edited by DNL291
Link to comment

Okay, Me desculpem vou tentar me expresar melhor 

addEvent( "createMakerFim7", true )
addEventHandler( "createMakerFim7", getRootElement(),
function( vehGuincho7, veh7, client, client )	
		timerBlip7 = setTimer( function()
			if ( getVehicleTowingVehicle ( vehGuincho7[client] ) == veh7[client] ) ~= true then -- if it attached
				if isElement(Bfim7) then destroyElement(Bfim7) end
				if isElement(Mfim7) then destroyElement(Mfim7) end
				if not isElement(BcarLocal7) then BcarLocal7 = createBlipAttachedTo ( vehGuincho7[client], 12 ) end
			elseif (getVehicleTowingVehicle ( vehGuincho7[client] ) == veh7[client]) ~= false then
				if isElement(Mfim7) ~= true then Mfim7 = createMarker (201.09660, 1902.68530, 17.64063 -1, "cylinder", 2, 0 ,255 ,0, 255) end
				if isElement(Bfim7) ~= true then Bfim7 = createBlipAttachedTo ( Mfim7, 19 ) end
				if isElement(BcarLocal7) then destroyElement(BcarLocal7) end
			end
		end, 200, 0 )

		timerFinal7 = setTimer( function()
			if isElement ( Mfim7 ) then
				if isElement ( vehGuincho7[client] ) and isElement ( veh7[client] ) then
					addEventHandler("onClientMarkerHit", Mfim7, function ( hitPlayer, md )
						local playerVeh = getPedOccupiedVehicle(hitPlayer)
						if hitPlayer == localPlayer and playerVeh and getElementData(playerVeh, "Owner7") == hitPlayer and md then
							if ( getVehicleTowingVehicle ( vehGuincho7[client] ) == veh7[client] ) then 
								triggerServerEvent( "completedFinalMission7", localPlayer )
							end
						end
					end	)
				end
			end
		end, 200, 0 )
end )

Queria a opinião  de vcs sobre, crei dois 2 timer um para verificar o veiculo e o guincho, o outro timer fiz para verifica se o marker foi criado

Explicando script

* TimerBlip7

Faz as verificações para ver se o veiculo esta guinchado ou não

*TimerFinal7

As primeira e a segunda verificação é se os elementos foram criados! 

A terceira e "getElementData" que vcs me ensinara a fazer para verificar se é o JOGADOR, é o player da missão 

A Quarta verificação  é se o Veiculo esta Guinchado ao outro.

esta e a parte que usei para destruir as coisas quando a missão for completa or falhada, tipo se destruir o "veh", ficar muito tempo fora do Veiculo. etc, tds iram ativar esta função 

function destroyMarker7 ()
	if isTimer ( timerFinal7 ) then killTimer ( timerFinal7 ) end
	if isTimer ( timerBlip7 ) then killTimer ( timerBlip7 )	end
	if isElement ( BcarLocal7 ) then destroyElement ( BcarLocal7 ) end
	if isElement ( Mfim7 ) then destroyElement ( Mfim7 ) end	
	if isElement ( Bfim7 ) then destroyElement ( Bfim7 ) end
end
addEvent ("destroyMarkerAndBlips7", true) 
addEventHandler ("destroyMarkerAndBlips7", getRootElement(), destroyMarker7)

obs: tudo isso esta no lado Client queria a opnião de vocês sobre o que deve ser mudado ou o que esta errado, atualmente não encontrei nenhum erro já testei com outros jogadores.

sobre o erro do "warp" eu não sei como explicar mas so funciona para min, quando outros jogadores tentam usar eles não são teleportados para dentro de veiculo. e um erro esquisito pois ele não aparece no "debugscript 3" ou talvez eu não consiga ver por não acontecer comigo, vcs tem alguma ideia do que seja o script do lado server  esta aki a baixo 

local veh7 = {}
local vehGuincho7 = {}
local timerVeh7 = {}

function inicio7 (  vxGuin7, vyGuin7, vzGuin7, vrotGuin7, vx7, vy7, vz7, vrot7 )
	if client ~= source or not (vrot7) then return end -- cheater detected!
	if isElement (veh7[client]) then 
		destroyElement (veh7[client])
	end
	
	if client ~= source or not (vrotGuin7) then return end -- cheater detected!
	if isElement (vehGuincho7[client]) then 
		destroyElement (vehGuincho7[client])
	end
	
	setElementData( client, "Trabalho7", true, false ) -- seta o jogador no element-data "Trabalho"; sinc com o client desativada
	
	veh7[client] = createVehicle ( 525, vx7, vy7, vz7, 0, 0, vrot7 )
	setElementData( veh7[client], "Owner7", client )
	outputChatBox ("#ffff00Drive the vehicle to the checkpoint. Note: You cannot leave the car during the mission.", client, 0, 0, 0, true)
	warpPedIntoVehicle (client, veh7[client])
	
	vehGuincho7[client] = createVehicle ( 602, vxGuin7, vyGuin7, vzGuin7, 0, 0, vrotGuin7 )
		
	triggerClientEvent (client, "createMakerFim7", client, vehGuincho7, veh7, client, client ) 

end
addEvent ("iniciaJob7", true) 
addEventHandler ("iniciaJob7", getRootElement(), inicio7)

este script funciona assim, quando no Gui Window e seleciono a missão 7 e aperto Start onde vai iniciar a função "inicioJob7"

# onde vair criar os veiculos 

# vai definir o setElementData 

# e vai ativar o #WarpPedIntoVehicle#

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

é Possivel criar um marker que seja visivel apenas para o player da missão Marker arrow  " que fique em cima do veiculo para o jogador saber qual e o seu"

Edited by kevincouto6
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...