View Single Post
SpirT
Senior Member
Join Date: Sep 2018
Location: Portugal
Old 05-26-2020 , 08:47   Re: [ISSUE] Not storing all strings
Reply With Quote #2

Quote:
Originally Posted by Tilex View Post
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;

Hey! Thanks for the reply. I changed the OnChatMessage action to yours. Still not replacing the badword either listing all badwords.

What changes need to be made?
__________________
SpirT is offline