Your plugin is incredible!
I'm using it on my Fistful of Frags servers
but when using "Super kick is {sm_super_kick}.""
the result is "Super Kick is 0" or "Super Kick is 0"
So I made this small change
Instead of displaying 1 it will display "ON"
Instead of displaying 0 it will display "OFF"
If the variable is not found it will go to the next advertisement
PHP Code:
void ProcessVariables(const char[] message, char[] buffer, int maxlength)
{
char name[64], value[256];
int buf_idx, i, name_len;
ConVar hConVar;
while (message[i] && buf_idx < maxlength - 1) {
if (message[i] != '{' || (name_len = FindCharInString(message[i + 1], '}')) == -1) {
buffer[buf_idx++] = message[i++];
continue;
}
strcopy(name, name_len + 1, message[i + 1]);
// Block responsible for replacing variables
if ((hConVar = FindConVar(name))) {
hConVar.GetString(value, sizeof(value));
// I modified this part to specifically handle the cases of 0 and 1
if (StrEqual(value, "1")) {
buf_idx += strcopy(buffer[buf_idx], maxlength - buf_idx, "ON");
} else if (StrEqual(value, "0")) {
buf_idx += strcopy(buffer[buf_idx], maxlength - buf_idx, "OFF");
} else {
buf_idx += strcopy(buffer[buf_idx], maxlength - buf_idx, value);
}
} else {
// If the variable is not found, clear the buffer and exit the loop
buf_idx = 0;
break;
}
i += name_len + 2;
}
buffer[buf_idx] = '\0';
}