Code:
if (getKeyPressed(AutoTeleport))
{
Vector3 coordz = ENTITY::GET_ENTITY_COORDS(PLAYER::PLAYER_PED_ID(), true);
//int VehID = VEHICLE::GET_CLOSEST_VEHICLE(coordz.x, coordz.y, coordz.z, 100.0f, 0, 71);
Vehicle ReturnToMe = getClosestVehicleFromPedPos(PLAYER::PLAYER_PED_ID(), 21.03F, 33.03F, FALSE);
//Vector3 CoordsForZeroWaypoint = ENTITY::GET_ENTITY_COORDS(VehID, 1);
Vector3 ReturnedToMesCoordinates = ENTITY::GET_ENTITY_COORDS(ReturnToMe, 1);
Vector3 coords = get_blip_marker();
if (coords.x == 0 && coords.y == 0)
{
cantbemessedwith = false;
AI::SET_PED_WAYPOINT_ROUTE_OFFSET(PLAYER::PLAYER_PED_ID(), ReturnedToMesCoordinates.x, ReturnedToMesCoordinates.y, ReturnedToMesCoordinates.z);
PrintError_Waypoint();
Entity e = PLAYER::PLAYER_PED_ID();
if (PED::IS_PED_IN_ANY_VEHICLE(e, 0))
{
e = PED::GET_VEHICLE_PED_IS_USING(e);
}
//Vector3 CoordsForZeroWaypoint = ENTITY::GET_ENTITY_COORDS(PLAYER::PLAYER_PED_ID(), 1);
//AI::SET_PED_WAYPOINT_ROUTE_OFFSET(e, CoordsForZeroWaypoint.x, CoordsForZeroWaypoint.y, CoordsForZeroWaypoint.z);
//Vector3 CoordsFornoWaypoint = get_blip_marker();
// load needed map region and check height levels for ground existence
Vector3 coords = ENTITY::GET_ENTITY_COORDS(PLAYER::PLAYER_PED_ID(), true);
//AI::SET_PED_WAYPOINT_ROUTE_OFFSET(PLAYER::PLAYER_PED_ID(), CoordsForZeroWaypoint.x, CoordsForZeroWaypoint.y, CoordsForZeroWaypoint.z);
//Vector3 CoordsFornoWaypoint = ENTITY::GET_ENTITY_COORDS(PLAYER::PLAYER_PED_ID(), 1);
bool groundFound3 = false;
static float groundCheckHeight[] =
{ 100.0, 150.0, 50.0, 0.0, 200.0, 250.0, 300.0, 350.0, 400.0, 450.0, 500.0, 550.0, 600.0, 650.0, 700.0, 750.0, 800.0 };
for (int i = 0; i < sizeof(groundCheckHeight) / sizeof(float); i++)
{
ENTITY::SET_ENTITY_COORDS_NO_OFFSET(e, ReturnedToMesCoordinates.x, ReturnedToMesCoordinates.y, groundCheckHeight[i] + -36.3f, 0, 0, 1);
WAIT(100);
PrintFloaty("Scanning grounds coords and fetching height...", Noti + 0.4965, 0.9300, ParadiseTextureR, 0, ParadiseTextureG, 255);
WAIT(50);
if (GAMEPLAY::GET_GROUND_Z_FOR_3D_COORD(ReturnedToMesCoordinates.x, ReturnedToMesCoordinates.y, groundCheckHeight[i], &ReturnedToMesCoordinates.z, 0))
{
groundFound3 = true;
ReturnedToMesCoordinates.z += 3.0;
PrintMText("~p~Note: ~s~Nearest vehicle it is.");
break;
}
}
// if ground not found then set Z in air and give player a parachute
if (!groundFound3)
{
ReturnedToMesCoordinates.z = 1000.0;
WEAPON::GIVE_DELAYED_WEAPON_TO_PED(PLAYER::PLAYER_PED_ID(), $("WEAPON_RAYPISTOL"), 1, 0);
}
return;
}
//do it
Entity c2 = PLAYER::PLAYER_PED_ID();
if (PED::IS_PED_IN_ANY_VEHICLE(c2, 0))
{
c2 = PED::GET_VEHICLE_PED_IS_USING(c2);
}
teleport_to_coords(c2, ReturnedToMeCoordinates);
cantbemessedwith = true;
if (cantbemessedwith) {
// get entity to teleport //// x2
Entity e = PLAYER::PLAYER_PED_ID();
if (PED::IS_PED_IN_ANY_VEHICLE(e, 0))
{
e = PED::GET_VEHICLE_PED_IS_USING(e);
}
// load needed map region and check height levels for ground existence
bool groundFound = false;
static float groundCheckHeight[] =
{ 100.0, 150.0, 50.0, 0.0, 200.0, 250.0, 300.0, 350.0, 400.0, 450.0, 500.0, 550.0, 600.0, 650.0, 700.0, 750.0, 800.0 };
for (int i = 0; i < sizeof(groundCheckHeight) / sizeof(float); i++)
{
ENTITY::SET_ENTITY_COORDS_NO_OFFSET(e, coords.x, coords.y, groundCheckHeight[i], 0, 0, 1);
WAIT(100);
PrintFloaty("Scanning grounds coords and fetching height...", Noti + 0.4965, 0.9300, GAMEPLAY::GET_RANDOM_FLOAT_IN_RANGE(66, 179), 0, GAMEPLAY::GET_RANDOM_FLOAT_IN_RANGE(133, 255), 255);
if (GAMEPLAY::GET_GROUND_Z_FOR_3D_COORD(coords.x, coords.y, groundCheckHeight[i], &coords.z, 0))
{
groundFound = true;
coords.z += 3.0;
break;
}
}
// if ground not found then set Z in air and give player a parachute
if (!groundFound)
{
coords.z = 1000.0;
WEAPON::GIVE_DELAYED_WEAPON_TO_PED(PLAYER::PLAYER_PED_ID(), 0x55FB16F1, 1, 0);
}
//do it
teleport_to_coords(e, coords);
//ptfx
This is a hotkey of course, look over, the other guys post for "Auto Teleporation" when a waypoint is detected if your really want it that way.
And how this is setup, if no waypoint is detected, your teleported to the nearest found vehicle (useful if your under the ground or other things) this doesn't grab with the furthest distance, left for you.
So, take out unneeded code.
And as you can see I was testing different things with being creative, something no one has on this forum it seems.