mirror of
https://github.com/openmoh/openmohaa.git
synced 2025-04-28 13:47:58 +03:00
Add a new feature to enable/disable instant messages and text chat with a variable to set the minimum delay between messages
This commit is contained in:
parent
a977cbdd26
commit
e43f0a9285
5 changed files with 73 additions and 5 deletions
|
@ -257,6 +257,10 @@ cvar_t *g_no_seasick;
|
|||
|
||||
cvar_t *g_aistats;
|
||||
|
||||
//
|
||||
// Added in OPM
|
||||
//
|
||||
|
||||
cvar_t *g_obituarylocation;
|
||||
|
||||
cvar_t *sv_scriptfiles;
|
||||
|
@ -269,6 +273,15 @@ cvar_t *g_spectatefollow_firstperson;
|
|||
|
||||
cvar_t *cl_running;
|
||||
|
||||
// Whether or instant messages are allowed
|
||||
cvar_t *g_instamsg_allowed;
|
||||
// Minimum delay, in milliseconds, between instant messages
|
||||
cvar_t *g_instamsg_minDelay;
|
||||
// Whether or not text messages are allowed
|
||||
cvar_t *g_textmsg_allowed;
|
||||
// Minimum delay, in milliseconds, between messages
|
||||
cvar_t *g_textmsg_minDelay;
|
||||
|
||||
void CVAR_Init(void)
|
||||
{
|
||||
developer = gi.Cvar_Get("developer", "0", 0);
|
||||
|
@ -596,6 +609,10 @@ void CVAR_Init(void)
|
|||
g_rifles_for_sweepers = gi.Cvar_Get("g_rifles_for_sweepers", "0", 0);
|
||||
g_no_seasick = gi.Cvar_Get("g_no_seasick", "0", 0);
|
||||
|
||||
//
|
||||
// Added in OPM
|
||||
//
|
||||
|
||||
if (g_target_game >= target_game_e::TG_MOHTA) {
|
||||
g_obituarylocation = gi.Cvar_Get("g_obituarylocation", "0", 0);
|
||||
} else {
|
||||
|
@ -624,5 +641,10 @@ void CVAR_Init(void)
|
|||
gi.cvar_set("sv_numbots", sv_maxbots->string);
|
||||
}
|
||||
|
||||
g_instamsg_allowed = gi.Cvar_Get("g_instamsg_allowed", "1", 0);
|
||||
g_instamsg_minDelay = gi.Cvar_Get("g_instamsg_minDelay", "0", 0);
|
||||
g_textmsg_allowed = gi.Cvar_Get("g_textmsg_allowed", "1", 0);
|
||||
g_textmsg_minDelay = gi.Cvar_Get("g_textmsg_minDelay", "0", 0);
|
||||
|
||||
cl_running = gi.Cvar_Get("cl_running", "", 0);
|
||||
}
|
||||
|
|
|
@ -274,6 +274,11 @@ extern cvar_t *g_spectatefollow_firstperson;
|
|||
|
||||
extern cvar_t *cl_running;
|
||||
|
||||
extern cvar_t *g_instamsg_allowed;
|
||||
extern cvar_t *g_instamsg_minDelay;
|
||||
extern cvar_t *g_textmsg_allowed;
|
||||
extern cvar_t *g_textmsg_minDelay;
|
||||
|
||||
void CVAR_Init(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -2023,6 +2023,9 @@ Player::Player()
|
|||
#endif
|
||||
m_fpsTiki = NULL;
|
||||
m_bConnected = false;
|
||||
|
||||
m_iInstantMessageTime = 0;
|
||||
m_iTextChatTime = 0;
|
||||
//====
|
||||
|
||||
if (LoadingSavegame) {
|
||||
|
@ -10403,6 +10406,16 @@ void Player::EventDMMessage(Event *ev)
|
|||
return;
|
||||
}
|
||||
|
||||
if (!g_instamsg_allowed->integer) {
|
||||
// Added in OPM
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_instamsg_minDelay->integer > 0 && level.inttime < m_iInstantMessageTime + g_instamsg_minDelay->integer) {
|
||||
// Added in OPM
|
||||
return;
|
||||
}
|
||||
|
||||
GetTeamDialogPrefix(sAliasName);
|
||||
sAliasName += va("%c%c", (sToken[1] + '0'), (sToken[2] + '0'));
|
||||
sRandomAlias = GetRandomAlias(sAliasName, &pSoundAlias);
|
||||
|
@ -10449,17 +10462,39 @@ void Player::EventDMMessage(Event *ev)
|
|||
iMode = -1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!g_textmsg_allowed->integer) {
|
||||
// Added in OPM
|
||||
|
||||
if (g_voiceChatTime->value > 0) {
|
||||
m_fTalkTime = g_voiceChatTime->value + level.time;
|
||||
str errorString = gi.LV_ConvertString("Message Error");
|
||||
str reasonString = gi.LV_ConvertString("Text chat is disabled on this server");
|
||||
|
||||
gi.SendServerCommand(
|
||||
edict - g_entities,
|
||||
"print \"" HUD_MESSAGE_CHAT_WHITE "%s: %s.\n\"",
|
||||
errorString.c_str(),
|
||||
reasonString.c_str()
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_textmsg_minDelay->integer > 0 && level.inttime < m_iTextChatTime + g_textmsg_minDelay->integer) {
|
||||
// Added in OPM
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!bInstaMessage) {
|
||||
if (bInstaMessage) {
|
||||
if (g_voiceChatTime->value > 0) {
|
||||
m_fTalkTime = g_voiceChatTime->value + level.time;
|
||||
}
|
||||
m_iInstantMessageTime = level.inttime;
|
||||
} else {
|
||||
iMode = ev->GetInteger(1);
|
||||
if (g_textChatTime->value > 0) {
|
||||
m_fTalkTime = g_textChatTime->value + level.time;
|
||||
}
|
||||
m_iTextChatTime = level.inttime;
|
||||
}
|
||||
|
||||
Q_strncpyz(szPrintString, "print \"" HUD_MESSAGE_CHAT_WHITE, sizeof(szPrintString));
|
||||
|
|
|
@ -345,7 +345,9 @@ public:
|
|||
bool m_bWaitingForRespawn;
|
||||
bool m_bShouldRespawn;
|
||||
|
||||
// new variables
|
||||
//
|
||||
// Added in OPM
|
||||
//
|
||||
str m_sVision; // current vision
|
||||
str m_sStateFile; // custom statefile
|
||||
bool m_bFrozen; // if player is frozen
|
||||
|
@ -360,6 +362,10 @@ public:
|
|||
bool m_bConnected;
|
||||
str m_lastcommand;
|
||||
|
||||
private:
|
||||
int m_iInstantMessageTime;
|
||||
int m_iTextChatTime;
|
||||
|
||||
public:
|
||||
qboolean CondTrue(Conditional& condition);
|
||||
qboolean CondChance(Conditional& condition);
|
||||
|
|
|
@ -34,7 +34,7 @@ Overall, better compatibility on modern systems and bugfixes.
|
|||
- More script commands for mods
|
||||
- Non-PVS optimization
|
||||
- Packet flood protection
|
||||
- Spectate players in first-person
|
||||
- Ability to enable/disable the text chat and the voice message chat and set a delay between chat/instant messages
|
||||
|
||||
#### Non-PVS optimization
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue