Jump to content

Screen PositionX and PositionY?


Recommended Posts

24 minutes ago, Patrick2562 said:

-- only on client side
local screenWidth, screenHeight = guiGetScreenSize()
local centerX, centerY = screenWidth/2, screenHeight/2

 

That's the center of the screen this doesn't mean it's where your aim sight it is, I have tested using GetScreenFromWorldPosition and it seems it's not the same, I shoot at the center of the enemy ped and return it's position with getElementPosition(source) and in hypothetical case that if screen center would be the center of your aim sight wouldn't be the same or very similiar?

addEventHandler("onClientRender", root, function()
	for _, v in pairs(getElementsByType("player")) do
		local x, y, z = getElementPosition(v)
		local okX, okY = getScreenFromWorldPosition(x, y, z)
		if (okX ~= false) and (okY ~= false) then
			dxDrawRectangle(okX - 4, okY - 4, 4, 4)
		end
	end
end)

I have drawn a little rectangle in the center of every player to see where is the exact center and I can conclude that the aim sight position IS NOT the center of the screen.

Edited by Flower ☠ Power
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...