Jump to content

Creating marker


Recommended Posts

Function's :
createMarker 
isPedInVehicle 
getPedOccupiedVehicle 
setElementFrozen 
setTimer 
guiSetVisible --[[ Show the label--]] or dxDrawText with 'onClientRender' 

Event's :

onClientMarkerHit or Server Side : onMarkerHit or onPlayerMarkerHit

Like this?

[lua]local myMarker = createMarker(-2596.625, 579.358, 15.626, 'cylinder', 2.0, 255, 0, 0, 150)  
  
function MarkerHit( hitElement, matchingDimension ) -- define MarkerHit function for the handler 
    local elementType = getElementType( hitElement ) -- get the hit element's type 
        if isPedInVehicle then 
    if getPedOccupiedVehicle ( thePlayer ) then 
        local playerVehicle = getPlayerOccupiedVehicle ( thePlayer ) 
        local currentFreezeStatus = isElementFrozen ( playerVehicle ) 
        local newFreezeStatus = not currentFreezeStatus 
        setElementFrozen ( playerVehicle, newFreezeStatus ) 
    end 
end 
  
  
     
end 
addEventHandler( "onMarkerHit", myMarker, MarkerHit ) -- attach onMarkerHit event to MarkerHit function 
  
function MarkerHit() 
    setTimer ( function() 
    end, 5000, 1 ) 
end 
  
MarkerHit() 
  
function changeVisibility ( ) 
        guiSetVisible (myWindow, not guiGetVisible ( myWindow ) ) 
end 
  
myWindow = guiCreateWindow ( 0.3, 0.3, 0.5, 0.60, "Test", true ) 
setTimer ( changeVisibility, 5000, 1 ) 

[/lua]

Link to comment

I tested it but it's not working

only the markers shows up but it doesn't do anythings

what did I do wrong?

local myMarker = createMarker( 1791.537, 656.511, 17.626, 'cylinder', 2.0, 255, 0, 0, 150)   
  
  
  
function MarkerHit( hitElement, matchingDimension ) -- define MarkerHit function for the handler 
  
    local elementType = getElementType( hitElement ) -- get the hit element's type 
  
        if isPedInVehicle then 
  
    if getPedOccupiedVehicle ( thePlayer ) then 
  
        local playerVehicle = getPlayerOccupiedVehicle ( thePlayer ) 
  
        local currentFreezeStatus = isElementFrozen ( playerVehicle ) 
  
        local newFreezeStatus = not currentFreezeStatus 
  
        setElementFrozen ( playerVehicle, newFreezeStatus ) 
  
    end 
  
end 
  
  
  
  
  
     
  
end 
  
addEventHandler( "onMarkerHit", myMarker, MarkerHit ) -- attach onMarkerHit event to MarkerHit function 
  
  
  
function MarkerHit() 
  
    setTimer ( function() 
  
    end, 5000, 1 ) 
  
end 
  
  
  
MarkerHit() 
  
  
  
function changeVisibility ( ) 
  
        guiSetVisible (myWindow, not guiGetVisible ( myWindow ) ) 
  
end 
  
  
  
myWindow = guiCreateWindow ( 0.3, 0.3, 0.5, 0.60, "Test", true ) 
  
setTimer ( changeVisibility, 5000, 1 ) 
  

Link to comment
  • Moderators
  
local myMarker = createMarker( 1791.537, 656.511, 17.626, 'cylinder', 2.0, 255, 0, 0, 150)   
  
  
function MarkerHit( hitElement, matchingDimension ) -- define MarkerHit function for the handler 
  
    local elementType = getElementType( hitElement ) -- get the hit element's type 
    if elementType == "player" and isPedInVehicle( hitElement ) then   
        local playerVehicle = getPlayerOccupiedVehicle ( hitElement ) 
  
        local currentFreezeStatus = isElementFrozen ( playerVehicle ) 
  
        local newFreezeStatus = not currentFreezeStatus 
  
        setElementFrozen ( playerVehicle, newFreezeStatus )   
    end 
end 

Link to comment
  
local myMarker = createMarker( 1791.537, 656.511, 17.626, 'cylinder', 2.0, 255, 0, 0, 150)   
  
  
function MarkerHit( hitElement, matchingDimension ) -- define MarkerHit function for the handler 
  
    local elementType = getElementType( hitElement ) -- get the hit element's type 
    if elementType == "player" and isPedInVehicle( hitElement ) then   
        local playerVehicle = getPlayerOccupiedVehicle ( hitElement ) 
  
        local currentFreezeStatus = isElementFrozen ( playerVehicle ) 
  
        local newFreezeStatus = not currentFreezeStatus 
  
        setElementFrozen ( playerVehicle, newFreezeStatus )   
    end 
end 

Even if this works there is no timer in it & no draw text on the screen?

Link to comment
  • Moderators
local myMarker = createMarker( 1791.537, 656.511, 17.626, 'cylinder', 2.0, 255, 0, 0, 150)   
  
addEventHandler("onPlayerMarkerHit",root,  
function ( hitElement, matchingDimension ) -- define MarkerHit function for the handler 
    if isPedInVehicle( hitElement ) then   
        local playerVehicle = getPlayerOccupiedVehicle ( hitElement ) 
  
        local currentFreezeStatus = isElementFrozen ( playerVehicle ) 
  
        local newFreezeStatus = not currentFreezeStatus 
  
        setElementFrozen ( playerVehicle, newFreezeStatus )  
    end 
end) 

Lol I didn't seen you also forgot the event.

Link to comment
local myMarker = createMarker( 1791.537, 656.511, 17.626, 'cylinder', 2.0, 255, 0, 0, 150)   
  
addEventHandler("onPlayerMarkerHit",root,  
function ( hitElement, matchingDimension ) -- define MarkerHit function for the handler 
    if isPedInVehicle( hitElement ) then   
        local playerVehicle = getPlayerOccupiedVehicle ( hitElement ) 
  
        local currentFreezeStatus = isElementFrozen ( playerVehicle ) 
  
        local newFreezeStatus = not currentFreezeStatus 
  
        setElementFrozen ( playerVehicle, newFreezeStatus )  
    end 
end) 

Lol I didn't seen you also forgot the event.

still not working xD

Link to comment
  • Moderators
addEventHandler("onMarkerHit",createMarker( 1791.537, 656.511, 17.626, 'cylinder', 2.0, 255, 0, 0, 150) , 
    function ( hitElement, matchingDimension )   
        if getElementType( hitElement )  == "vehicle" then      
            setElementFrozen ( hitElement, not isElementFrozen ( hitElement ) ) 
        end 
    end) 

Link to comment
addEventHandler("onMarkerHit",createMarker( 1791.537, 656.511, 17.626, 'cylinder', 2.0, 255, 0, 0, 150) , 
    function ( hitElement, matchingDimension )   
        if getElementType( hitElement )  == "vehicle" then      
            setElementFrozen ( hitElement, not isElementFrozen ( hitElement ) ) 
        end 
    end) 

Now it works but how can I make it freeze you for 5 seconds only & drawtext will show in screen?

Link to comment
addEventHandler ( "onMarkerHit", createMarker ( 1791.537, 656.511, 17.626, 'cylinder', 2.0, 255, 0, 0, 150 ) , 
    function ( hitElement, matchingDimension ) 
        if ( getElementType ( hitElement ) == "vehicle" ) then 
            setElementFrozen ( hitElement, true ) 
            setTimer ( setElementFrozen, 5000, 1, hitElement, false ) 
        end 
    end 
) 

That's for the 5 seconds to unfreeze, but for the dxDrawText, you'll have to do that.

Link to comment

Will this works and show the text on screen?

addEventHandler ( "onMarkerHit", createMarker ( 1791.537, 656.511, 17.626, 'cylinder', 2.0, 255, 0, 0, 150 ) , 
  
    function ( hitElement, matchingDimension ) 
  
        if ( getElementType ( hitElement ) == "vehicle" ) then 
         
                    triggerClientEvent ( thePlayer, "hitElement", getRootElement(), "Frozen" ) 
                        else 
        if ( setElementFrozen, false, hitElement, false ) 
                            triggerClientEvent ( thePlayer, "hitElement", getRootElement(), "GO" ) 
                         
  
  
            setElementFrozen ( hitElement, true ) 
  
            setTimer ( setElementFrozen, 5000, 1, hitElement, false ) 
  
        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...