Administrators Lpsd Posted December 10, 2016 Administrators Share Posted December 10, 2016 (edited) Hi, I'm having a slight problem with "guiCreateWindow", it just doesn't appear at all. Here's my client.lua: x, y = guiGetScreenSize () function createGUI () local guiWidth, guiHeight = 500, 300 local centerX, centerY = (x / 2) - (guiWidth / 2), (y / 2) - (guiHeight / 2) myWindow = guiCreateWindow(centerX, centerY, 500, 300, "Information", true) guiSetVisible(myWindow, true) end addEventHandler( "onClientResourceStart", getRootElement( ), createGUI) and here's my meta.xml <meta> <script src="server.lua" type="server" /> <script src="client.lua" type="client" /> </meta> I can't see a single reason for it not to work, checked in debug and no errors there. I think I'm not fully understanding how the different types of positioning work. Earlier on I used the "centerX, centerY" variables on a "dxDrawImage" element, to position it in the exact center of the screen, and it worked fine. The Wiki explains about the position arguments of the "dxDrawImage" function: posX: the absolute X coordinate of the top left corner of the image posY: the absolute Y coordinate of the top left corner of the image However the explanation for the arguments of positioning on the "guiCreateWindow" function are slightly different: x: A float of the 2D x position of the GUI window on a player's screen. This is affected by the relative argument. y: A float of the 2D y position of the GUI window on a player's screen. This is affected by the relative argument. Maybe that's where I'm going wrong. Thanks for reading, hope I've provided enough info. Edited December 10, 2016 by LopSided_ Link to comment
MR.S3D Posted December 10, 2016 Share Posted December 10, 2016 x, y = guiGetScreenSize () function createGUI () local guiWidth, guiHeight = 500, 300 local centerX, centerY = (x / 2) - (guiWidth / 2), (y / 20) - (guiHeight / 20) myWindow = guiCreateWindow(centerX, centerY, 500, 300, "Information", false) end addEventHandler( "onClientResourceStart", getRootElement( ), createGUI) Link to comment
Administrators Lpsd Posted December 10, 2016 Author Administrators Share Posted December 10, 2016 11 minutes ago, MR.S3D said: x, y = guiGetScreenSize () function createGUI () local guiWidth, guiHeight = 500, 300 local centerX, centerY = (x / 2) - (guiWidth / 2), (y / 20) - (guiHeight / 20) myWindow = guiCreateWindow(centerX, centerY, 500, 300, "Information", false) end addEventHandler( "onClientResourceStart", getRootElement( ), createGUI) Works fine, thanks. So it was just the relative positioning that messed it up? & I'm guessing guiSetVisible isn't needed either. Link to comment
MR.S3D Posted December 10, 2016 Share Posted December 10, 2016 1 minute ago, LopSided_ said: Works fine, thanks. So it was just the relative positioning that messed it up? & I'm guessing guiSetVisible isn't needed either. yes welcome. Link to comment
Administrators Lpsd Posted December 10, 2016 Author Administrators Share Posted December 10, 2016 (edited) 12 minutes ago, MR.S3D said: yes welcome. Quick question. When I'm already at the top-level (gui isn't contained in anything else), what am I positioning relatively to? The screen itself? edit: nevermind, found a whole topic explaining absolute vs relative positioning Edited December 10, 2016 by LopSided_ Link to comment
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