[Command] Implemented setviewpos

This commit is contained in:
/dev/root 2016-11-22 23:25:56 +01:00
parent 3973cf71a7
commit e8a5e164fc
3 changed files with 50 additions and 0 deletions

View File

@ -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<bool>())
{
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()

View File

@ -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;

View File

@ -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;