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
)