View Single Post
Paralhama
New Member
Join Date: Aug 2021
Old 02-19-2024 , 20:58   Re: Advertisements 2.1 (Updated 2021/02/06)
Reply With Quote #2225

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[] messagechar[] bufferint maxlength)
{
    
char name[64], value[256];
    
int buf_idxiname_len;
    
ConVar hConVar;

    while (
message[i] && buf_idx maxlength 1) {
        if (
message[i] != '{' || (name_len FindCharInString(message[1], '}')) == -1) {
            
buffer[buf_idx++] = message[i++];
            continue;
        }

        
strcopy(namename_len 1message[1]);

        
// Block responsible for replacing variables
        
if ((hConVar FindConVar(name))) {
            
hConVar.GetString(valuesizeof(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_idxvalue);
            }
        } else {
            
// If the variable is not found, clear the buffer and exit the loop
            
buf_idx 0;
            break;
        }

        
+= name_len 2;
    }

    
buffer[buf_idx] = '\0';

Paralhama is offline