Skip to content

Commit 60a5af1

Browse files
committed
Add client state conditional
1 parent fdde946 commit 60a5af1

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/game/client/components/tclient/conditional.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,27 @@ void CConditional::OnConsoleInit()
317317
int i = std::clamp((int)(y / h * 3.0f), 0, 2) * 3 + std::clamp((int)(x / w * 3.0f), 0, 2);
318318
return str_copy(pOut, s_apLocations[i], Length);
319319
});
320+
m_vVariables.emplace_back("state", [&](char *pOut, int Length) {
321+
switch(Client()->State())
322+
{
323+
case IClient::EClientState::STATE_CONNECTING:
324+
return str_copy(pOut, "connecting", Length);
325+
case IClient::STATE_OFFLINE:
326+
return str_copy(pOut, "offline", Length);
327+
case IClient::STATE_LOADING:
328+
return str_copy(pOut, "loading", Length);
329+
case IClient::STATE_ONLINE:
330+
return str_copy(pOut, "online", Length);
331+
case IClient::STATE_DEMOPLAYBACK:
332+
return str_copy(pOut, "demo", Length);
333+
case IClient::STATE_QUITTING:
334+
return str_copy(pOut, "quitting", Length);
335+
case IClient::STATE_RESTARTING:
336+
return str_copy(pOut, "restarting", Length);
337+
}
338+
dbg_assert(false, "Invalid client state");
339+
dbg_break();
340+
});
320341

321342
m_vFunctions.emplace_back("id", [&](const char *pParam, char *pOut, int Length) {
322343
if(Client()->State() != CClient::STATE_ONLINE && Client()->State() != CClient::STATE_DEMOPLAYBACK)

0 commit comments

Comments
 (0)