You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I propose to implement the ability to quickly clear the player's userinfo, which is set by the setinfo command. The code from one of my projects that implements this feature is as follows:
char *g_info_numbers[] =
{
"topcolor",
"bottomcolor",
"rate",
"cl_updaterate",
"cl_lw",
"cl_lc",
};
bool IsNumberKey(char *key)
{
for (auto &&k : g_info_numbers)
{
if (!_stricmp(key, k))
return true;
}
return false;
}
void hkCmd_SetInfo()
{
if (CMD_ARGC() < 2)
return orgCmd_SetInfo();
auto key = CMD_ARGV(1);
if (_stricmp(key, "restore") != 0 && _stricmp(key, "clear") != 0)
return orgCmd_SetInfo();
memset(cls.userinfo, 0, MAX_INFO_STRING);
auto cvars = GET_CVAR_LIST();
while (cvars)
{
if (cvars->flags & FCVAR_USERINFO)
{
char *value;
if (IsNumberKey(cvars->name))
value = va("%d", atoi(cvars->string));
else
value = cvars->string;
gEngine.pNetAPI->Info_SetValueForStarKey(cls.userinfo, cvars->name, value, MAX_INFO_STRING);
}
cvars = cvars->next;
}
CON_PRINTF("Setinfo restored.\n");
}
The project works as an add-on that intercepts the setinfo command handler, which explains the orgCmd_SetInfo function that points to the original setinfo callback.
The text was updated successfully, but these errors were encountered:
I propose to implement the ability to quickly clear the player's userinfo, which is set by the setinfo command. The code from one of my projects that implements this feature is as follows:
The project works as an add-on that intercepts the setinfo command handler, which explains the
orgCmd_SetInfo
function that points to the original setinfo callback.The text was updated successfully, but these errors were encountered: