Jump to content

math floor problem


ysj4

Recommended Posts

        local wX, wY = getScreenFromWorldPosition(bX, bY, bZ + 0.35)
        local sX, sY = math.floor(wX), math.floor(wY)
bX, bY, bZ its a pedBone position

EUb467g.png

problem its a with wX idk why

 

Edited by ysj4
Link to comment

Hello ysj4,

did you know that if (bX, bY, bZ + 0.35) are outside of your GTA SA game client screen then the getScreenFromWorldPosition function does return false? If you want to know about a more generic way to get a blip position in the camera-orriented direction then take a look at this thread in which I responded last year:

The reason for this issue is very simple: you cannot see any world position on your screen that is outside of your game client window. Thus you should not expect the getScreenFromWorldPosition function to return anything that you cannot see! ?

Link to comment
12 minutes ago, The_GTA said:

Hello ysj4,

did you know that if (bX, bY, bZ + 0.35) are outside of your GTA SA game client screen then the getScreenFromWorldPosition function does return false? If you want to know about a more generic way to get a blip position in the camera-orriented direction then take a look at this thread in which I responded last year:

The reason for this issue is very simple: you cannot see any world position on your screen that is outside of your game client window. Thus you should not expect the getScreenFromWorldPosition function to return anything that you cannot see! ?

yeah but my problem with getScreenFromWorldPosition its for nametags and when my character get teleported far away then i got that problem

Link to comment
30 minutes ago, ysj4 said:

yeah but my problem with getScreenFromWorldPosition its for nametags and when my character get teleported far away then i got that problem

How about you don't draw nametags that are not visible on screen? Since the 3D projection is a frustum which has a bottom plane (far-clip) too far players do not get a screen position either.

Or just use the function I have linked for you. It does not return false in the far-clip case.

HINT: you need to enable OOP in your MTA resource to use the get_screen_coordinates function!

HINT: the get_screen_coordinates function does return relative values; you have to multiply them with the screen dimensions to get pixel values.

Edited by The_GTA
  • Like 1
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...