elchoky10 3 Posted December 8, 2019 Share Posted December 8, 2019 (edited) Well i just stude the native trainer and i find on google another solution is this: Vector3 GetGroundCoords(Vector2 coords, int tries) { Vector3 rcor; float groundZ; for (int i = 0; i < tries; ++i) { if (i) { for (float z = 1000.f; z >= 0.f; z -= 100.f) { STREAMING::REQUEST_COLLISION_AT_COORD(coords.x, coords.y, z); wait_for(0); } } if (MISC::GET_GROUND_Z_FOR_3D_COORD(coords.x, coords.y, 1000.f, &groundZ, 0)) { rcor = { coords.x, coords.y, groundZ + 1 }; return rcor; } } rcor = { coords.x, coords.y, 1000.f }; return rcor; } And using here: Vector3 position1 = MAP::_GET_WAYPOINT_COORDS(); Vector2 position2 = {position1.x, position1.y}; const auto ped = PLAYER::PLAYER_PED_ID(); const auto veh = PED::GET_VEHICLE_PED_IS_IN(ped, false); auto inVehicle = PED::IS_PED_IN_ANY_VEHICLE(ped, false) == TRUE; auto coords = GetGroundCoords(position2, 20); if (inVehicle) { Vector3 closestRoad; if (PATHFIND::GET_CLOSEST_ROAD(coords.x, coords.y, coords.z, 1.f, 1, &closestRoad, &closestRoad, 0, 0, 0, 0)) { printf("PATHFIN TRUE"); STREAMING::_SET_FOCUS_AREA(coords.x, coords.y, coords.z, 0.1f, 0.3f, 0.5f); coords = closestRoad; } } ENTITY::SET_ENTITY_COORDS(inVehicle ? veh : ped, coords.x, coords.y, coords.z, 0, 0, 0, 1); } But when i tp i just go to 1000.f seen like request colission and GET_GROUND_Z_FOR_3D_COORD IS NOT WORKIN? I doe some wrong? Edited December 9, 2019 by elchoky10 Quote Link to comment Share on other sites More sharing options...
LMS 674 Posted December 8, 2019 Share Posted December 8, 2019 The problem is that for areas further away, not all pathing data is loaded so you cannot get the ground coordinates. Hence you need to ask the game to load collisions there and loop until it works. Can you tell us which of the three code pieces you are using? You could try using a longer sleep/wait in the loop, perhaps your game needs a bit to load. Quote Link to comment Share on other sites More sharing options...
elchoky10 3 Posted December 9, 2019 Author Share Posted December 9, 2019 (edited) 21 hours ago, LMS said: The problem is that for areas further away, not all pathing data is loaded so you cannot get the ground coordinates. Hence you need to ask the game to load collisions there and loop until it works. Can you tell us which of the three code pieces you are using? You could try using a longer sleep/wait in the loop, perhaps your game needs a bit to load. I fixed the post i use that two codes, i was usin just the set entity coords with the vector of the waypoint, but after i try i always do a tp to z = 0.f so i find on google that function ground detector and read about loading, the map. I need to load so i need to insert into the loop functions? the first code? for example: void loop(){ if(finZ) STREAMING::REQUEST_COLLISION_AT_COORD(coords.x, coords.y, z); if (MISC::GET_GROUND_Z_FOR_3D_COORD(coords.x, coords.y, 1000.f, &groundZ, 0)) { rcor = { coords.x, coords.y, groundZ + 1 }; findZ = false; } } And what i can use to tell to the game, to load that part of map from the coord see roads dont work Edited December 9, 2019 by elchoky10 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.