Jump to content

Creating marker


Recommended Posts

I tried this but it's not working can you tell me what is the problem now?

*Client Side

local function drawMessage ()  
  
      local screenWidth, screenHeight = guiGetScreenSize (); 
  
      dxDrawText ("YOU ARE NOW FROZEN", screenWidth - 50, screenHeight); 
  
end; 
  
  
  
addEvent ("onPlayerFrozen", true); 
  
addEvent ("onPlayerUnfrozen", true);  
  
  
  
addEventHandler ("onPlayerFrozen", getRootElement (), 
  
        function ()  
  
              addEventHandler ("onClientRender", getRootElement (), drawMessage); 
  
        end); 
  
  
  
addEventHandler ("onPlayerUnfrozen", getRootElement (), 
  
       function ()  
  
  
             removeEventHandler ("onClientRender", getRootElement (), drawMessage); 
  
       end); 

*Server Side

  
addEventHandler ( "onMarkerHit", createMarker ( 1791.537, 656.511, 17.626, 'cylinder', 2.0, 255, 0, 0, 150 ) , 
  
    function ( hitElement, matchingDimension ) 
  
  
       if getElementType (hitElement) ~= "player" then return; end;  
  
        
  
        if ( getElementType ( hitElement ) == "vehicle" ) then 
  
     
  
            setElementFrozen ( hitElement, true ) 
  
  
            triggerClientEvent (hitElement, "onPlayerFrozen", getRootElement ());  
  
            setTimer (  
  
                  function (thePlayer)  
  
  
                        triggerClientEvent (thePlayer, "onPlayerUnfrozen", getRootElement ()); 
  
  
                        setElementFrozen (thePlayer, false); 
  
                  end, 
  
                  5000, 1, hitElement); 
  
        end 
  
    end 
  
); 

Edit : I used Debugscript 3 to check for errors but there are no errors at all and the marker still not showing so I can test it

Link to comment

-- client side:

function drawMessage ( ) 
    local screenWidth, screenHeight = guiGetScreenSize ( ) 
    dxDrawText ( "YOU ARE NOW FROZEN", screenWidth / 2, screenHeight / 2 ) 
end 
  
addEvent ( "setMessageVisible", true ) 
addEventHandler ( "setMessageVisible", root, 
    function ( state ) 
        removeEventHandler ( "onClientRender", getRootElement (), drawMessage ) 
        if ( state ) then 
            addEventHandler ( "onClientRender", getRootElement (), drawMessage ) 
        end 
    end 
) 

-- server side:

addEventHandler ( "onMarkerHit", createMarker ( 1791.537, 656.511, 17.626, 'cylinder', 2.0, 255, 0, 0, 150 ), 
    function ( hitElement, matchingDimension ) 
        if ( getElementType ( hitElement ) ~= "player" ) then 
            return 
        end 
  
        local vehicle = getPedOccupiedVehicle ( hitElement ) 
        if ( vehicle ) then 
            setElementFrozen ( vehicle, true ) 
            triggerClientEvent ( hitElement, "setMessageVisible", hitElement, true ) 
            setTimer ( 
                function ( thePlayer, vehicle ) 
                    triggerClientEvent ( thePlayer, "setMessageVisible", thePlayer, false ) 
                    setElementFrozen ( vehicle, false ) 
                end 
                ,5000, 1, hitElement, vehicle 
            ) 
        end 
    end 
) 

Link to comment
Well, there's no point on showing a text for unfreezing, but you can edit it if you want.

Ok now I made it and it's working fine but the unfreeze message never disappear?

client side

function drawMessage1 ( ) 
  
    local screenWidth, screenHeight = guiGetScreenSize ( ) 
  
    dxDrawText ( "YOU ARE NOW FROZEN", screenWidth / 2, screenHeight / 2 ) 
  
end 
  
  
  
addEvent ( "text1", true ) 
  
addEventHandler ( "text1", root, 
  
    function ( state ) 
  
        removeEventHandler ( "onClientRender", getRootElement (), drawMessage1 ) 
  
        if ( state ) then 
  
            addEventHandler ( "onClientRender", getRootElement (), drawMessage1 ) 
  
        end 
  
    end 
  
) 
  
  
  
function drawMessage2 ( ) 
  
    local screenWidth, screenHeight = guiGetScreenSize ( ) 
  
    dxDrawText ( "YOU ARE NOW UNFROZEN", screenWidth / 2, screenHeight / 2 ) 
  
end 
  
  
  
addEvent ( "text2", true ) 
  
addEventHandler ( "text2", root, 
  
    function ( state ) 
  
        removeEventHandler ( "onClientRender", getRootElement (), drawMessage2 ) 
  
        if ( state ) then 
  
            addEventHandler ( "onClientRender", getRootElement (), drawMessage2 ) 
  
        end 
  
    end 
  
) 

server side

addEventHandler ( "onMarkerHit", createMarker ( 1791.537, 656.511, 17.626, 'cylinder', 2.0, 255, 0, 0, 150 ), 
  
    function ( hitElement, matchingDimension ) 
  
        if ( getElementType ( hitElement ) ~= "player" ) then 
  
            return 
  
        end 
  
  
  
        local vehicle = getPedOccupiedVehicle ( hitElement ) 
  
        if ( vehicle ) then 
  
            setElementFrozen ( vehicle, true ) 
  
            triggerClientEvent ( hitElement, "text1", hitElement, true ) 
  
            setTimer ( 
  
                function ( thePlayer, vehicle ) 
  
                    triggerClientEvent ( thePlayer, "text1", thePlayer, false ) 
            triggerClientEvent ( hitElement, "text2", hitElement, true ) 
  
                    setElementFrozen ( vehicle, false ) 
  
                end 
  
                ,5000, 1, hitElement, vehicle 
  
            ) 
  
        end 
  
    end 
  
) 

Link to comment

-- client side:

local msg = "" 
  
function drawMessage ( ) 
    local screenWidth, screenHeight = guiGetScreenSize ( ) 
    dxDrawText ( msg, screenWidth / 2, screenHeight / 2 ) 
end 
  
addEvent ( "setMessageVisible", true ) 
addEventHandler ( "setMessageVisible", root, 
    function ( state, msg_ ) 
        removeEventHandler ( "onClientRender", getRootElement (), drawMessage ) 
        if ( state ) then 
            msg = msg_ 
            addEventHandler ( "onClientRender", getRootElement (), drawMessage ) 
        end 
    end 
) 

-- server side:

addEventHandler ( "onMarkerHit", createMarker ( 1791.537, 656.511, 17.626, 'cylinder', 2.0, 255, 0, 0, 150 ), 
    function ( hitElement, matchingDimension ) 
        if ( getElementType ( hitElement ) ~= "player" ) then 
            return 
        end 
  
        local vehicle = getPedOccupiedVehicle ( hitElement ) 
        if ( vehicle ) then 
            setElementFrozen ( vehicle, true ) 
            triggerClientEvent ( hitElement, "setMessageVisible", hitElement, true, "YOU ARE NOW FROZEN" ) 
            setTimer ( 
                function ( thePlayer, vehicle ) 
                    triggerClientEvent ( thePlayer, "setMessageVisible", thePlayer, true, "YOU ARE NOW UNFROZEN" ) 
                    setElementFrozen ( vehicle, false ) 
                    setTimer ( triggerClientEvent, 3000, 1, thePlayer, "setMessageVisible", thePlayer, false ) 
                end 
                ,5000, 1, hitElement, vehicle 
            ) 
        end 
    end 
) 

Link to comment
  • Moderators
dxDrawText ( msg,0, 0, screenWidth, screenHeight, tocolor ( 0, 0, 0, 255 ), 1.02, "pricedown", "center", "center" ) 
  

dxDrawText ( msg,0, 0, screenWidth, screenHeight, tocolor ( 0, 0, 0, 255 ), 1.02, "pricedown", "center", "center" )

The start position of the boundingbox is x=0 y=0

The end position is the max size of your screen: screenWidth, screenHeight

The center is between the start and the 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...