Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //copy these functions to your script
- private Vector2 CoordToScreen(Vector3 vect)
- {
- int Screen = 0;
- GTA.Native.Pointer x = new GTA.Native.Pointer(typeof(float));
- GTA.Native.Pointer y = new GTA.Native.Pointer(typeof(float));
- Vector3 xpos = vect;
- GTA.Native.Pointer ViewportId = new GTA.Native.Pointer(typeof(int));
- GTA.Native.Function.Call("GET_GAME_VIEWPORT_ID", ViewportId);
- Screen = ViewportId;
- GTA.Native.Function.Call("GET_VIEWPORT_POSITION_OF_COORD", xpos.X, xpos.Y, xpos.Z, Screen, x, y);
- return new Vector2(x,y);
- }
- private bool isCoordVisibleStopsAfterLoad(Vector3 WorldCoord, float AreaSize = 1f) //stops working after you load a save game
- {
- if(Game.Exists(Game.CurrentCamera))
- {
- return GTA.Native.Function.Call<bool>("CAM_IS_SPHERE_VISIBLE", Game.CurrentCamera, WorldCoord.X, WorldCoord.Y, WorldCoord.Z, AreaSize);
- }
- else{return false;}
- }
- private bool isCoordVisible(Vector3 WorldCoord)
- {
- if (Vector3.Subtract(Vector3.Normalize(Vector3.Subtract(myPed, Game.CurrentCamera.Position)),Game.CurrentCamera.Direction).Length() > 0.6f) return false;
- return true;
- }
- //put this in PerFrameDrawing
- Vector3 WorldPosition = //insert Vector3 you want shown here (eg: Game.LocalPlayer.Character.Position)
- if(isCoordVisible(WorldPosition))
- {
- Vector2 ScreenPosition = CoordToScreen(WorldPosition);
- e.Graphics.DrawRect(ScreenPosition.X, ScreenPosition.Y, 32, 32, System.Drawing.Color.White);
- //or e.Graphics.DrawSprite
- //or e.Graphics.DrawText
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement