Raised This Month: $ Target: $400
 0% 

Weird problem.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
maqi
Senior Member
Join Date: Apr 2017
Location: Serbia
Old 11-18-2017 , 18:37   Weird problem.
Reply With Quote #1

Hey guys, I recently made this plugin for my server, and everything looked and worked well.

Today I entered a server and for everyone else it worked perfectly, but for me, I had the default say ( Like it returned continue ). Then my brother joined and he had the default say and everything was working fine for me.

Im loosing my mind and have no clue whats happening, please help.

Also please dont answer me something on the lines of "There is a plugin for this already" We had some problems with those so i made this one which does exactly what i need, no reason to use anything more. But if there are any code errors please be sure to point them out!

PHP Code:
#include <amxmodx>
#include <amxmisc>

#include < colorchat >

#pragma semicolon 1

new const     plugin[]    =    "chat",
        
version[]    =    "1.4",
        
author[]    =    "maqi";

#define ADMIN_FLAGS     ADMIN_BAN
#define VIP_FLAGS     ADMIN_LEVEL_C

new const    ADMIN_PREFIX[]     =     "[Admin]",
        
VIP_PREFIX[]     =     "[Vip]";
        
new        
bool:hasPrefix[32] = true;

new 
Color:iColor;

public 
plugin_init() 
{
    
register_pluginpluginversionauthor );
    
    
register_clcmd"say""SayRegistered" );
    
register_clcmd"say_team""SayRegistered" );
}
public 
client_authorizedid )
    
hasPrefixid ] = true;

public 
SayRegisteredid )
{
    new     
said[192],
        
player[32],
        
team[20],
        
cmd[9],
        
arg1[9],
        
prefix[8],
        
dead[8];
        
    
    
read_argv0cmdcharsmax(cmd) );
    
read_argv1arg1charsmax(arg1) );
    
read_argssaidcharsmax(said) );
    
remove_quotessaid );
    
get_user_nameidplayercharsmax(player) );
        
    if( 
equaliarg1"/prefix" ) )
        
PrefixToggleid );    
        
    if( 
said[0] == '/' || equalisaid"" ) )
        return 
PLUGIN_HANDLED;
    
    if( 
get_user_flagsid ) & ADMIN_FLAGS && hasPrefixid ] )
        
copyprefixcharsmax(prefix), ADMIN_PREFIX );
    else if ( 
get_user_flagsid ) & VIP_FLAGS && hasPrefixid ] )
        
copyprefixcharsmax(prefix), VIP_PREFIX );    
    else
        
copyprefixcharsmax(prefix), "" );
        
    if( 
get_user_teamid ) == )
        
copydeadcharsmax(dead), " SPEC " );    
    else if( !
is_user_aliveid ) )
        
copydeadcharsmax(dead), " DEAD " );    
    else
        
copydeadcharsmax(dead), "" );
    
    switch ( 
get_user_teamid ) )
    {
        case 
1:
        {
            if( 
equalcmd"say_team") )
                
copyteamcharsmax(team), "(Terrorist)" );
            
iColor RED;
        }
        case 
2:
        {
            if( 
equalcmd"say_team") )
                
copyteamcharsmax(team), "(Counter-Terrorist)" ); 
            
iColor BLUE;
        }
        case 
3:
        {
            if( 
equalcmd"say_team") )
                
copyteamcharsmax(team), "(Spectator)" );    
            
iColor GREEN;
        }
        default:
            return 
PLUGIN_CONTINUE;
    }
    
    new    
sFormat[192];
    
    if( !
is_user_aliveid ) )
        
formatsFormatcharsmax(sFormat), "^x04%s^x01%s%s^x03%s: ^x01%s"prefixdeadteamplayersaid ); 
    else if( ( 
get_user_flagsid ) & ADMIN_FLAGS  || get_user_flagsid ) & VIP_FLAGS || equalcmd"say_team") ) && hasPrefixid ] )
        
formatsFormatcharsmax(sFormat), "^x04%s^x01%s%s^x03 %s: ^x01%s"prefixdeadteamplayersaid );
    else
        
formatsFormatcharsmax(sFormat), "^x04%s^x01%s%s^x03%s: ^x01%s"prefixdeadteamplayersaid ); 
        
    if( 
equalcmd"say_team") )
    {
        new    
pnum,
            
players[32];
        
        
get_playersplayers,pnum );
        
        for( new 
i;pnum;i++ )
        {
            if( 
get_user_teamid ) == get_user_teamplayer[i] ) || get_user_flagsplayer[i] ) & ADMIN_FLAGS )
                
ColorChatplayers[i] , iColorsFormat );
        }
    }
    
    
ColorChat0iColorsFormat );
    
    return 
PLUGIN_HANDLED;
}

public 
PrefixToggleid )
{
    if( 
get_user_flagsid ) & ADMIN_FLAGS || get_user_flagsid ) & VIP_FLAGS )
    {
        if( 
hasPrefixid ] )
        {
            
hasPrefixid ] = false;
            
ColorChatidGREEN"^x04[chat]^x01 Admin Prefix Disabled." );
        } else {
            
hasPrefixid ] = true;
            
ColorChatidGREEN"^x04[chat]^x01 Admin Prefix Enabled." );
        }
    }


Thanks in advance
maqi is offline
VINAGHOST
Member
Join Date: Aug 2016
Location: Việt Nam
Old 11-18-2017 , 23:59   Re: Weird problem.
Reply With Quote #2

Did you try "return PLUGIN_HANDLED;" to "return PLUGIN_HANDLED_MAIN" ?
I saw in "Admin Prefixes" - m0skVi4a, he use it ._.

And look like you forgot "else" here
PHP Code:
if( equalcmd"say_team") ) 
    { 
        new    
pnum
            
players[32]; 
         
        
get_playersplayers,pnum ); 
         
        for( new 
i;pnum;i++ ) 
        { 
            if( 
get_user_teamid ) == get_user_teamplayer[i] ) || get_user_flagsplayer[i] ) & ADMIN_FLAGS 
                
ColorChatplayers[i] , iColorsFormat ); 
        } 
    } 
 else 
//HERE
         
ColorChat0iColorsFormat ); 
Sorry for my bad English ._.

Last edited by VINAGHOST; 11-19-2017 at 00:01.
VINAGHOST is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 11-19-2017 , 07:27   Re: Weird problem.
Reply With Quote #3

You can't use read_argv in say/say_team. You have to use trim() and strbreak() from string.inc. You can learn to use them by looking at the /donate plugin from Zombie Plague.
__________________

Last edited by edon1337; 11-19-2017 at 07:30.
edon1337 is offline
maqi
Senior Member
Join Date: Apr 2017
Location: Serbia
Old 11-19-2017 , 10:40   Re: Weird problem.
Reply With Quote #4

@VINAGHOST
Yes i did forget, but it worked even without it ( No double messages )
Such a simple plugin but nothing makes sense to me

@edon1337
I dont get if you are saying i shouldnt or that it wont work. Because that part is working perfectly

Im just having problems with why is my plugin acting like its returning PLUGIN_CONTINUE
maqi is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 11-19-2017 , 19:50   Re: Weird problem.
Reply With Quote #5

Quote:
Originally Posted by maqi View Post
I dont get if you are saying i shouldnt or that it wont work. Because that part is working perfectly
Take a look at this thread.
__________________
edon1337 is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 11-19-2017 , 13:38   Re: Weird problem.
Reply With Quote #6

What you do is find out what the errors have in common. "Random" is not a cause, code doesn't behave that way. The code will do what you tell it to.

From what I can see you will get double messages whenever writing a team-message, and everyone will get it.
To fix this you either put a "return PLUGIN_HANDLED" after the team message is sent or you put the ColorChat() for the main chat inside an else-statement.
It is also possible another plugin is interfering but I would say that seems unlikely.

Last edited by Black Rose; 11-19-2017 at 13:40.
Black Rose is offline
maqi
Senior Member
Join Date: Apr 2017
Location: Serbia
Old 11-19-2017 , 14:30   Re: Weird problem.
Reply With Quote #7

I agree with you, but i fixed that mistake.

My question is why is the say message ever happening if my plugin is essentially this:
PHP Code:
public plugin_init() 
    
register_clcmd"say""SayRegistered" );
public 
SayRegistered(id)
    return 
PLUGIN_HANDLED 
maqi is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 11-21-2017 , 10:32   Re: Weird problem.
Reply With Quote #8

Quote:
Originally Posted by maqi View Post
I agree with you, but i fixed that mistake.

My question is why is the say message ever happening if my plugin is essentially this:
PHP Code:
public plugin_init() 
    
register_clcmd"say""SayRegistered" );
public 
SayRegistered(id)
    return 
PLUGIN_HANDLED 
Maybe you have a plugin like all chat or something like this that sends a message artificially and then returns handled.
Solution is to put it above all plugins in plugins.ini and see what happens.
siriusmd99 is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 11-19-2017 , 15:48   Re: Weird problem.
Reply With Quote #9

Simple answer: It doesn't.
Black Rose is offline
maqi
Senior Member
Join Date: Apr 2017
Location: Serbia
Old 11-19-2017 , 15:50   Re: Weird problem.
Reply With Quote #10

Man you can see my code, ur answer like that doesnt help me at all Either find a mistake or tell me a plugin is interfearing or something else
maqi is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 13:51.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode