Jump to content

Why move the dx elements, when guiGetScreenSize is added?


Turbe$Z

Recommended Posts

In 1440x900 resolution, the dx elements they are in the right place, but in 1920x1080 the dx elements move up, and in 1366x768 the dx elements move  down.. Why? how to fix this? the guigetscreensize is added with the correct coordinates.. O.o 

Edited by Turbo777
Link to comment
Just now, Ayush Rathore said:

post your code

i downloaded a fps and ping meter from community, and i want change the position :S 

local ping = getPlayerPing(getLocalPlayer())
local x, y = guiGetScreenSize ( )
local posx2,posy2 = x*0.1,y*0.1

local root = getRootElement()
local player = getLocalPlayer()
local counter = 0
local starttick
local currenttick
addEventHandler("onClientRender",root,
	function()
		if not starttick then
			starttick = getTickCount()
		end
		counter = counter + 1
		currenttick = getTickCount()
		if currenttick - starttick >= 1000 then
			setElementData(player,"FPS",counter)
			counter = 0
			starttick = false
		end
	end
)

function drawStates ()
    addEventHandler ( "onClientRender", root, pingState )
	addEventHandler ( "onClientRender", root, fpsState )
end
addEventHandler ( "onClientResourceStart", resourceRoot, drawStates )

function fpsState()
local ping = getPlayerPing(getLocalPlayer())
	
    posx2= x-55
    posy2= 13

	
    dxDrawText ( getElementData(getLocalPlayer(),"FPS"), posx2-118, posy2+18, x, y, tocolor ( 30, 144, 255, 255 ), 1.0, "default-bold" )
    dxDrawText ( ping.." ms", posx2-23, posy2+18, x, y, tocolor ( 30, 144, 255, 255 ), 1.0, "default-bold" )

	dxDrawText ( "FPS", posx2-120, posy2+33, x, y, tocolor ( 30, 144, 255, 255 ), 0.8, "default-bold" )
	dxDrawText ( "PING", posx2-20, posy2+33, x, y, tocolor ( 30, 144, 255, 255 ), 0.8, "default-bold" )
end

fileDelete("client.lua")

 

Link to comment

where you want your fps and ping

1 minute ago, Turbo777 said:

i downloaded a fps and ping meter from community, and i want change the position :S 


local ping = getPlayerPing(getLocalPlayer())
local x, y = guiGetScreenSize ( )
local posx2,posy2 = x*0.1,y*0.1

local root = getRootElement()
local player = getLocalPlayer()
local counter = 0
local starttick
local currenttick
addEventHandler("onClientRender",root,
	function()
		if not starttick then
			starttick = getTickCount()
		end
		counter = counter + 1
		currenttick = getTickCount()
		if currenttick - starttick >= 1000 then
			setElementData(player,"FPS",counter)
			counter = 0
			starttick = false
		end
	end
)

function drawStates ()
    addEventHandler ( "onClientRender", root, pingState )
	addEventHandler ( "onClientRender", root, fpsState )
end
addEventHandler ( "onClientResourceStart", resourceRoot, drawStates )

function fpsState()
local ping = getPlayerPing(getLocalPlayer())
	
    posx2= x-55
    posy2= 13

	
    dxDrawText ( getElementData(getLocalPlayer(),"FPS"), posx2-118, posy2+18, x, y, tocolor ( 30, 144, 255, 255 ), 1.0, "default-bold" )
    dxDrawText ( ping.." ms", posx2-23, posy2+18, x, y, tocolor ( 30, 144, 255, 255 ), 1.0, "default-bold" )

	dxDrawText ( "FPS", posx2-120, posy2+33, x, y, tocolor ( 30, 144, 255, 255 ), 0.8, "default-bold" )
	dxDrawText ( "PING", posx2-20, posy2+33, x, y, tocolor ( 30, 144, 255, 255 ), 0.8, "default-bold" )
end

fileDelete("client.lua")

 

 

Link to comment

after seeing your code it should be this  

local ping = getPlayerPing(getLocalPlayer())
local x, y = guiGetScreenSize ( )
local posA,posB = x*0.95,y*0.03
local posC,posD = x*0.87,y*0.03


local root = getRootElement()
local player = getLocalPlayer()
local counter = 0
local starttick
local currenttick
addEventHandler("onClientRender",root,
    function()
        if not starttick then
            starttick = getTickCount()
        end
        counter = counter + 1
        currenttick = getTickCount()
        if currenttick - starttick >= 1000 then
            setElementData(player,"FPS",counter)
            counter = 0
            starttick = false
        end
    end
)

function drawStates ()
    addEventHandler ( "onClientRender", root, pingState )
    addEventHandler ( "onClientRender", root, fpsState )
end
addEventHandler ( "onClientResourceStart", resourceRoot, drawStates )

function fpsState()
    local ping = getPlayerPing(getLocalPlayer())
    dxDrawText ( "FPS:"..getElementData(getLocalPlayer(),"FPS"), posA, posB, x, y, tocolor ( 30, 144, 255, 255 ), 1.0, "default-bold" )
    dxDrawText ( "PING:"..ping.." ms", posC, posD, x, y, tocolor ( 30, 144, 255, 255 ), 1.0, "default-bold" )
end

fileDelete("client.lua")

it will fit all res

think sx*0.1 as 1/10 of sx

and sy*0.1 as 1/10 of sy

so sy*0.2 will be 2/10 of sy

 

 

 

for example if sx = 1366 and sy =768 then

sx*0.1 = 136.6

sx*0.2 = (136.6*2)

 

well i am not good at making people understand but few example above can click your brain on how i did it

 

:)

  • Like 1
Link to comment
8 minutes ago, Ayush Rathore said:

after seeing your code it should be this  


local ping = getPlayerPing(getLocalPlayer())local x, y = guiGetScreenSize ( )local posA,posB = x*0.95,y*0.03local posC,posD = x*0.87,y*0.03local root = getRootElement()local player = getLocalPlayer()local counter = 0local startticklocal currenttickaddEventHandler("onClientRender",root,    function()        if not starttick then            starttick = getTickCount()        end        counter = counter + 1        currenttick = getTickCount()        if currenttick - starttick >= 1000 then            setElementData(player,"FPS",counter)            counter = 0            starttick = false        end    end)function drawStates ()    addEventHandler ( "onClientRender", root, pingState )    addEventHandler ( "onClientRender", root, fpsState )endaddEventHandler ( "onClientResourceStart", resourceRoot, drawStates )function fpsState()    local ping = getPlayerPing(getLocalPlayer())    dxDrawText ( "FPS:"..getElementData(getLocalPlayer(),"FPS"), posA, posB, x, y, tocolor ( 30, 144, 255, 255 ), 1.0, "default-bold" )    dxDrawText ( "PING:"..ping.." ms", posC, posD, x, y, tocolor ( 30, 144, 255, 255 ), 1.0, "default-bold" )endfileDelete("client.lua")

it will fit all res

thanks :D

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