Raised This Month: $32 Target: $400
 8% 

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
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 11-19-2017 , 13:38   Re: Weird problem.
Reply With Quote #5

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 #6

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
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 11-19-2017 , 15:48   Re: Weird problem.
Reply With Quote #7

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 #8

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
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 11-19-2017 , 16:15   Re: Weird problem.
Reply With Quote #9

How would I know? I don't know what plugins you're running.



Here's another problem:

Code:
L 11/19/2017 - 22:22:51: Invalid player id 66
L 11/19/2017 - 22:22:51: [AMXX] Displaying debug trace (plugin "test1.amxx")
L 11/19/2017 - 22:22:51: [AMXX] Run time error 10: native error (native "get_use
r_flags")
L 11/19/2017 - 22:22:51: [AMXX]    [0] test1.sma::SayRegistered (line 111)
(Counter-Terrorist) Black Rose : hello
Code:
        new    pnum,
            players[32];
         
        get_players( players,pnum );
                  for( new i;i < pnum;i++ )         {
            if( get_user_team( id ) == get_user_team( player[i] ) || get_user_flags( player[i] ) & ADMIN_FLAGS )
                ColorChat( players[i] , iColor, sFormat );         }
player[] is a string containing the player name, players[] is the array of players.
have you even looked at the log? It's so much easier to debug things with the server console at least partially visible on screen so you see when bugs occur. That will help you to figure out the cause.

Last edited by Black Rose; 11-19-2017 at 16:36.
Black Rose is offline
maqi
Senior Member
Join Date: Apr 2017
Location: Serbia
Old 11-19-2017 , 16:23   Re: Weird problem.
Reply With Quote #10

Example ( Plugin is working normaly for everyone and all of a sudden one random admin doesnt have it working, instead they have a default say message: *DEAD* nick : message

And i dont know how to recreate it, or i would probably find a way to fix it, that is why this is so weird.

Last edited by maqi; 11-19-2017 at 16:24.
maqi is offline
Reply


Thread Tools
Display Modes

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 14:19.


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