Jump to content

Need help with GUI


Recommended Posts

Hello ,

I need to edit this GUI so when the player leave the marker in any ways ( Warp , Death or anything ) the GUI will be hidden

This is the code

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

local Marker = createMarker ( 296, -37, 999.5, "cylinder", 2, 255, 255, 0, 150 ) 
setElementInterior( Marker, 1, 296, -37, 999.5 ) 
  
addEventHandler('onClientMarkerHit', Marker, 
function ( hitPlayer ) 
    if ( hitPlayer == localPlayer ) then 
        show() 
        showCursor( true ) 
    end 
end ) 
  
createBlip ( 1367, -1279, 13 , 6 ) 

Link to comment

I tested this but it didn't work :/ sorry I am still new with Lua coding

local Marker = createMarker ( 296, -37, 999.5, "cylinder", 2, 255, 255, 0, 150 ) 
setElementInterior( Marker, 1, 296, -37, 999.5 ) 
  
addEventHandler('onClientMarkerHit', Marker, 
function ( hitPlayer ) 
    if ( hitPlayer == localPlayer ) then 
        show() 
        showCursor( true ) 
    end 
end ) 
  
  
  
  
  
function markerLeave ( leavingPlayer, matchingDimension, Marker, 
    if ( localPlayer ) then 
        hide() 
        showCursor( false ) 
end 
  
addEventHandler ( "onClientMarkerLeave", getRootElement(), markerLeave ) 
  
  
  
  
createBlip ( 1367, -1279, 13 , 6 ) 

Link to comment
  
addEventHandler( "onMarkerLeave", Marker, markerLeave ) 
  

That won't work, and first of all you should of looked at what type of events he was already using, then you would of maybe noticed it was client sided events.

After all,

where did you define "show()" and "hide()"?

Link to comment

i make for you an script when markerhit, to show you a text "PRESS 'F' TO OPEN SHOP"...

  
local Marker = createMarker ( 296, -37, 999.5, "cylinder", 2, 255, 255, 0, 150 ) 
setElementInterior( Marker, 1, 296, -37, 999.5 ) 
function dxText2 ( ) 
    dxDrawText("Press \"F\" for open shop.", 756, 596, 1161, 630, tocolor(0, 0, 0, 255), 1.00, "bankgothic", "center", "center", false, false, true, false, false) 
    dxDrawText("Press \"F\" for open shop.", 756, 594, 1161, 628, tocolor(0, 0, 0, 255), 1.00, "bankgothic", "center", "center", false, false, true, false, false) 
    dxDrawText("Press \"F\" for open shop.", 754, 596, 1159, 630, tocolor(0, 0, 0, 255), 1.00, "bankgothic", "center", "center", false, false, true, false, false) 
    dxDrawText("Press \"F\" for open shop.", 754, 594, 1159, 628, tocolor(0, 0, 0, 255), 1.00, "bankgothic", "center", "center", false, false, true, false, false) 
    dxDrawText("Press \"F\" for open shop.", 755, 595, 1160, 629, tocolor(49, 250, 2, 255), 1.00, "bankgothic", "center", "center", false, false, true, false, false) 
end 
  
addEventHandler ( "onClientMarkerHit", Marker, 
    function ( hitPlayer, matchingDimension ) 
        if hitPlayer == localPlayer then 
        addEventHandler ( "onClientRender", root, dxText2) 
         
        function ss () 
        show() 
        showCursor( true ) 
    end 
    bindKey("f", "down", ss) 
end 
end 
) 
  
addEventHandler ( "onClientMarkerLeave", Marker, 
    function ( leftPlayer, matchingDimension ) 
        removeEventHandler ( "onClientRender", root, dxText2) 
        unbindKey("f", "down", ss) 
    end 
) 

for me work perfectly :D

Link to comment
i make for you an script when markerhit, to show you a text "PRESS 'F' TO OPEN SHOP"...
  
local Marker = createMarker ( 296, -37, 999.5, "cylinder", 2, 255, 255, 0, 150 ) 
setElementInterior( Marker, 1, 296, -37, 999.5 ) 
function dxText2 ( ) 
    dxDrawText("Press \"F\" for open shop.", 756, 596, 1161, 630, tocolor(0, 0, 0, 255), 1.00, "bankgothic", "center", "center", false, false, true, false, false) 
    dxDrawText("Press \"F\" for open shop.", 756, 594, 1161, 628, tocolor(0, 0, 0, 255), 1.00, "bankgothic", "center", "center", false, false, true, false, false) 
    dxDrawText("Press \"F\" for open shop.", 754, 596, 1159, 630, tocolor(0, 0, 0, 255), 1.00, "bankgothic", "center", "center", false, false, true, false, false) 
    dxDrawText("Press \"F\" for open shop.", 754, 594, 1159, 628, tocolor(0, 0, 0, 255), 1.00, "bankgothic", "center", "center", false, false, true, false, false) 
    dxDrawText("Press \"F\" for open shop.", 755, 595, 1160, 629, tocolor(49, 250, 2, 255), 1.00, "bankgothic", "center", "center", false, false, true, false, false) 
end 
  
addEventHandler ( "onClientMarkerHit", Marker, 
    function ( hitPlayer, matchingDimension ) 
        if hitPlayer == localPlayer then 
        addEventHandler ( "onClientRender", root, dxText2) 
         
        function ss () 
        show() 
        showCursor( true ) 
    end 
    bindKey("f", "down", ss) 
end 
end 
) 
  
addEventHandler ( "onClientMarkerLeave", Marker, 
    function ( leftPlayer, matchingDimension ) 
        removeEventHandler ( "onClientRender", root, dxText2) 
        unbindKey("f", "down", ss) 
    end 
) 

for me work perfectly :D

your code works fine and it's a great idea but the problem is that some people can open the gui outside the war room I made so I want the gui be hidden when they leave the marker.

Edit : your code will only hide the text and the bind key but the gui will still be visible for them when they leave the marker using warp or by death

Link to comment

Never mind I fixed it thanks a lot for your help :D

Just one last thing how can I make the text in the center of the screen in all resolutions?

function dxText2 ( ) 
  
    dxDrawText("Press \"F\" for open shop.", 756, 596, 1161, 630, tocolor(0, 0, 0, 255), 1.00, "bankgothic", "center", "center", false, false, true, false, false) 
  
    dxDrawText("Press \"F\" for open shop.", 756, 594, 1161, 628, tocolor(0, 0, 0, 255), 1.00, "bankgothic", "center", "center", false, false, true, false, false) 
  
    dxDrawText("Press \"F\" for open shop.", 754, 596, 1159, 630, tocolor(0, 0, 0, 255), 1.00, "bankgothic", "center", "center", false, false, true, false, false) 
  
    dxDrawText("Press \"F\" for open shop.", 754, 594, 1159, 628, tocolor(0, 0, 0, 255), 1.00, "bankgothic", "center", "center", false, false, true, false, false) 
  
    dxDrawText("Press \"F\" for open shop.", 755, 595, 1160, 629, tocolor(49, 250, 2, 255), 1.00, "bankgothic", "center", "center", false, false, true, false, false) 
  
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...