Tp to waypoint
This code attempts to improve the tracking of the different heights of the game map, thus avoiding ending up underneath it
I'm kinda confused about this cause is this improved tp to waypoint or its just normal ?? Cause we already have one from the yimmenuv2 tho
Ground-Z investigation has been adjusted
- ground_z = vec.z;
- ground_z = vec.z + 25.f; // start slightly higher
Instead of working directly with vec.z, 25 units are now being started higher. This improves the success rate of teleporting in complex terrain.
Collision request corrected
- STREAMING::REQUEST_COLLISION_AT_COORD (vec.x, vec.y, vec.z);
- STREAMING::REQUEST_COLLISION_AT_COORD (vec.x, vec.y, ground_z);
Use ground_z instead of vec.z now - useful because ground_z was raised before.
Water height + safety limit
- vec.z = water_height;
- vec.z = std:max (water_height, min_safe_z);
Protection against too deep teleportation in the water (e.g. under the map). min_safe_z is, for example, 1.0f.
GET_GROUND_Z_FOR_3D_COORD improved
- GET_GROUND_Z_FOR_3D_COORD (vec.x, vec.y, max_ground_check, ...)
- GET_GROUND_Z_FOR_3D_COORD (vec.x, vec.y, ground_z, ...)
The height ground_z is used instead of a maximum fixed number - better for accuracy.
Fallback improved
- vec.z = GET_APPROX_HEIGHT_FOR_POINT (...)
- vec.z = std:max (GET_APPROX_HEIGHT_FOR_POINT (...), min_safe_z); Here, too, it is ensured that the height does not fall below a safe value.
yea it will be nice to have this since the existing one sometimes tp under the ground and the car gets destroyed and some missions fail. it would be nice also to have tp to objective
Some places might have a ground Z value below 1. Are you sure this doesn't cause you to get teleported in the air?
make tp to object would be usefull fr
make tp to object would be usefull fr
I'm working on a teleportation system for objects, collectibles, and objectives
make tp to object would be usefull fr
I'm working on a teleportation system for objects, collectibles, and objectives
allright
Whats with the foreign comments in the code
Whats with the foreign comments in the code
- They're using a translator to convert all code comments into English and back, or
- They asked a Spanish-speaking AI to make this code change for them
Whats with the foreign comments in the code
- They're using a translator to convert all code comments into English and back, or
- They asked a Spanish-speaking AI to make this code change for them
Neither of those options, my native language is Spanish. I simply left line 17 commented out as a reminder.
Neither of those options, my native language is Spanish. I simply left line 17 commented out as a reminder.
Ah ok, it's just that a lot of people working on this project probably don't understand Spanish and won't be able to read your comments
Some places might have a ground Z value below 1. Are you sure this doesn't cause you to get teleported in the air?
Also, have you tested this yet?
Hello there,
I finally managed to build the DLL including this PR and the latest actual repo. Better than actual TP but still not perfect since it keep continuing teleporting some times under the ground at sea level and tries to go higher when there is actually nothing else.
Sometimes it happens sometime not. Build here and video if you wanna check up what I means when sea level TP and higher than ground
I dont know how you can achieve this but I believe in many FiveM servers or admins menus there was a TP to Waypoint that teleports you to the lowest Z coordinate then keep raising your ped to highers Zs until you can finally stand on it.
This is what I have in mind, but this is in lua which I can more understand than c++
try this code, its one from old legacy menu -
void ResolveZCoordinate(Vector3& vec)
{
constexpr float max_ground_check = 1000.f;
constexpr int max_attempts = 20;
float ground_z = vec.z;
int current_attempts = 0;
+ bool found_ground = false;
do
{
STREAMING::REQUEST_COLLISION_AT_COORD(vec.x, vec.y, vec.z);
- float water_height;
- if (WATER::GET_WATER_HEIGHT(vec.x, vec.y, vec.z, &water_height))
- {
- vec.z = water_height;
- return;
- }
-
if (MISC::GET_GROUND_Z_FOR_3D_COORD(vec.x, vec.y, max_ground_check, &ground_z, false, false))
{
vec.z = ground_z + 1.0f;
+ found_ground = true;
+ break;
}
if (current_attempts % 3 == 0)
{
ground_z += 25.f;
}
++current_attempts;
ScriptMgr::Yield();
} while (current_attempts < max_attempts);
+ float water_height;
+ if (WATER::GET_WATER_HEIGHT(vec.x, vec.y, vec.z, &water_height))
+ {
+ vec.z = water_height;
+ return;
+ }
+ if (!found_ground)
vec.z = PATHFIND::GET_APPROX_HEIGHT_FOR_POINT(vec.x, vec.y); // fallback value
}
try this code, its one from old legacy menu -
void ResolveZCoordinate(Vector3& vec) { constexpr float max_ground_check = 1000.f; constexpr int max_attempts = 20; float ground_z = vec.z; int current_attempts = 0; + bool found_ground = false; do { STREAMING::REQUEST_COLLISION_AT_COORD(vec.x, vec.y, vec.z); - float water_height; - if (WATER::GET_WATER_HEIGHT(vec.x, vec.y, vec.z, &water_height)) - { - vec.z = water_height; - return; - } - if (MISC::GET_GROUND_Z_FOR_3D_COORD(vec.x, vec.y, max_ground_check, &ground_z, false, false)) { vec.z = ground_z + 1.0f; + found_ground = true; + break; } if (current_attempts % 3 == 0) { ground_z += 25.f; } ++current_attempts; ScriptMgr::Yield(); } while (current_attempts < max_attempts); + float water_height; + if (WATER::GET_WATER_HEIGHT(vec.x, vec.y, vec.z, &water_height)) + { + vec.z = water_height; + return; + } + if (!found_ground) vec.z = PATHFIND::GET_APPROX_HEIGHT_FOR_POINT(vec.x, vec.y); // fallback value }
This seems to fix TPing into ground / under ground. Will needs to test more to see I encounter any issue with it.
Here is a implementation i have added to Yimmenu (Legacy) a while back, little bit modified since but, works 99.9% of the time!
bool load_ground_at_3d_coordinates(Vector3& location)
{
constexpr int max_attempts = 20;
float ground_z = location.z;
int current_attempts = 0;
bool found_ground = false;
float water_height;
while(current_attempts < max_attempts)
{
constexpr float max_z = 1000.f;
// Attempt to get ground height at the current coordinates
found_ground = MISC::GET_GROUND_Z_FOR_3D_COORD(location.x, location.y, max_z, &ground_z, false, false);
STREAMING::REQUEST_COLLISION_AT_COORD(location.x, location.y, location.z);
if (found_ground)
break;
// Adjust z-coordinate every 3 attempts
if (current_attempts % 3 == 0)
{
if (location.z < max_z)
{
constexpr float z_increment = 100.f;
location.z += z_increment;
}
else
{
location.z = -200.f;
}
}
++current_attempts;
script::get_current()->yield();
}
if (!found_ground)
{
return false;
}
// Check for water height and adjust z-coordinate accordingly
if (WATER::GET_WATER_HEIGHT(location.x, location.y, location.z, &water_height))
{
location.z = water_height;
}
else
{
location.z = ground_z;
}
return true;
}
EDIT-1:
After testing your code, this is what causing you to be teleported on air
vec.z = std::max(PATHFIND::GET_APPROX_HEIGHT_FOR_POINT(vec.x, vec.y), min_safe_z);
Just use the method i provided, should work well!