ManeXi Posted April 1, 2017 Posted April 1, 2017 local fontTab = {} function mtrxButton(a, b, c, d, text, fontSize, r, g, b, parent) local button local label if (parent) then button = guiCreateStaticImage(a, b, c, d, ":test_font/button_green.png", false, parent) else button = guiCreateStaticImage(a, b, c, d, ":test_font/button_green.png", false) end label = guiCreateLabel(0, 0, c, d, text, false, button) setMtrxFont(label, fontSize) guiLabelSetColor(label, r, g, b) guiLabelSetHorizontalAlign(label, "center", true) guiLabelSetVerticalAlign(label, "center") addEventHandler("onClientMouseEnter", label, function() guiStaticImageLoadImage(button, ":test_font/button_red.png") end, false) addEventHandler("onClientMouseLeave", label, function() guiStaticImageLoadImage(button, ":test_font/button_green.png") end, false) return button, label end function setMtrxFont(gui, fontSize) for i = 1, #fontTab do if (fontTab[i][1] == fontSize) then guiSetFont(gui, fontTab[i][2]) return end end table.insert(fontTab, {}) fontTab[#fontTab][1] = fontSize fontTab[#fontTab][2] = guiCreateFont(":test_font/main_trans_font.ttf", fontSize) end GUIEditor = { img = {}, window = {}, mtrxButt = {} } GUIEditor.window[1] = guiCreateWindow(194, 111, 391, 237, "", false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.img[1], GUIEditor.mtrxButt[1] = mtrxButton(48, 45, 104, 51, "I'm the button #1", 10, 0, 0, 0, GUIEditor.window[1]) GUIEditor.img[2], GUIEditor.mtrxButt[2] = mtrxButton(200, 107, 144, 60, "I'm the button #2", 11, 0, 0, 0, GUIEditor.window[1]) guiSetVisible(GUIEditor.window[1], false) addCommandHandler("buttest", function() guiSetVisible(GUIEditor.window[1], not guiGetVisible(GUIEditor.window[1])) showCursor(not isCursorShowing()) end) the problem is that when I write the command the main windows is shown (this one: GUIEditor.window[1] = guiCreateWindow(194, 111, 391, 237, "", false)) but for some reason the "custom buttons" doesn't show, it doesn't give any debug error, can anyone find the mistake, please? Interested on a paid 3D modder? My Skype: awdsasda.sdasdaad
NeXuS™ Posted April 1, 2017 Posted April 1, 2017 Did you try creating those images just by guiCreateStaticImage to see if they are created or not? Did I help you? NeXuS™#0001
ManeXi Posted April 1, 2017 Author Posted April 1, 2017 4 minutes ago, NeXuS™ said: Did you try creating those images just by guiCreateStaticImage to see if they are created or not? Good suggestion, yes, I have just do it and they are created. Interested on a paid 3D modder? My Skype: awdsasda.sdasdaad
NeXuS™ Posted April 1, 2017 Posted April 1, 2017 So you might have an error inside your mtrxButton function. I'm gonna run through it, maybe I can see something in there. Did I help you? NeXuS™#0001
NeXuS™ Posted April 1, 2017 Posted April 1, 2017 Found it. local fontTab = {} function mtrxButton(a, b, c, d, text, fontSize, r, g, bc, parent) local button local label if (parent) then outputChatBox(b) button = guiCreateButton(a, b, c, d, text, false, parent) --button = guiCreateStaticImage(a, b, c, d, ":test_font/button_green.png", false, parent) outputChatBox("Created w/ parent") outputChatBox(a .. " " .. b .. " " .. c .. " " .. d) else --button = guiCreateStaticImage(a, b, c, d, ":test_font/button_green.png", false) button = guiCreateButton(a, b, c, d, text, false) outputChatBox("Created wo/ parent") end label = guiCreateLabel(0, 0, c, d, text, false, button) setMtrxFont(label, fontSize) guiLabelSetColor(label, r, g, bc) guiLabelSetHorizontalAlign(label, "center", true) guiLabelSetVerticalAlign(label, "center") addEventHandler("onClientMouseEnter", label, function() guiStaticImageLoadImage(button, ":test_font/button_red.png") end, false) addEventHandler("onClientMouseLeave", label, function() guiStaticImageLoadImage(button, ":test_font/button_green.png") end, false) return button, label end function setMtrxFont(gui, fontSize) for i = 1, #fontTab do if (fontTab[i][1] == fontSize) then guiSetFont(gui, fontTab[i][2]) return end end table.insert(fontTab, {}) fontTab[#fontTab][1] = fontSize fontTab[#fontTab][2] = "default-bold" --fontTab[#fontTab][2] = guiCreateFont("default", fontSize) end GUIEditor = { img = {}, window = {}, mtrxButt = {} } GUIEditor.window[1] = guiCreateWindow(194, 111, 391, 237, "", false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.img[1], GUIEditor.mtrxButt[1] = mtrxButton(48, 45, 104, 51, "I'm the button #1", 10, 0, 0, 0, GUIEditor.window[1]) GUIEditor.img[2], GUIEditor.mtrxButt[2] = mtrxButton(200, 107, 144, 60, "I'm the button #2", 11, 0, 0, 0, GUIEditor.window[1]) guiSetVisible(GUIEditor.window[1], false) local x, y = guiGetPosition(GUIEditor.img[1], false) outputChatBox(x .. " " .. y) addCommandHandler("buttest", function() guiSetVisible(GUIEditor.window[1], not guiGetVisible(GUIEditor.window[1])) showCursor(not isCursorShowing()) end) You had the "b" for the y and "b" for the blue color. Btw, sorry for all that :~ in there, just change your main code by renaming one of the "b"s in your function. 1 Did I help you? NeXuS™#0001
ManeXi Posted April 1, 2017 Author Posted April 1, 2017 Now it's working, thank you alot. Interested on a paid 3D modder? My Skype: awdsasda.sdasdaad
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now