Jump to content

Problema con estructura de función


MBAUser

Recommended Posts

Hola a todos!! Les cuento lo que me esta pasando, quiero crear una función que me permita que a partir de presionar un boton, se active una función de crearse un marker y despues que desaparesca al pisarlo, alguien sabe?

Este es el código que hice:


-----------------------------------------------------
-- Esto seria la parte del panel para que empieze a la función, osea con "BOTON"
-----------------------------------------------------

addEventHandler("onClientGUIClick", guiRoot,    
	function()
		local getGui = guiGetVisible(Ventana2)
		if source == BOTON then	 --Para que se cree el marquer pulsar este boton
			if getGui then 
				guiSetVisible(Ventana2, false)
				showCursor(false) 
				setElementVisibleTo ( Marker1, root, true ) --El voton "Crearia el marker 1"
				end
			end
		end
	end
)   

setElementVisibleTo ( Marker1, root, false )
Marker1 = createMarker(2482.2924804688, 1917.4254150391, 9.768750190735,"cylinder",2,0,218,255) --Supuestamente apareceria cuando lo apretaria


function Inicio ()                                          
	if isElementWithinMarker(source, Marker1)    --Cuando toca sobre el marker desaparesca
			then destroyElement ( Marker1 )       --Se destruye el marker1
		    Marker2 = createMarker(2482.2924804688, 1917.4254150391, 9.768750190735,"cylinder",2,0,218,255) --se crea el marker2
	end
  end
end
addEventHandler( "onMarkerHit", Marker1, Inicio ) 

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

 

Link to comment
addEventHandler("onClientGUIClick", guiRoot,    
	function()
		local getGui = guiGetVisible(Ventana2)
		if source == BOTON then	
			if getGui then 
				guiSetVisible(Ventana2, false)
				showCursor(false) 
                Marker1 = createMarker(2482.2924804688, 1917.4254150391, 9.768750190735,"cylinder",2,0,218,255)
				addEventHandler( "onClientMarkerHit", Marker1, Inicio ) 
				end
			end
		end
	end
)   



function Inicio (element)
  if element == localPlayer then 
     destroyElement ( Marker1 )  
     Marker1 = nil	
	 Marker2 = createMarker(2482.2924804688, 1917.4254150391, 9.768750190735,"cylinder",2,0,218,255)
  end
end

si solo quieres que vea el market el jugador no es necesario un trigger pero si quieres que lo vean todos los jugadores como dice @aka Blue vas a necesitar un trigger

Edited by alex17"
  • Like 1
Link to comment
addEventHandler("onClientGUIClick", guiRoot,    
	function()
		local getGui = guiGetVisible(Ventana2)
		if source == BOTON then	
			if getGui then 
				guiSetVisible(Ventana2, false)
				showCursor(false) 
                Marker1 = createMarker(2482.2924804688, 1917.4254150391, 9.768750190735,"cylinder",2,0,218,255)
				addEventHandler( "onClientMarkerHit", Marker1, Inicio ) 
				end
			end
		end
	end
)   



function Inicio (element)
  if element == localPlayer then  
    if timer then killTimer(timer) timer = nil end
	timer = setTimer(create_marker, 3000, 1)
  end
end

function create_marker()
   destroyElement ( Marker1 ) 
   Marker1 = nil	
   Marker2 = createMarker(2482.2924804688, 1917.4254150391, 9.768750190735,"cylinder",2,0,218,255)
   timer = nil
end
 

 

  • Thanks 1
Link to comment
addEventHandler("onClientGUIClick", guiRoot,    
	function()
		local getGui = guiGetVisible(Ventana2)
		if source == Aboton1 then	
			if getGui then 
				guiSetVisible(Ventana2, false)
				showCursor(false)				
                Marker1 = createMarker(2482.4780273438, 1917.6636962891, 10.768750190735-1,"cylinder",2,255,0,0)
				addEventHandler( "onClientMarkerHit", Marker1, Inicio ) 
				Mk1 = createBlipAttachedTo ( Marker1, 0 )
			end
		end
	end
)

function Inicio (element)
  if element == localPlayer then  
    if timer then killTimer(timer) timer = nil end
    timer = setTimer(create_marker, 3000, 1)
    freezeThisDude ( source, 5000 )
  end
end

function freezeThisDude ( thePlayer, freezeTime )
    toggleAllControls ( thePlayer, false )                        
    setTimer ( toggleAllControls, freezeTime, 1, thePlayer, true )
end

Mepa q esta es la forma de aplicarlo en el Server, pero no en Client, porq no me congela al personaje

Link to comment
10 hours ago, aka Blue said:

Fijate en la wiki. En el lado client solo pones true o false. No tienes que poner toggleAllControls (player, true), pones solo toggleAllControls (false) y ya.

Me la complicaba al pedo, ya me funcionó, gracias!! ¿Hay alguna forma de que se active cuando el vehiculo del usuario sea 0?

?
function L58Inicio1 (element)
  if element == localPlayer then 
    local veh = getPedOccupiedVehicle(player)
	local vx, vy, vz = getVehicleTurnVelocity(veh) 	
	if vx, vy, vz = (0, 0, 0)
    outputChatBox("Cargando pasajeros", 0, 255, 0, false)
    ----------------------------------------------------------------------------------------
    if timer then killTimer(timer) timer = nil end
	toggleAllControls (false)
	timer = setTimer(L54Ip1, 7000, 1)
	end
  end
end
if vx, vy, vz = (0,0,0) Me parece que eso es lo que esta mal hecho para el true o false, ¡Gracias por hacerme buscar mas en la wiki!
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...