Skip to content

Commit 40c6978

Browse files
committed
add basic whisper for clients without chatcommands support
1 parent 3acd52e commit 40c6978

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

src/game/server/gamecontroller.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1361,6 +1361,27 @@ void IGameController::Com_ServerInfo(IConsole::IResult *pResult, void *pContext)
13611361
pSelf->GameServer()->SendChat(-1, CHAT_ALL, ClientID, pSelf->Config()->m_SvInfoLine3);
13621362
}
13631363

1364+
void IGameController::Com_Whisper(IConsole::IResult *pResult, void *pContext)
1365+
{
1366+
CCommandManager::SCommandContext *pComContext = (CCommandManager::SCommandContext *)pContext;
1367+
IGameController *pSelf = (IGameController *)pComContext->m_pContext;
1368+
1369+
int ClientID = pComContext->m_ClientID;
1370+
{
1371+
const char* TargetID = pResult->GetString(0);
1372+
if (!(TargetID[0] == '0' || TargetID[0] == '1' || TargetID[0] == '2' || TargetID[0] == '3' || TargetID[0] == '4' || TargetID[0] == '5' || TargetID[0] == '6' || TargetID[0] == '7' || TargetID[0] == '8' || TargetID[0] == '9'))
1373+
{
1374+
pSelf->GameServer()->SendChat(-1, CHAT_ALL, ClientID, "You need to use client id");
1375+
return;
1376+
}
1377+
}
1378+
1379+
int TargetID = pResult->GetInteger(0);
1380+
const char* pMsg = pResult->GetString(1);
1381+
1382+
pSelf->GameServer()->SendChat(ClientID, CHAT_WHISPER, TargetID, pMsg);
1383+
}
1384+
13641385
/*void IGameController::Com_Example(IConsole::IResult *pResult, void *pContext)
13651386
{
13661387
CCommandManager::SCommandContext *pComContext = (CCommandManager::SCommandContext *)pContext;
@@ -1375,5 +1396,6 @@ void IGameController::RegisterChatCommands(CCommandManager *pManager)
13751396
pManager->AddCommand("help", "get info about the current gametype", "", Com_GameHelp, this);
13761397
pManager->AddCommand("restart", "vote for restarting the match", "", Com_Restart, this);
13771398
pManager->AddCommand("info", "get info about the server and contact links", "", Com_ServerInfo, this);
1399+
pManager->AddCommand("w", "send private message", "ir", Com_Whisper, this);
13781400
//pManager->AddCommand("test", "Test the command system", "r", Com_Example, this);
13791401
}

src/game/server/gamecontroller.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ class IGameController
246246
static void Com_Restart(IConsole::IResult *pResult, void *pContext);
247247
virtual const char *GetGameHelpText();
248248
static void Com_ServerInfo(IConsole::IResult *pResult, void *pContext);
249+
static void Com_Whisper(IConsole::IResult *pResult, void *pContext);
249250
//static void Com_Example(IConsole::IResult *pResult, void *pContext);
250251
virtual void RegisterChatCommands(CCommandManager *pManager);
251252

0 commit comments

Comments
 (0)