diff --git a/src/Components/Modules/Command.cpp b/src/Components/Modules/Command.cpp index 24339b87..3c8c4345 100644 --- a/src/Components/Modules/Command.cpp +++ b/src/Components/Modules/Command.cpp @@ -195,6 +195,51 @@ namespace Components Logger::Print("UFO toggled\n"); Toast::Show("cardicon_abduction", "Success", "UFO toggled", 3000); }); + + Command::Add("setviewpos", [](Command::Params params) + { + int clientNum = Game::CG_GetClientNum(); + if (!Game::CL_IsCgameInitialized() || clientNum >= 18 || clientNum < 0 || !Game::g_entities[clientNum].client) + { + Logger::Print("You are not hosting a match!\n"); + Toast::Show("cardicon_stop", "Error", "You are not hosting a match!", 3000); + return; + } + + if (!Dvar::Var("sv_cheats").get()) + { + Logger::Print("Cheats disabled!\n"); + Toast::Show("cardicon_stop", "Error", "Cheats disabled!", 3000); + return; + } + + if (params.length() < 4 || params.length() > 6) + { + Logger::Print("Invalid coordinate specified!\n"); + Toast::Show("cardicon_stop", "Error", "Invalid coordinate specified!", 3000); + return; + } + + float pos[3]; + float orientation[3]; + + for (unsigned int i = 0; i < (params.length() - 1); i++) + { + if (i < 3) + { + pos[i] = strtof(params[i + 1], NULL); + } + else + { + orientation[i - 3] = strtof(params[i + 1], NULL); + } + } + + Game::TeleportPlayer(&Game::g_entities[clientNum], pos, orientation); + + Logger::Print("Successfully teleported player!\n"); + Toast::Show("cardicon_abduction", "Success", "You have been teleported!", 3000); + }); } Command::~Command() diff --git a/src/Game/Functions.cpp b/src/Game/Functions.cpp index d8c87645..054ee1f3 100644 --- a/src/Game/Functions.cpp +++ b/src/Game/Functions.cpp @@ -225,6 +225,8 @@ namespace Game Sys_ListFiles_t Sys_ListFiles = (Sys_ListFiles_t)0x45A660; Sys_Milliseconds_t Sys_Milliseconds = (Sys_Milliseconds_t)0x42A660; + TeleportPlayer_t TeleportPlayer = (TeleportPlayer_t)0x496850; + UI_AddMenuList_t UI_AddMenuList = (UI_AddMenuList_t)0x4533C0; UI_CheckStringTranslation_t UI_CheckStringTranslation = (UI_CheckStringTranslation_t)0x4FB010; UI_LoadMenus_t UI_LoadMenus = (UI_LoadMenus_t)0x641460; diff --git a/src/Game/Functions.hpp b/src/Game/Functions.hpp index 41e151ed..69fbd054 100644 --- a/src/Game/Functions.hpp +++ b/src/Game/Functions.hpp @@ -518,6 +518,9 @@ namespace Game typedef int(__cdecl * Sys_Milliseconds_t)(); extern Sys_Milliseconds_t Sys_Milliseconds; + typedef void(__cdecl * TeleportPlayer_t)(gentity_t* entity, float* pos, float* orientation); + extern TeleportPlayer_t TeleportPlayer; + typedef bool(__cdecl * Sys_SendPacket_t)(netsrc_t sock, size_t len, const char *format, netadr_t adr); extern Sys_SendPacket_t Sys_SendPacket;