Jump to content

Creating marker


Recommended Posts

Posted
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]

350x20_FFFFFF_FFFFFF_000000_000000.png
Posted

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 ) 
  

350x20_FFFFFF_FFFFFF_000000_000000.png
  • Moderators
Posted
  
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 

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted
  
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?

350x20_FFFFFF_FFFFFF_000000_000000.png
  • Moderators
Posted
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.

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted
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

350x20_FFFFFF_FFFFFF_000000_000000.png
  • Moderators
Posted
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) 

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted
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?

350x20_FFFFFF_FFFFFF_000000_000000.png
  • Moderators
Posted

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

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

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

I'm not going to do that for you aswell.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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 
  
) 

350x20_FFFFFF_FFFFFF_000000_000000.png
Posted

No, it doesn't make any sense.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

-- server side:

triggerClientEvent 

-- client side:

addEvent 
addEventHandler 
dxDrawText 

onClientRender

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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