From 61786f34a379d3330df4683cc28862b25e4277ea Mon Sep 17 00:00:00 2001 From: Grinch_ Date: Mon, 15 Feb 2021 14:49:01 +0600 Subject: [PATCH] Fix a bug with teleporter --- src/Game.cpp | 1 + src/MenuInfo.h | 2 +- src/Teleport.cpp | 13 +++++++------ src/Ui.cpp | 2 +- tests/Test.cpp | 23 +++++++++++++++++++---- 5 files changed, 29 insertions(+), 12 deletions(-) diff --git a/src/Game.cpp b/src/Game.cpp index f527ad3..015bf36 100644 --- a/src/Game.cpp +++ b/src/Game.cpp @@ -207,6 +207,7 @@ void SetPlayerMission(std::string& rootkey, std::string& name, std::string& id) int interior = 0; Command<0x09E8>(hplayer,&interior); + if ( Util::IsOnMission() && interior == 0) { player->SetWantedLevel(0); diff --git a/src/MenuInfo.h b/src/MenuInfo.h index f201110..0b4def0 100644 --- a/src/MenuInfo.h +++ b/src/MenuInfo.h @@ -1,5 +1,5 @@ #pragma once #define MENU_NAME "Cheat Menu" #define MENU_VERSION "2.6-beta" -#define BUILD_NUMBER "20210210" +#define BUILD_NUMBER "20210215" #define MENU_TITLE MENU_NAME " v" MENU_VERSION "(" BUILD_NUMBER ")" \ No newline at end of file diff --git a/src/Teleport.cpp b/src/Teleport.cpp index 84c98e9..5e8dc0a 100644 --- a/src/Teleport.cpp +++ b/src/Teleport.cpp @@ -71,15 +71,16 @@ Teleport::Teleport() CEntity* player_entity = FindPlayerEntity(-1); STeleport::pos.z = CWorld::FindGroundZFor3DCoord(Teleport::STeleport::pos.x, Teleport::STeleport::pos.y, STeleport::pos.z + 100.0f, 0, &player_entity) + 1.0f; + CVehicle *pVeh = player->m_pVehicle; - if (player->m_pVehicle) - player->m_pVehicle->Teleport(STeleport::pos, false); + if (pVeh && player->m_nPedFlags.bInVehicle) + pVeh->Teleport(STeleport::pos, false); else player->Teleport(STeleport::pos, false); STeleport::_bool = false; Command(CPools::GetPedRef(player), false); - Command(); + Command(); TheCamera.Fade(0,1); } @@ -124,8 +125,8 @@ void Teleport::TeleportPlayer(bool get_marker, CVector* pos, short interior_id) CStreaming::LoadScene(&Teleport::STeleport::pos); CStreaming::LoadSceneCollision(&Teleport::STeleport::pos); CStreaming::LoadAllRequestedModels(false); - - if (pVeh) + + if (pVeh && player->m_nPedFlags.bInVehicle) { pVeh->Teleport(CVector(pos->x, pos->y, pos->z), false); @@ -137,7 +138,7 @@ void Teleport::TeleportPlayer(bool get_marker, CVector* pos, short interior_id) pVeh->m_nAreaCode = interior_id; } else - player->Teleport(CVector(pos->x, pos->y, pos->z), false); + player->Teleport(STeleport::pos, false); player->m_nAreaCode = interior_id; Command(interior_id); diff --git a/src/Ui.cpp b/src/Ui.cpp index 961d8c6..0663946 100644 --- a/src/Ui.cpp +++ b/src/Ui.cpp @@ -826,7 +826,7 @@ bool Ui::HotKey(const char* label, HotKeyData& key_data) if (!active) current_hotkey = label; - if (active && (ImGui::IsMouseClicked(ImGuiMouseButton_Left) || ImGui::IsItemClicked(ImGuiMouseButton_Left))) + if (active && (ImGui::IsMouseClicked(ImGuiMouseButton_Left) || ImGui::IsItemClicked(ImGuiMouseButton_Right))) { current_hotkey = ""; state = true; diff --git a/tests/Test.cpp b/tests/Test.cpp index 7e2c68d..d8328d3 100644 --- a/tests/Test.cpp +++ b/tests/Test.cpp @@ -1,16 +1,31 @@ #include "plugin.h" +#include "CHud.h" using namespace plugin; +void DoStuff(); + class Test { public: + Test() { - Events::initGameEvent += [] - { - patch::PutRetn0(0x4B35A4); - }; + Events::processScriptsEvent += DoStuff; + } + ~Test() + { + Events::processScriptsEvent -= DoStuff; } } test; +void DoStuff() +{ + CHud::SetMessage((char*)"Test"); + + if (KeyPressed(VK_TAB)) + { + test.~Test(); + } +} +