Merge pull request #290 from diamante0018/disablechat
[Chat] add dvar to disable chat
This commit is contained in:
commit
0f8e727a73
@ -173,8 +173,8 @@ namespace Components
|
|||||||
list.append(Utils::String::VA("\\%s\\%s", std::to_string(i).c_str(), playerTitle));
|
list.append(Utils::String::VA("\\%s\\%s", std::to_string(i).c_str(), playerTitle));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string command = Utils::String::VA("%c customTitles \"%s\"", 21, list.data());
|
const auto* command = Utils::String::VA("%c customTitles \"%s\"", 21, list.data());
|
||||||
Game::SV_GameSendServerCommand(-1, 0, command.data());
|
Game::SV_GameSendServerCommand(-1, Game::SV_CMD_CAN_IGNORE, command);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CardTitles::ParseCustomTitles(const char* msg)
|
void CardTitles::ParseCustomTitles(const char* msg)
|
||||||
|
@ -2,8 +2,10 @@
|
|||||||
|
|
||||||
namespace Components
|
namespace Components
|
||||||
{
|
{
|
||||||
Game::dvar_t** Chat::cg_chatHeight = reinterpret_cast<Game::dvar_t**>(0x7ED398);
|
|
||||||
Dvar::Var Chat::cg_chatWidth;
|
Dvar::Var Chat::cg_chatWidth;
|
||||||
|
Dvar::Var Chat::sv_disableChat;
|
||||||
|
|
||||||
|
Game::dvar_t** Chat::cg_chatHeight = reinterpret_cast<Game::dvar_t**>(0x7ED398);
|
||||||
Game::dvar_t** Chat::cg_chatTime = reinterpret_cast<Game::dvar_t**>(0x9F5DE8);
|
Game::dvar_t** Chat::cg_chatTime = reinterpret_cast<Game::dvar_t**>(0x9F5DE8);
|
||||||
|
|
||||||
bool Chat::SendChat;
|
bool Chat::SendChat;
|
||||||
@ -27,7 +29,7 @@ namespace Components
|
|||||||
{
|
{
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
Chat::SendChat = false;
|
Chat::SendChat = false;
|
||||||
Game::SV_GameSendServerCommand(player->s.number, 0,
|
Game::SV_GameSendServerCommand(player->s.number, Game::SV_CMD_CAN_IGNORE,
|
||||||
Utils::String::VA("%c \"You are muted\"", 0x65));
|
Utils::String::VA("%c \"You are muted\"", 0x65));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,6 +39,13 @@ namespace Components
|
|||||||
lock.unlock();
|
lock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Chat::sv_disableChat.get<bool>())
|
||||||
|
{
|
||||||
|
Chat::SendChat = false;
|
||||||
|
Game::SV_GameSendServerCommand(player->s.number, Game::SV_CMD_CAN_IGNORE,
|
||||||
|
Utils::String::VA("%c \"Chat is disabled\"", 0x65));
|
||||||
|
}
|
||||||
|
|
||||||
TextRenderer::StripMaterialTextIcons(text, text, strlen(text) + 1);
|
TextRenderer::StripMaterialTextIcons(text, text, strlen(text) + 1);
|
||||||
|
|
||||||
Game::Scr_AddEntity(player);
|
Game::Scr_AddEntity(player);
|
||||||
@ -223,14 +232,14 @@ namespace Components
|
|||||||
lock.unlock();
|
lock.unlock();
|
||||||
|
|
||||||
Logger::Print("%s was muted\n", client->name);
|
Logger::Print("%s was muted\n", client->name);
|
||||||
Game::SV_GameSendServerCommand(client->gentity->s.number, 0,
|
Game::SV_GameSendServerCommand(client->gentity->s.number, Game::SV_CMD_CAN_IGNORE,
|
||||||
Utils::String::VA("%c \"You were muted\"", 0x65));
|
Utils::String::VA("%c \"You were muted\"", 0x65));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
Logger::Print("%s is already muted\n", client->name);
|
Logger::Print("%s is already muted\n", client->name);
|
||||||
Game::SV_GameSendServerCommand(-1, 0,
|
Game::SV_GameSendServerCommand(-1, Game::SV_CMD_CAN_IGNORE,
|
||||||
Utils::String::VA("%c \"%s is already muted\"", 0x65, client->name));
|
Utils::String::VA("%c \"%s is already muted\"", 0x65, client->name));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,7 +248,7 @@ namespace Components
|
|||||||
Chat::UnmuteInternal(client->steamID);
|
Chat::UnmuteInternal(client->steamID);
|
||||||
|
|
||||||
Logger::Print("%s was unmuted\n", client->name);
|
Logger::Print("%s was unmuted\n", client->name);
|
||||||
Game::SV_GameSendServerCommand(client->gentity->s.number, 0,
|
Game::SV_GameSendServerCommand(client->gentity->s.number, Game::SV_CMD_CAN_IGNORE,
|
||||||
Utils::String::VA("%c \"You were unmuted\"", 0x65));
|
Utils::String::VA("%c \"You were unmuted\"", 0x65));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -317,7 +326,11 @@ namespace Components
|
|||||||
{
|
{
|
||||||
Dvar::OnInit([]
|
Dvar::OnInit([]
|
||||||
{
|
{
|
||||||
cg_chatWidth = Dvar::Register<int>("cg_chatWidth", 52, 1, std::numeric_limits<int>::max(), Game::DVAR_ARCHIVE, "The normalized maximum width of a chat message");
|
Chat::cg_chatWidth = Dvar::Register<int>("cg_chatWidth", 52, 1,
|
||||||
|
std::numeric_limits<int>::max(), Game::dvar_flag::DVAR_ARCHIVE, "The normalized maximum width of a chat message");
|
||||||
|
Chat::sv_disableChat = Dvar::Register<bool>("sv_disableChat", false,
|
||||||
|
Game::dvar_flag::DVAR_NONE, "Disable chat messages from clients");
|
||||||
|
|
||||||
Chat::AddChatCommands();
|
Chat::AddChatCommands();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -9,8 +9,11 @@ namespace Components
|
|||||||
Chat();
|
Chat();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static Game::dvar_t** cg_chatHeight;
|
|
||||||
static Dvar::Var cg_chatWidth;
|
static Dvar::Var cg_chatWidth;
|
||||||
|
static Dvar::Var sv_disableChat;
|
||||||
|
|
||||||
|
// Game dvars
|
||||||
|
static Game::dvar_t** cg_chatHeight;
|
||||||
static Game::dvar_t** cg_chatTime;
|
static Game::dvar_t** cg_chatTime;
|
||||||
|
|
||||||
static bool SendChat;
|
static bool SendChat;
|
||||||
|
@ -32,7 +32,7 @@ namespace Components
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string command = Utils::String::VA("%c clantags \"%s\"", 22, list.data());
|
std::string command = Utils::String::VA("%c clantags \"%s\"", 22, list.data());
|
||||||
Game::SV_GameSendServerCommand(-1, 0, command.data());
|
Game::SV_GameSendServerCommand(-1, Game::SV_CMD_CAN_IGNORE, command.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* ClanTags::GetUserClantag(std::uint32_t /*clientnum*/, const char* playername)
|
const char* ClanTags::GetUserClantag(std::uint32_t /*clientnum*/, const char* playername)
|
||||||
|
@ -11,14 +11,14 @@ namespace Components
|
|||||||
if (!Dvar::Var("sv_cheats").get<bool>())
|
if (!Dvar::Var("sv_cheats").get<bool>())
|
||||||
{
|
{
|
||||||
Logger::Print("CheatsOk: cheats are disabled!\n");
|
Logger::Print("CheatsOk: cheats are disabled!\n");
|
||||||
Game::SV_GameSendServerCommand(entNum, 0, Utils::String::VA("%c \"GAME_CHEATSNOTENABLED\"", 0x65));
|
Game::SV_GameSendServerCommand(entNum, Game::SV_CMD_CAN_IGNORE, Utils::String::VA("%c \"GAME_CHEATSNOTENABLED\"", 0x65));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ent->health < 1)
|
if (ent->health < 1)
|
||||||
{
|
{
|
||||||
Logger::Print("CheatsOk: entity %i must be alive to use this command!\n", entNum);
|
Logger::Print("CheatsOk: entity %i must be alive to use this command!\n", entNum);
|
||||||
Game::SV_GameSendServerCommand(entNum, 0, Utils::String::VA("%c \"GAME_MUSTBEALIVECOMMAND\"", 0x65));
|
Game::SV_GameSendServerCommand(entNum, Game::SV_CMD_CAN_IGNORE, Utils::String::VA("%c \"GAME_MUSTBEALIVECOMMAND\"", 0x65));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ namespace Components
|
|||||||
const auto entNum = ent->s.number;
|
const auto entNum = ent->s.number;
|
||||||
Logger::Print("Noclip toggled for entity %i\n", entNum);
|
Logger::Print("Noclip toggled for entity %i\n", entNum);
|
||||||
|
|
||||||
Game::SV_GameSendServerCommand(entNum, 0, Utils::String::VA("%c \"%s\"", 0x65,
|
Game::SV_GameSendServerCommand(entNum, Game::SV_CMD_CAN_IGNORE, Utils::String::VA("%c \"%s\"", 0x65,
|
||||||
(ent->client->flags & Game::PLAYER_FLAG_NOCLIP) ? "GAME_NOCLIPON" : "GAME_NOCLIPOFF"));
|
(ent->client->flags & Game::PLAYER_FLAG_NOCLIP) ? "GAME_NOCLIPON" : "GAME_NOCLIPOFF"));
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ namespace Components
|
|||||||
const auto entNum = ent->s.number;
|
const auto entNum = ent->s.number;
|
||||||
Logger::Print("UFO toggled for entity %i\n", entNum);
|
Logger::Print("UFO toggled for entity %i\n", entNum);
|
||||||
|
|
||||||
Game::SV_GameSendServerCommand(entNum, 0, Utils::String::VA("%c \"%s\"", 0x65,
|
Game::SV_GameSendServerCommand(entNum, Game::SV_CMD_CAN_IGNORE, Utils::String::VA("%c \"%s\"", 0x65,
|
||||||
(ent->client->flags & Game::PLAYER_FLAG_UFO) ? "GAME_UFOON" : "GAME_UFOOFF"));
|
(ent->client->flags & Game::PLAYER_FLAG_UFO) ? "GAME_UFOON" : "GAME_UFOOFF"));
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -94,7 +94,7 @@ namespace Components
|
|||||||
const auto entNum = ent->s.number;
|
const auto entNum = ent->s.number;
|
||||||
Logger::Print("God toggled for entity %i\n", entNum);
|
Logger::Print("God toggled for entity %i\n", entNum);
|
||||||
|
|
||||||
Game::SV_GameSendServerCommand(entNum, 0, Utils::String::VA("%c \"%s\"", 0x65,
|
Game::SV_GameSendServerCommand(entNum, Game::SV_CMD_CAN_IGNORE, Utils::String::VA("%c \"%s\"", 0x65,
|
||||||
(ent->flags & Game::FL_GODMODE) ? "GAME_GODMODE_ON" : "GAME_GODMODE_OFF"));
|
(ent->flags & Game::FL_GODMODE) ? "GAME_GODMODE_ON" : "GAME_GODMODE_OFF"));
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -108,7 +108,7 @@ namespace Components
|
|||||||
const auto entNum = ent->s.number;
|
const auto entNum = ent->s.number;
|
||||||
Logger::Print("Demigod toggled for entity %i\n", entNum);
|
Logger::Print("Demigod toggled for entity %i\n", entNum);
|
||||||
|
|
||||||
Game::SV_GameSendServerCommand(entNum, 0, Utils::String::VA("%c \"%s\"", 0x65,
|
Game::SV_GameSendServerCommand(entNum, Game::SV_CMD_CAN_IGNORE, Utils::String::VA("%c \"%s\"", 0x65,
|
||||||
(ent->flags & Game::FL_DEMI_GODMODE) ? "GAME_DEMI_GODMODE_ON" : "GAME_DEMI_GODMODE_OFF"));
|
(ent->flags & Game::FL_DEMI_GODMODE) ? "GAME_DEMI_GODMODE_ON" : "GAME_DEMI_GODMODE_OFF"));
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -122,7 +122,7 @@ namespace Components
|
|||||||
const auto entNum = ent->s.number;
|
const auto entNum = ent->s.number;
|
||||||
Logger::Print("Notarget toggled for entity %i\n", entNum);
|
Logger::Print("Notarget toggled for entity %i\n", entNum);
|
||||||
|
|
||||||
Game::SV_GameSendServerCommand(entNum, 0, Utils::String::VA("%c \"%s\"", 0x65,
|
Game::SV_GameSendServerCommand(entNum, Game::SV_CMD_CAN_IGNORE, Utils::String::VA("%c \"%s\"", 0x65,
|
||||||
(ent->flags & Game::FL_NOTARGET) ? "GAME_NOTARGETON" : "GAME_NOTARGETOFF"));
|
(ent->flags & Game::FL_NOTARGET) ? "GAME_NOTARGETON" : "GAME_NOTARGETOFF"));
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ namespace Components
|
|||||||
|
|
||||||
if (params->size() < 4 || params->size() > 6)
|
if (params->size() < 4 || params->size() > 6)
|
||||||
{
|
{
|
||||||
Game::SV_GameSendServerCommand(ent->s.number, 0,
|
Game::SV_GameSendServerCommand(ent->s.number, Game::SV_CMD_CAN_IGNORE,
|
||||||
Utils::String::VA("%c \"GAME_USAGE\x15: setviewpos x y z [yaw] [pitch]\n\"", 0x65));
|
Utils::String::VA("%c \"GAME_USAGE\x15: setviewpos x y z [yaw] [pitch]\n\"", 0x65));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -208,7 +208,7 @@ namespace Components
|
|||||||
strncpy_s(ent->client->visionName[visMode],
|
strncpy_s(ent->client->visionName[visMode],
|
||||||
sizeof(Game::gclient_t::visionName[0]) / sizeof(char), name, _TRUNCATE);
|
sizeof(Game::gclient_t::visionName[0]) / sizeof(char), name, _TRUNCATE);
|
||||||
|
|
||||||
Game::SV_GameSendServerCommand(ent->s.number, 1,
|
Game::SV_GameSendServerCommand(ent->s.number, Game::SV_CMD_RELIABLE,
|
||||||
Utils::String::VA("%c \"%s\" %i", Game::MY_CMDS[visMode], name, duration));
|
Utils::String::VA("%c \"%s\" %i", Game::MY_CMDS[visMode], name, duration));
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -236,7 +236,7 @@ namespace Components
|
|||||||
strncpy_s(ent->client->visionName[visMode],
|
strncpy_s(ent->client->visionName[visMode],
|
||||||
sizeof(Game::gclient_t::visionName[0]) / sizeof(char), name, _TRUNCATE);
|
sizeof(Game::gclient_t::visionName[0]) / sizeof(char), name, _TRUNCATE);
|
||||||
|
|
||||||
Game::SV_GameSendServerCommand(ent->s.number, 1,
|
Game::SV_GameSendServerCommand(ent->s.number, Game::SV_CMD_RELIABLE,
|
||||||
Utils::String::VA("%c \"%s\" %i", Game::MY_CMDS[visMode], name, duration));
|
Utils::String::VA("%c \"%s\" %i", Game::MY_CMDS[visMode], name, duration));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ namespace Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Game::SV_GameSendServerCommand(-1, 0, list.data());
|
Game::SV_GameSendServerCommand(-1, Game::SV_CMD_CAN_IGNORE, list.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dedicated::TimeWrapStub(Game::errorParm_t code, const char* message)
|
void Dedicated::TimeWrapStub(Game::errorParm_t code, const char* message)
|
||||||
@ -415,12 +415,12 @@ namespace Components
|
|||||||
|
|
||||||
if (!name.empty())
|
if (!name.empty())
|
||||||
{
|
{
|
||||||
Game::SV_GameSendServerCommand(-1, 0, Utils::String::VA("%c \"%s: %s\"", 104, name.data(), message.data()));
|
Game::SV_GameSendServerCommand(-1, Game::SV_CMD_CAN_IGNORE, Utils::String::VA("%c \"%s: %s\"", 104, name.data(), message.data()));
|
||||||
Game::Com_Printf(15, "%s: %s\n", name.data(), message.data());
|
Game::Com_Printf(15, "%s: %s\n", name.data(), message.data());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Game::SV_GameSendServerCommand(-1, 0, Utils::String::VA("%c \"Console: %s\"", 104, message.data()));
|
Game::SV_GameSendServerCommand(-1, Game::SV_CMD_CAN_IGNORE, Utils::String::VA("%c \"Console: %s\"", 104, message.data()));
|
||||||
Game::Com_Printf(15, "Console: %s\n", message.data());
|
Game::Com_Printf(15, "Console: %s\n", message.data());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -436,12 +436,12 @@ namespace Components
|
|||||||
|
|
||||||
if (!name.empty())
|
if (!name.empty())
|
||||||
{
|
{
|
||||||
Game::SV_GameSendServerCommand(client, 0, Utils::String::VA("%c \"%s: %s\"", 104, name.data(), message.data()));
|
Game::SV_GameSendServerCommand(client, Game::SV_CMD_CAN_IGNORE, Utils::String::VA("%c \"%s: %s\"", 104, name.data(), message.data()));
|
||||||
Game::Com_Printf(15, "%s -> %i: %s\n", name.data(), client, message.data());
|
Game::Com_Printf(15, "%s -> %i: %s\n", name.data(), client, message.data());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Game::SV_GameSendServerCommand(client, 0, Utils::String::VA("%c \"Console: %s\"", 104, message.data()));
|
Game::SV_GameSendServerCommand(client, Game::SV_CMD_CAN_IGNORE, Utils::String::VA("%c \"Console: %s\"", 104, message.data()));
|
||||||
Game::Com_Printf(15, "Console -> %i: %s\n", client, message.data());
|
Game::Com_Printf(15, "Console -> %i: %s\n", client, message.data());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -452,7 +452,7 @@ namespace Components
|
|||||||
if (params->size() < 2) return;
|
if (params->size() < 2) return;
|
||||||
|
|
||||||
std::string message = params->join(1);
|
std::string message = params->join(1);
|
||||||
Game::SV_GameSendServerCommand(-1, 0, Utils::String::VA("%c \"%s\"", 104, message.data()));
|
Game::SV_GameSendServerCommand(-1, Game::SV_CMD_CAN_IGNORE, Utils::String::VA("%c \"%s\"", 104, message.data()));
|
||||||
Game::Com_Printf(15, "Raw: %s\n", message.data());
|
Game::Com_Printf(15, "Raw: %s\n", message.data());
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -463,7 +463,7 @@ namespace Components
|
|||||||
|
|
||||||
int client = atoi(params->get(1));
|
int client = atoi(params->get(1));
|
||||||
std::string message = params->join(2);
|
std::string message = params->join(2);
|
||||||
Game::SV_GameSendServerCommand(client, 0, Utils::String::VA("%c \"%s\"", 104, message.data()));
|
Game::SV_GameSendServerCommand(client, Game::SV_CMD_CAN_IGNORE, Utils::String::VA("%c \"%s\"", 104, message.data()));
|
||||||
Game::Com_Printf(15, "Raw -> %i: %s\n", client, message.data());
|
Game::Com_Printf(15, "Raw -> %i: %s\n", client, message.data());
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -834,7 +834,7 @@ namespace Game
|
|||||||
typedef int(__cdecl* SV_GameClientNum_Score_t)(int clientID);
|
typedef int(__cdecl* SV_GameClientNum_Score_t)(int clientID);
|
||||||
extern SV_GameClientNum_Score_t SV_GameClientNum_Score;
|
extern SV_GameClientNum_Score_t SV_GameClientNum_Score;
|
||||||
|
|
||||||
typedef void(__cdecl * SV_GameSendServerCommand_t)(int clientNum, /*svscmd_type*/int type, const char* text);
|
typedef void(__cdecl * SV_GameSendServerCommand_t)(int clientNum, svscmd_type type, const char* text);
|
||||||
extern SV_GameSendServerCommand_t SV_GameSendServerCommand;
|
extern SV_GameSendServerCommand_t SV_GameSendServerCommand;
|
||||||
|
|
||||||
typedef void(__cdecl * SV_Cmd_TokenizeString_t)(const char* string);
|
typedef void(__cdecl * SV_Cmd_TokenizeString_t)(const char* string);
|
||||||
|
@ -336,6 +336,12 @@ namespace Game
|
|||||||
HITLOC_NUM
|
HITLOC_NUM
|
||||||
} hitLocation_t;
|
} hitLocation_t;
|
||||||
|
|
||||||
|
enum svscmd_type
|
||||||
|
{
|
||||||
|
SV_CMD_CAN_IGNORE = 0x0,
|
||||||
|
SV_CMD_RELIABLE = 0x1,
|
||||||
|
};
|
||||||
|
|
||||||
struct FxEffectDef;
|
struct FxEffectDef;
|
||||||
struct pathnode_t;
|
struct pathnode_t;
|
||||||
struct pathnode_tree_t;
|
struct pathnode_tree_t;
|
||||||
|
Loading…
Reference in New Issue
Block a user