View Single Post
Tilex
Junior Member
Join Date: May 2020
Old 05-25-2020 , 19:17   Re: [ISSUE] Not storing all strings
Reply With Quote #6

PHP Code:
public Action foo
{
    for (
int i 0sizeof(BadWord); i++)
    {
     
bar;
     
bar:
     
bar;


     return 
Plugin_Handled;
    }
    
    return 
Plugin_Handled;

you see it?
You have a pre-mature return in your for loop

Also the "return Plugin_Changed" needs to go.
I'm not sure what it does, but if it's important, you should rather define a flag before your for and then check what to return afterwards:

PHP Code:
public Action OnChatMessage(intauthorHandle recipientschar[] namechar[] message)
{
    
bool changesMade false;
    for (
int i 0sizeof(BadWord); i++)
    {
        
char newMessage[256];
        
strcopy(newMessagesizeof(newMessage), message);
            
        if(
StrContains(newMessageBadWord[i]))
        {
            
ReplaceString(newMessagesizeof(newMessage), BadWord[i], BadWordReplace);
            
changesMade true;
        }
        
        
    }
    
    if(
changesMade)
       return 
Plugin_Changed;
    else
       return 
Plugin_Handled;

Tilex is offline