Jump to content

guiGetScreenSize


Chaos

Recommended Posts

hi,

i want to make dxdraw on same place in all resolutions

i tried this but won't stay on same place

  
local screenW, screenH = guiGetScreenSize() 
function dxdraw() 
 dxDrawText("EXAMPLE", (screenW - 206) , (screenH - 59) , 1028, 97, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "center", false, false, true, false, false) 
end 
addEventHandler("onClientRender",root,dxdraw) 
  

please can you help me ?

Link to comment

try this :

  
local screenW, screenH = guiGetScreenSize() 
function dxdraw() 
 dxDrawText("EXAMPLE", (screenW - 206) / 2, (screenH - 59) /2.5 , 1028, 97, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "center", false, false, true, false, false) 
end 
addEventHandler("onClientRender",root,dxdraw) 
  

2 = x coordinate

2.5 = y coordinate ,

just change them.

Link to comment

you mean like this ?

local screenW, screenH = guiGetScreenSize()

function dxdraw()

dxDrawText("EXAMPLE", (screenW - 1028) / 2) + 1028, (screenH - 97) / 2.5) + 97 , 1028, 97, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "center", false, false, true, false, false)

end

addEventHandler("onClientRender",root,dxdraw)

Link to comment

No,

try that:

  
  
local screenW, screenH = guiGetScreenSize() 
function dxdraw() 
 dxDrawText("EXAMPLE", (screenW - 206) / 2, (screenH - 59) /2.5 , ((screenW - 1028) / 2.1) + 1028, ((screenH - 97) / 2.5) + 97, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "center", false, false, true, false, false) 
end 
addEventHandler("onClientRender",root,dxdraw) 
  

Link to comment
local screenW, screenH = guiGetScreenSize() 
function dxdraw() 
 dxDrawText("EXAMPLE", (screenW - 206) / 2, (screenH - 59) /2.5 , ((screenW - 1028) / 2.1) + 1028, ((screenH - 97) / 2.5) + 97, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "center", false, false, true, false, false) 
end 
addEventHandler("onClientRender",root,dxdraw) 

Link to comment
function DXtext () 
local sWidth,sHeight = guiGetScreenSize() -- The variables 
dxDrawText("Hello World!",sWidth*0.668, sHeight*0.952, sWidth*0.715, sHeight*0.997,tocolor(0,255,255,175),1.0,"bankgothic","left","top",false,false,false) 
end 
  
addEventHandler ( "onClientRender", getRootElement(), DXtext ) 
  

i tried that example in wiki and still same problem :/

Link to comment

Try the dxDrawText example :

local screenWidth, screenHeight = guiGetScreenSize ( ) -- Get the screen resolution (width and height) 
  
  
function createText ( ) 
    local playerX, playerY, playerZ = getElementPosition ( localPlayer )       -- Get our player's coordinates. 
    local playerZoneName = getZoneName ( playerX, playerY, playerZ )          -- Get name of the zone the player is in. 
  
    -- Draw zone name text's shadow. 
    dxDrawText ( playerZoneName, 44, screenHeight - 41, screenWidth, screenHeight, tocolor ( 0, 0, 0, 255 ), 1.02, "pricedown" ) 
    -- Draw zone name text. 
    dxDrawText ( playerZoneName, 44, screenHeight - 43, screenWidth, screenHeight, tocolor ( 255, 255, 255, 255 ), 1, "pricedown" )  
end 
  
function HandleTheRendering ( ) 
    addEventHandler ( "onClientRender", root, createText ) -- keep the text visible with onClientRender. 
end 
  
addEventHandler ( "onClientResourceStart", resourceRoot, HandleTheRendering ) 

Link to comment
local x,y = guiGetScreenSize() 
local text = "My n*gga, my n*gga..." 
local scale = 2 
local length = dxGetTextWidth(text,scale,"default-bold") 
local height = dxGetFontHeight(scale,"default-bold") 
  
function renderText() 
  dxDrawText(text,x/2-length/2,y/2-height/2,x,y,tocolor(255,255,255,255),scale,"default-bold") -- centered text 
end 
addEventHandler("onClientRender",getRootElement(),renderText) 

EDIT: found a small mistake. Changed it.

Edited by Guest
Link to comment
  
    local x,y = guiGetScreenSize() 
    local text = "Example" 
    local scale = 2 
    local length = dxGetTextWidth(text,scale,"default-bold") 
    local height = dxGetFontHeight(scale,"default-bold") 
      
    function renderText() 
      dxDrawText(text,x/1.05-length/2,y-height/1.20,x,y,tocolor(255,255,255,255),scale,"default-bold") -- centered text 
    end 
    addEventHandler("onClientRender",getRootElement(),renderText) 
  
  

look :/

image.jpg

image.jpg

Link to comment
This:
local screenW, screenH = guiGetScreenSize() 
function dxdraw() 
 dxDrawText("EXAMPLE", 0, 0, screenW, screenH, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "right", false, false, true, false, false) 
end 
addEventHandler("onClientRender",root,dxdraw) 

Useless :/

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...