CTCCoco Posted February 28, 2010 Share Posted February 28, 2010 How I can get the X and Y coordinates to make a text and a GUI in the player window? Please help. Thanks. Link to comment
50p Posted February 28, 2010 Share Posted February 28, 2010 Calculate it? Depends what kind of text you're adding. You can use relative coords which are between 0 and 1 (1 = full width, height, etc), where 0.5 is half length (middle of the screen or parent element). Link to comment
Xeno Posted February 28, 2010 Share Posted February 28, 2010 Im not really sure, but i had seen somthink about a ped haveing a name, maby you could remove the ped and there would be text there? heres the script local rootElement = getRootElement() --define what rootElement is (that's probably your main problem) local NPC = createPed(124,0,0,5) local screenWidth, screenHeight = guiGetScreenSize() --you don't need to get this every frame, it will not change local maxrange = 45 -- the max range the text can be seen (modify to your preferences, i believe normal nametags use 45 too) function NPCnametag() local pedX,pedY,pedZ = getElementPosition(NPC) local sx,sy = getScreenFromWorldPosition (pedX,pedY,pedZ) local cameraX,cameraY,cameraZ = getCameraMatrix() if sx then --this will check if the ped is actually on screen (without this check you would have many errors in your debug log) if getDistanceBetweenPoints3D(cameraX,cameraY,cameraZ,pedX,pedY,pedZ) <= maxrange then --get the distance between two points in the 3d environment and check if it is smaller or the same as our maxrange dxDrawText("Bob",sx,sy,screenWidth, screenHeight,tocolor ( 255, 255, 0, 255 ), 2,"sans") --I'm not sure if the text was supposed to be invisible but I think I'll just change that too end end end function HandleTheRendering() addEventHandler("onClientRender",rootElement, NPCnametag) end addEventHandler("onClientResourceStart",rootElement, HandleTheRendering) I have tried it, try this. dxDrawText("Bob",sx,sy,screenWidth, screenHeight,tocolor ( 255, 255, 0, 255 ), 2,"sans") Link to comment
CTCCoco Posted March 1, 2010 Author Share Posted March 1, 2010 Calculate it? Depends what kind of text you're adding.You can use relative coords which are between 0 and 1 (1 = full width, height, etc), where 0.5 is half length (middle of the screen or parent element). I mean for create a GUI for example a Buy a House GUI or LOGIN GUI. How you get the coordinates? Magic? Thanks for help a noob Link to comment
50p Posted March 1, 2010 Share Posted March 1, 2010 Calculate it? Depends what kind of text you're adding.You can use relative coords which are between 0 and 1 (1 = full width, height, etc), where 0.5 is half length (middle of the screen or parent element). I mean for create a GUI for example a Buy a House GUI or LOGIN GUI. How you get the coordinates? Magic? Thanks for help a noob guiGetScreenSize returns width and height of the screen. You can use it to calculate your positions. I don't know what you have problems with Each pixel on your screen has a position (x, y) and it's your choice where you create your elements. If you want to create something in the top left corner, you use 0, 0 for x and y. If you want to create something at the bottom left of the screen, you use 0 for X and you need to calculate Y, like so: screenWidth, screenHeight = guiGetScreenSize(); -- I usually make a table instead of 2 variables HEIGHT_OF_YOUR_ELEMENT = 100 WIDTH_OF_YOUR_ELEMENT = 100 guiCreateWindow( 0, screenHeight - HEIGHT_OF_YOUR_ELEMENT, WIDTH_OF_YOUR_ELEMENT, HEIGHT_OF_YOUR_ELEMENT, "bottom left", false ); Basically, take away height of your GUI element from the height of the screen. Explain what you don't understand or what pills you have taken. 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