Add noclip and ufo commands
This commit is contained in:
parent
c26e197161
commit
f064966ec0
@ -134,7 +134,74 @@ namespace Components
|
||||
|
||||
Command::Command()
|
||||
{
|
||||
// TODO: Add commands here?
|
||||
// Disable native noclip command
|
||||
Utils::Hook::Nop(0x474846, 5);
|
||||
|
||||
Command::Add("noclip", [] (Command::Params params)
|
||||
{
|
||||
if (!Game::CL_IsCgameInitialized())
|
||||
{
|
||||
Logger::Print("No game running!\n");
|
||||
return;
|
||||
}
|
||||
if (!Dvar::Var("sv_cheats").Get<bool>())
|
||||
{
|
||||
Logger::Print("Cheats disabled!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
int clientNum = Game::CG_GetClientNum();
|
||||
if (clientNum >= 18)
|
||||
{
|
||||
Logger::Print("Unable to lookup our clientnum!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
Game::gentity_t* entity = &Game::g_entities[clientNum];
|
||||
|
||||
if (!entity->client)
|
||||
{
|
||||
Logger::Print("Unable to find our client info!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
entity->client->flags ^= Game::PLAYER_FLAG_NOCLIP;
|
||||
|
||||
Logger::Print("Noclip toggled\n");
|
||||
});
|
||||
|
||||
Command::Add("ufo", [] (Command::Params params)
|
||||
{
|
||||
if (!Game::CL_IsCgameInitialized())
|
||||
{
|
||||
Logger::Print("No game running!\n");
|
||||
return;
|
||||
}
|
||||
if (!Dvar::Var("sv_cheats").Get<bool>())
|
||||
{
|
||||
Logger::Print("Cheats disabled!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
int clientNum = Game::CG_GetClientNum();
|
||||
if (clientNum >= 18)
|
||||
{
|
||||
Logger::Print("Unable to lookup our clientnum!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
Game::gentity_t* entity = &Game::g_entities[clientNum];
|
||||
|
||||
if (!entity->client)
|
||||
{
|
||||
Logger::Print("Unable to find our client info!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
entity->client->flags ^= Game::PLAYER_FLAG_UFO;
|
||||
|
||||
Logger::Print("UFO toggled\n");
|
||||
});
|
||||
}
|
||||
|
||||
Command::~Command()
|
||||
|
@ -372,7 +372,6 @@ namespace Components
|
||||
throw new std::exception();
|
||||
});
|
||||
|
||||
|
||||
// Debug patches
|
||||
#ifdef DEBUG
|
||||
// ui_debugMode 1
|
||||
|
@ -8,6 +8,8 @@ namespace Game
|
||||
Cbuf_AddServerText_t Cbuf_AddServerText = (Cbuf_AddServerText_t)0x4BB9B0;
|
||||
Cbuf_AddText_t Cbuf_AddText = (Cbuf_AddText_t)0x404B20;
|
||||
|
||||
CG_GetClientNum_t CG_GetClientNum = (CG_GetClientNum_t)0x433700;
|
||||
|
||||
CL_GetClientName_t CL_GetClientName = (CL_GetClientName_t)0x4563D0;
|
||||
CL_IsCgameInitialized_t CL_IsCgameInitialized = (CL_IsCgameInitialized_t)0x43EB20;
|
||||
CL_ConnectFromParty_t CL_ConnectFromParty = (CL_ConnectFromParty_t)0x433D30;
|
||||
|
@ -9,6 +9,9 @@ namespace Game
|
||||
typedef void(__cdecl * Cbuf_AddText_t)(int localClientNum, const char *text);
|
||||
extern Cbuf_AddText_t Cbuf_AddText;
|
||||
|
||||
typedef int(__cdecl * CG_GetClientNum_t)();
|
||||
extern CG_GetClientNum_t CG_GetClientNum;
|
||||
|
||||
typedef char*(__cdecl * CL_GetClientName_t)(int localClientNum, int index, char *buf, size_t size);
|
||||
extern CL_GetClientName_t CL_GetClientName;
|
||||
|
||||
|
@ -868,11 +868,20 @@ namespace Game
|
||||
int lastEntityRef;
|
||||
} msg_t;
|
||||
|
||||
enum playerFlag
|
||||
{
|
||||
PLAYER_FLAG_NOCLIP = 1,
|
||||
PLAYER_FLAG_UFO = 2,
|
||||
PLAYER_FLAG_FROZEN = 4,
|
||||
};
|
||||
|
||||
typedef struct gclient_s
|
||||
{
|
||||
unsigned char pad[12764];
|
||||
unsigned int team;
|
||||
char pad2[1164];
|
||||
char pad2[436];
|
||||
int flags;
|
||||
char pad3[724];
|
||||
} gclient_t;
|
||||
|
||||
typedef struct gentity_s
|
||||
|
Loading…
Reference in New Issue
Block a user