[HELP] Getting the clients screen size?

Hello everyone,

I was hoping it would be a simple process of obtaining the current game windows size, so that I may correctly center my text since I’m assuming that it simply won’t be perfectly centered for everyone, considering 720p, 1080p, 2K, 4K, you know what I mean.

It’s likely I could be missing something fairly obvious, it’s currently 1AM, I can hardly see straight as I’m typing this, and quite frankly I’m new to development for FiveM as a whole.

Regardless, hopefully someone might know where I could go from this and hopefully point me in the right direction, thanks in advance everyone :slight_smile:

I think you’re looking for

local screenW, screenH = GetScreenResolution()

To get text to appear centered you can do something like the following (taken from NativeUI, very basic)

local screenW, screenH = GetScreenResolution()
local height = 1080
local ratio = screenW/screenH
local width = height*ratio

AddTextComponentString( someString )

DrawText( width/2, 100) -- appear 100 pixels from the top (i think) centered in the x
1 Like

You see I was sure that such a function must of existed, however I don’t seem to have it on my available functions… how odd!

This is very much appreciated, thank you :slight_smile:

GetScreenResolution() is hardcoded to return always 1280x720
you need to use GetActiveScreenResolution() it works

can’t get “GetActiveScreenResolution()” to work ,can you help me please ?