Skip to content

Commit

Permalink
Add !restart and !1on1 (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChillerDragon committed Nov 13, 2023
1 parent d0f061f commit f486f84
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
43 changes: 42 additions & 1 deletion src/game/server/gamecontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2048,7 +2048,9 @@ void CGameContext::OnSayNetMessage(const CNetMsg_Cl_Say *pMsg, int ClientID, con
else
Team = CHAT_ALL;

if(pMsg->m_pMessage[0] == '/')
if(pMsg->m_pMessage[0] == '!')
OnBangCommand(pMsg->m_pMessage + 1, ClientID);
else if(pMsg->m_pMessage[0] == '/')
{
if(str_startswith_nocase(pMsg->m_pMessage + 1, "w "))
{
Expand Down Expand Up @@ -4750,6 +4752,45 @@ void CGameContext::OnUpdatePlayerServerInfo(char *aBuf, int BufSize, int ID)

// gctf

void CGameContext::OnBangCommand(const char *pLine, int ClientID)
{
const char *pCmd = pLine;

int SetSlots = -1;
const char aaVs[][16] = {"on", "n", "vs", "v"};
for(auto aVs : aaVs)
{
for(int i = 1; i <= 8; i++)
{
char a1on1[32];
str_format(a1on1, sizeof(a1on1), "%d%s%d", i, aVs, i);
if(!str_comp_nocase(pCmd, a1on1))
{
SetSlots = i;
break;
}
}
}

if(SetSlots != -1)
{
char aCmd[512];
str_format(aCmd, sizeof(aCmd), "sv_spectator_slots %d", MAX_CLIENTS - SetSlots * 2);
char aDesc[512];
str_format(aDesc, sizeof(aDesc), "%dvs%d", SetSlots, SetSlots);
char aChatmsg[512];
str_format(aChatmsg, sizeof(aChatmsg), "'%s' called vote to change server option '%s'", Server()->ClientName(ClientID), aDesc);
CallVote(ClientID, aDesc, aCmd, "chat cmd", aChatmsg);
}
else if(!str_comp_nocase(pCmd, "restart") || !str_comp_nocase(pCmd, "reload") || !str_comp_nocase(pCmd, "go"))
{
// if(pResult->NumArguments())
// m_pController->DoWarmup(pResult->GetInteger(0));
// else
m_pController->DoWarmup(10);
}
}

void CGameContext::SendGameMsg(int GameMsgID, int ClientID)
{
CMsgPacker Msg(protocol7::NETMSGTYPE_SV_GAMEMSG, false, true);
Expand Down
1 change: 1 addition & 0 deletions src/game/server/gamecontext.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ class CGameContext : public IGameServer
void SendGameMsg(int GameMsgID, int ParaI1, int ClientID);
void SendGameMsg(int GameMsgID, int ParaI1, int ParaI2, int ParaI3, int ClientID); // gctf
int GetDDNetInstaWeapon();
void OnBangCommand(const char *pLine, int ClientID);

//
void CheckPureTuning();
Expand Down

0 comments on commit f486f84

Please sign in to comment.