Log in to reply
 

Can someone tell me what is wrong with this Coding Line



  • Edit 3: i fixed it with: Game.Player.Character.Position = new GTA.Math.Vector3(-1844f, 745f, 133f);



  • @ShadoFax Add

    using GTA.Math;

    up the top to include the name Math namespace, this contains Vector3.



  • @mcal9909 How do i teleport to watpoint ?

    Game.Player.Character.Position



  • Set the player's position to World.GetWaypointPosition()



  • @Jitnaught thx

    i actually founded a real advanced way for this:

                    {
                        Game.Player.Character.IsPositionFrozen = true;
                        Vector3 pos = World.WaypointPosition;
                        pos.Z = 800;
                        pos.Z = World.GetGroundHeight(pos);
                        pos.Z += 20f;
                        List<float> CheckHeights = new List<float>{
                            100.0f, 150.0f, 50.0f, 0.0f, 200.0f, 250.0f, 300.0f, 350.0f, 400.0f,
                            450.0f, 500.0f, 550.0f, 600.0f, 650.0f, 700.0f, 750.0f, 800.0f
                        };
                        for (int i = 0; i < CheckHeights.Count; i++)
                        {
                            Game.Player.Character.Position = pos;
                            Wait(100);
                            OutputArgument output = new OutputArgument();
                            if (Function.Call<bool>(Hash.GET_GROUND_Z_FOR_3D_COORD, pos.X, pos.Y, CheckHeights[i], output))
                            {
                                float z = output.GetResult<float>();
                                if (z != 0) pos.Z = z;
                                break;
                            }
                            else
                            {
                                float z = output.GetResult<float>();
                                if (z != 0) pos.Z = z;
                            }
    
                        }
                        Game.Player.Character.Position = pos;
                        Game.Player.Character.IsPositionFrozen = false;
    
                    }
                    else GTA.UI.Notification.Show("No waypoint found!", true);
                }
    
            };```
    
    Got alot of help from someone


  • I would go for a simpler approach, such as this:

    Vector3 waypointPos = World.WaypointPosition;
    float groundHeight = 0f;
    
    for (int i = 0; i < 20; i++) //try a total of 20 times, which will take around 1 second at max (20 times * 50ms = 1000ms)
    {
    	groundHeight = World.GetGroundHeight(pos);
    	
    	if (groundHeight == 0.0f) waypointPos.Z += 25f; //didn't find ground height, so increase height incrementally until we find the ground height
    	else waypointPos.Z = groundHeight; //found the ground height
    	
    	Game.Player.Character.Position = waypointPos;
    	
    	if (groundHeight != 0.0f) break; //found the ground height, so exit loop
    	
    	Wait(50); //wait before checking the ground height again
    }
    

Log in to reply
 

Looks like your connection to GTA5-Mods.com Forums was lost, please wait while we try to reconnect.