Jump to content

i really dont know what im doing wrong


Toffbrown

Recommended Posts

i used guieditor resource to make my own GUI and but i cant seem to toggle the panel with a commandHandler and bindKey i have just had a mind blanke

function centerWindow(center_window) 
    local screenW,screenH=guiGetScreenSize() 
    local windowW,windowH=guiGetSize(center_window,false) 
    local x,y = (screenW-windowW)/2,(screenH-windowH)/2 
    guiSetPosition(center_window,x,y,false) 
end 
  
  
GUIEditor = { 
    button = {}, 
    staticimage = {} 
} 
  
addEventHandler("onClientResourceStart", resourceRoot, 
    function () 
        sfpay = guiCreateButton(176, 294, 150, 35, "San Fierro Pay And Spray", false) 
        guiSetFont(sfpay, "default-bold-small") 
  
  
        oldg = guiCreateButton(734, 410, 150, 35, "San Fierro Old Garage", false) 
        guiSetFont(oldg, "default-bold-small") 
  
  
        mc = guiCreateButton(554, 470, 150, 35, "mc", false) 
        guiSetFont(mc, "default-bold-small") 
  
  
        trans = guiCreateButton(365, 470, 150, 35, "San Fierro Trans Fender", false) 
        guiSetFont(trans, "default-bold-small") 
  
  
        Bay = guiCreateButton(554, 410, 150, 35, "Bay", false) 
        guiSetFont(Bay, "default-bold-small") 
  
  
        Bridge = guiCreateButton(365, 294, 150, 35, "Bridge", false) 
        guiSetFont(Bridge, "default-bold-small") 
  
  
        Las = guiCreateButton(176, 410, 150, 35, "Johnson House", false) 
        guiSetFont(Las, "default-bold-small") 
  
  
        Airstrip = guiCreateButton(176, 470, 150, 35, "Abanded Airport Garage", false) 
        guiSetFont(Airstrip, "default-bold-small") 
  
  
        eightball = guiCreateButton(176, 351, 150, 35, "Eight Ball Autos", false) 
        guiSetFont(eightball, "default-bold-small") 
  
  
        gfr = guiCreateButton(365, 351, 150, 35, "Michells Repair", false) 
        guiSetFont(gfr, "default-bold-small") 
  
  
        map = guiCreateButton(365, 410, 150, 35, "yolo", false) 
        guiSetFont(map, "default-bold-small") 
  
  
        test1 = guiCreateButton(365, 539, 150, 35, "test1", false) 
        guiSetFont(test1, "default-bold-small") 
  
  
        test2 = guiCreateButton(554, 539, 150, 35, "test2", false) 
        guiSetFont(tes2, "default-bold-small") 
  
  
        sfoldbig = guiCreateButton(176, 539, 150, 35, "San Fierro Old Garage Big", false) 
        guiSetFont(sfoldbig, "default-bold-small") 
  
  
        test3 = guiCreateButton(734, 539, 150, 35, "test3", false) 
        guiSetFont(test3, "default-bold-small") 
  
  
        closepanel = guiCreateButton(734, 462, 144, 62, "Close", false) 
  
  
        GUIEditor.staticimage[1] = guiCreateStaticImage(554, 195, 324, 180, ":dxopen/images/jjlogo.png", false)     
    end 
) 
addCommandHandler("garage", ) 
  
  
addEventHandler("onClientRender", root, 
    function() 
        dxDrawRectangle(156, 184, 732, 501, tocolor(0, 0, 0, 100), false) 
        dxDrawText("JJ's garage Panel", 237, 227, 642, 361, tocolor(0, 0, 0, 255), 1.20, "pricedown", "left", "top", false, false, false, false, false) 
        dxDrawText("JJ's garage Panel", 232, 227, 515, 294, tocolor(255, 255, 0, 170), 1.20, "pricedown", "left", "top", false, false, false, false, false) 
        dxDrawText("Made By ToffBrown", 365, 619, 684, 660, tocolor(29, 238, 39, 139), 1.00, "bankgothic", "left", "top", false, false, true, false, false) 
    end 
)    
addEventHandler("onClientRender",root,dxWindow) 
  
  
  
  
  
  
addEventHandler ( "onClientGUIClick", getResourceRootElement(getThisResource()), 
        function ( ) 
            if (source == sfpay) then 
           triggerServerEvent("switchsf1", getRootElement()) 
            
            end 
         end 
) 
  
addEventHandler ( "onClientGUIClick", getResourceRootElement(getThisResource()), 
        function ( ) 
            if (source == trans) then 
           triggerServerEvent("switchsf2", getRootElement()) 
            
            end 
         end 
) 
  
addEventHandler ( "onClientGUIClick", getResourceRootElement(getThisResource()), 
        function ( ) 
            if (source == oldg) then 
           triggerServerEvent("oldgarage1", getRootElement()) 
            
            end 
         end 
) 

Link to comment

Try this, although I haven't tested it.

function centerWindow(center_window) 
    local screenW,screenH=guiGetScreenSize() 
    local windowW,windowH=guiGetSize(center_window,false) 
    local x,y = (screenW-windowW)/2,(screenH-windowH)/2 
    guiSetPosition(center_window,x,y,false) 
end 
  
  
GUIEditor = { 
    button = {}, 
    staticimage = {} 
} 
  
function createGUI ( ) 
    if ( isElement ( sfpay ) ) then 
        destroyElement ( sfpay ) 
    else 
        sfpay = guiCreateButton(176, 294, 150, 35, "San Fierro Pay And Spray", false) 
        guiSetFont(sfpay, "default-bold-small") 
    end 
  
    if ( isElement ( oldg ) ) then 
        destroyElement ( oldg ) 
    else 
        oldg = guiCreateButton(734, 410, 150, 35, "San Fierro Old Garage", false) 
        guiSetFont(oldg, "default-bold-small") 
    end 
  
    if ( isElement ( mc ) ) then 
        destroyElement ( mc ) 
    else 
        mc = guiCreateButton(554, 470, 150, 35, "mc", false) 
        guiSetFont(mc, "default-bold-small") 
    end 
      
    if ( isElement ( trans ) ) then 
        destroyElement ( trans ) 
    else 
        trans = guiCreateButton(365, 470, 150, 35, "San Fierro Trans Fender", false) 
        guiSetFont(trans, "default-bold-small") 
    end 
  
    if ( isElement ( Bay ) ) then 
        destroyElement ( Bay ) 
    else 
        Bay = guiCreateButton(554, 410, 150, 35, "Bay", false) 
        guiSetFont(Bay, "default-bold-small") 
    end 
  
    if ( isElement ( Bridge ) ) then 
        destroyElement ( Bridge ) 
    else 
        Bridge = guiCreateButton(365, 294, 150, 35, "Bridge", false) 
        guiSetFont(Bridge, "default-bold-small") 
    end 
  
    if ( isElement ( Las ) ) then 
        destroyElement ( Las ) 
    else 
        Las = guiCreateButton(176, 410, 150, 35, "Johnson House", false) 
        guiSetFont(Las, "default-bold-small") 
    end 
  
    if ( isElement ( Airstrip ) ) then 
        destroyElement ( Airstrip ) 
    else 
        Airstrip = guiCreateButton(176, 470, 150, 35, "Abanded Airport Garage", false) 
        guiSetFont(Airstrip, "default-bold-small") 
    end 
  
    if ( isElement ( eightball ) ) then 
        destroyElement ( eightball ) 
    else 
        eightball = guiCreateButton(176, 351, 150, 35, "Eight Ball Autos", false) 
        guiSetFont(eightball, "default-bold-small") 
    end 
  
    if ( isElement ( gfr )  ) then 
        destroyElement ( gfr ) 
    else 
        gfr = guiCreateButton(365, 351, 150, 35, "Michells Repair", false) 
        guiSetFont(gfr, "default-bold-small") 
    end 
  
    if ( isElement ( map ) ) then 
        destroyElement ( map ) 
    else 
        map = guiCreateButton(365, 410, 150, 35, "yolo", false) 
        guiSetFont(map, "default-bold-small") 
    end 
  
    if ( isElement ( test1 ) ) then 
        destroyElement ( test1 ) 
    else 
        test1 = guiCreateButton(365, 539, 150, 35, "test1", false) 
        guiSetFont(test1, "default-bold-small") 
    end 
  
    if ( isElement ( test2 ) ) then 
        destroyElement ( test2 ) 
    else 
        test2 = guiCreateButton(554, 539, 150, 35, "test2", false) 
        guiSetFont(tes2, "default-bold-small") 
    end 
  
    if ( isElement ( sfoldbig ) ) then 
        destroyElement ( sfoldbig ) 
    else 
        sfoldbig = guiCreateButton(176, 539, 150, 35, "San Fierro Old Garage Big", false) 
        guiSetFont(sfoldbig, "default-bold-small") 
    end 
  
    if ( isElement ( test3 ) ) then 
        destroyElement( test3 ) 
    else 
        test3 = guiCreateButton(734, 539, 150, 35, "test3", false) 
        guiSetFont(test3, "default-bold-small") 
    end 
  
    if ( isElement ( closepanel ) ) then 
        destroyElement ( closepanel ) 
    else 
        closepanel = guiCreateButton(734, 462, 144, 62, "Close", false) 
    end 
  
    if ( isElement ( GUIEditor.staticimage[1] ) ) then 
        destroyElement ( GUIEditor.staticimage[1] )  
    else 
        GUIEditor.staticimage[1] = guiCreateStaticImage(554, 195, 324, 180, ":dxopen/images/jjlogo.png", false) 
    end 
end 
addCommandHandler("garage", createGUI ) 
  
  
addEventHandler("onClientRender", root, 
    function() 
        dxDrawRectangle(156, 184, 732, 501, tocolor(0, 0, 0, 100), false) 
        dxDrawText("JJ's garage Panel", 237, 227, 642, 361, tocolor(0, 0, 0, 255), 1.20, "pricedown", "left", "top", false, false, false, false, false) 
        dxDrawText("JJ's garage Panel", 232, 227, 515, 294, tocolor(255, 255, 0, 170), 1.20, "pricedown", "left", "top", false, false, false, false, false) 
        dxDrawText("Made By ToffBrown", 365, 619, 684, 660, tocolor(29, 238, 39, 139), 1.00, "bankgothic", "left", "top", false, false, true, false, false) 
    end 
)    
addEventHandler("onClientRender",root,dxWindow) 
  
  
  
  
  
  
addEventHandler ( "onClientGUIClick", getResourceRootElement(getThisResource()), 
        function ( ) 
            if (source == sfpay) then 
           triggerServerEvent("switchsf1", getRootElement()) 
            
            end 
         end 
) 
  
addEventHandler ( "onClientGUIClick", getResourceRootElement(getThisResource()), 
        function ( ) 
            if (source == trans) then 
           triggerServerEvent("switchsf2", getRootElement()) 
            
            end 
         end 
) 
  
addEventHandler ( "onClientGUIClick", getResourceRootElement(getThisResource()), 
        function ( ) 
            if (source == oldg) then 
           triggerServerEvent("oldgarage1", getRootElement()) 
            
            end 
         end 
) 

Link to comment
if ( isElement ( dxDrawRectangle ) ) then 
        destroyElement ( dxDrawRectangle ) 
     
    else 
        dxDrawRectangle(156, 184, 732, 501, tocolor(0, 0, 0, 100), false) 
    end 
     
    if ( isElement ( dxDrawText ) ) then 
        destroyElement ( dxDrawText ) 
     
    else 
        dxDrawText("JJ's garage Panel", 237, 227, 642, 361, tocolor(0, 0, 0, 255), 1.20, "pricedown", "left", "top", false, false, false, false, false) 
    end 
     
    if ( isElement ( dxDrawText ) ) then 
        destroyElement ( dxDrawText ) 
     
    else 
        dxDrawText("JJ's garage Panel", 232, 227, 515, 294, tocolor(255, 255, 0, 170), 1.20, "pricedown", "left", "top", false, false, false, false, false) 
    end 
     
    if ( isElement ( dxDrawText ) ) then 
        destroyElement ( dxDrawText ) 
     
    else 
        dxDrawText("Made By ToffBrown", 365, 619, 684, 660, tocolor(29, 238, 39, 139), 1.00, "bankgothic", "left", "top", false, false, true, false, false) 
    end 
end 
addCommandHandler("garage", createGUI ) 
addEventHandler("onClientRender",root,dxDrawRectangle) 

i added this to what you wrote it works but their is no dxtext and dxgui/rectangle

Link to comment

I have absolutely no idea what you are doing. Why are you checking if it's an element? And why are you trying to destroy it?

DX Drawings do not create any elements except for a select few functions such as dxCreateRenderTarget.

You need to use either onClientRender or onClientPreRender to draw DX Drawings as they are only drawn for one frame. For example,

Toggle Command; (Client-Side)

local isDrawing = false 
  
function exampleCommand() 
    if(isDrawing == false) then 
        addEventHandler("onClientRender", getRootElement(), stuffToBeDrawn) 
        isDrawing = true 
    else 
        removeEventHandler("onClientRender", getRootElement(), stuffToBeDrawn) 
        isDrawing = false 
    end 
end 
addCommandHandler("draw", exampleCommand, false, false) 
  
function stuffToBeDrawn() 
    dxDrawText("JJ's garage Panel", 237, 227, 642, 361, tocolor(0, 0, 0, 255), 1.20, "pricedown", "left", "top", false, false, false, 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...