--[[ mapcoords.lua How to determine the map coordinates that are under the screen cursor A learning script by perelect. --]] function mapcoords_init(e) SetGamePlayerStateCameraFov(42.2) -- tested at resolution 1366 x 768 end function mapcoords_main(e) -- Common Camera Variables local Camera_X = GetCameraPositionX(0) local Camera_Z = GetCameraPositionZ(0) local Camera_Y = GetCameraPositionY(0) local Camera_T = GetTerrainHeight( Camera_X , Camera_Z ) local Camera_TD = ( Camera_Y - Camera_T ) -- Screen Cursor distance from the center of the screen if g_MouseX <= 50 then Cursor2D_X = -50 + g_MouseX end if g_MouseX > 50 then Cursor2D_X = -50 + g_MouseX end if g_MouseY <= 50 then Cursor2D_Y = 50 - g_MouseY end if g_MouseY > 50 then Cursor2D_Y = 50 - g_MouseY end -- 3D Cursor local Cursor3D_X = ( Camera_X + (Cursor2D_X*(Camera_TD * ((( GetDeviceWidth ()/2)/1000)/50))) ); -- Map X position under the screen cursor local Cursor3D_Z = ( Camera_Z + (Cursor2D_Y*(Camera_TD * ((( GetDeviceHeight()/2)/1000)/50))) ); -- Map Z position under the screen cursor local Cursor3D_Y = GetTerrainHeight( Cursor3D_X , Cursor3D_Z ); -- Set the camera SetCameraOverride ( 3 ) SetCameraAngle ( 0 , 90 , 0 , 0 ) SetCameraPosition ( 0 , 25000 , 3600 , 25000 ) -- Display values TextColor(10,10,3,"MAP COORDINATES",255,255,255) TextColor(10,13,3,"Cursor3D_X: "..math.floor(Cursor3D_X),255,255,255) TextColor(10,16,3,"Cursor3D_Z: "..math.floor(Cursor3D_Z),255,255,255) TextColor(10,19,3,"Cursor3D_Y: "..math.floor(Cursor3D_Y),255,255,255) TextColor(10,25,3,"SCREEN COORDINATES",255,255,255) TextColor(10,28,3,"Mouse X: "..math.floor(g_MouseX),255,255,255) TextColor(10,31,3,"Mouse Y: "..math.floor(g_MouseY),255,255,255) end