mirror of
https://github.com/Mr-X-GTA/YimMenu.git
synced 2024-12-23 04:27:25 +08:00
fix(teleport): code reuse / fix lot of unnecessary logic running for tping our own ped. (#2246)
This commit is contained in:
parent
ad6eaaade7
commit
3323e1c43f
@ -2,6 +2,7 @@
|
||||
#include "core/enums.hpp"
|
||||
#include "gta/enums.hpp"
|
||||
#include "util/entity.hpp"
|
||||
#include "util/teleport.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
@ -15,7 +16,7 @@ namespace big
|
||||
{
|
||||
Vector3 c;
|
||||
entity::raycast(&c);
|
||||
PED::SET_PED_COORDS_KEEP_VEHICLE(self::ped, c.x, c.y, c.z);
|
||||
teleport::to_coords(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,11 @@
|
||||
|
||||
namespace big::teleport
|
||||
{
|
||||
inline void to_coords(const Vector3& location)
|
||||
{
|
||||
PED::SET_PED_COORDS_KEEP_VEHICLE(self::ped, location.x, location.y, location.z + 1.f);
|
||||
}
|
||||
|
||||
inline bool teleport_player_to_coords(player_ptr player, Vector3 coords, Vector3 euler = {0, 0, 0})
|
||||
{
|
||||
Entity ent;
|
||||
@ -20,7 +25,10 @@ namespace big::teleport
|
||||
bool is_local_player = (ent == self::ped || ent == self::veh);
|
||||
|
||||
if (is_local_player)
|
||||
PED::SET_PED_COORDS_KEEP_VEHICLE(ent, coords.x, coords.y, coords.z);
|
||||
{
|
||||
to_coords(coords);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (ENTITY::IS_ENTITY_DEAD(ent, true))
|
||||
{
|
||||
@ -151,11 +159,6 @@ namespace big::teleport
|
||||
return true;
|
||||
}
|
||||
|
||||
inline void to_coords(Vector3 location)
|
||||
{
|
||||
PED::SET_PED_COORDS_KEEP_VEHICLE(self::ped, location.x, location.y, location.z + 1.f);
|
||||
}
|
||||
|
||||
inline bool to_blip(int sprite, int color = -1)
|
||||
{
|
||||
Vector3 location;
|
||||
@ -166,7 +169,7 @@ namespace big::teleport
|
||||
if (sprite == (int)BlipIcons::Waypoint)
|
||||
entity::load_ground_at_3dcoord(location);
|
||||
|
||||
PED::SET_PED_COORDS_KEEP_VEHICLE(self::ped, location.x, location.y, location.z);
|
||||
to_coords(location);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -175,7 +178,7 @@ namespace big::teleport
|
||||
{
|
||||
Vector3 location = ENTITY::GET_ENTITY_COORDS(ent, true);
|
||||
|
||||
PED::SET_PED_COORDS_KEEP_VEHICLE(self::ped, location.x, location.y, location.z);
|
||||
to_coords(location);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -206,7 +209,7 @@ namespace big::teleport
|
||||
return false;
|
||||
}
|
||||
|
||||
PED::SET_PED_COORDS_KEEP_VEHICLE(self::ped, location.x, location.y, location.z);
|
||||
to_coords(location);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ namespace big
|
||||
ImGui::InputFloat3("##Customlocation", new_location);
|
||||
ImGui::SameLine();
|
||||
components::button("Teleport", [] {
|
||||
teleport::teleport_player_to_coords(g_player_service->get_self(), {new_location[0], new_location[1], new_location[2]});
|
||||
teleport::to_coords({new_location[0], new_location[1], new_location[2]});
|
||||
});
|
||||
|
||||
ImGui::Spacing();
|
||||
@ -53,10 +53,10 @@ namespace big
|
||||
|
||||
ImGui::BeginGroup();
|
||||
components::button("Forward", [] {
|
||||
teleport::teleport_player_to_coords(g_player_service->get_self(), ENTITY::GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(self::ped, 0, increment, 0));
|
||||
teleport::to_coords(ENTITY::GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(self::ped, 0, increment, 0));
|
||||
});
|
||||
components::button("Backward", [] {
|
||||
teleport::teleport_player_to_coords(g_player_service->get_self(), ENTITY::GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(self::ped, 0, -increment, 0));
|
||||
teleport::to_coords(ENTITY::GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(self::ped, 0, -increment, 0));
|
||||
});
|
||||
ImGui::EndGroup();
|
||||
|
||||
@ -64,10 +64,10 @@ namespace big
|
||||
|
||||
ImGui::BeginGroup();
|
||||
components::button("Left", [] {
|
||||
teleport::teleport_player_to_coords(g_player_service->get_self(), ENTITY::GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(self::ped, -increment, 0, 0));
|
||||
teleport::to_coords(ENTITY::GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(self::ped, -increment, 0, 0));
|
||||
});
|
||||
components::button("Right", [] {
|
||||
teleport::teleport_player_to_coords(g_player_service->get_self(), ENTITY::GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(self::ped, increment, 0, 0));
|
||||
teleport::to_coords(ENTITY::GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(self::ped, increment, 0, 0));
|
||||
});
|
||||
ImGui::EndGroup();
|
||||
|
||||
@ -75,10 +75,10 @@ namespace big
|
||||
|
||||
ImGui::BeginGroup();
|
||||
components::button("Up", [] {
|
||||
teleport::teleport_player_to_coords(g_player_service->get_self(), ENTITY::GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(self::ped, 0, 0, increment));
|
||||
teleport::to_coords(ENTITY::GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(self::ped, 0, 0, increment));
|
||||
});
|
||||
components::button("Down", [] {
|
||||
teleport::teleport_player_to_coords(g_player_service->get_self(), ENTITY::GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(self::ped, 0, 0, -increment));
|
||||
teleport::to_coords(ENTITY::GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(self::ped, 0, 0, -increment));
|
||||
});
|
||||
ImGui::EndGroup();
|
||||
|
||||
@ -130,10 +130,7 @@ namespace big
|
||||
|
||||
if (components::button("TP_TO_IPL"_T.data()))
|
||||
{
|
||||
PED::SET_PED_COORDS_KEEP_VEHICLE(self::ped,
|
||||
selected_ipl.location.x,
|
||||
selected_ipl.location.y,
|
||||
selected_ipl.location.z);
|
||||
teleport::to_coords(selected_ipl.location);
|
||||
}
|
||||
|
||||
ImGui::Spacing();
|
||||
|
Loading…
Reference in New Issue
Block a user