Raised This Month: $51 Target: $400
 12% 

can't hook say and say_team


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
lexzor
Veteran Member
Join Date: Nov 2020
Old 08-25-2021 , 10:19   can't hook say and say_team
Reply With Quote #1

hello, i m trying to hook say and say_team on my server. the problem is that on other default servers it s working but not for my server.

this is how i hook it.

PHP Code:
public plugin_init()
{
        
register_clcmd("say""say_hook");
    
register_clcmd("say_team""say_hook");
}

public 
say_hook(id)
{
    new 
szArg[192];
    
read_argv(1szArgcharsmax(szArg));
    
remove_quotes(szArg);
    
server_print("Message: %s"szArg);

    if(
equali(szArg[0], "@"))
        return 
PLUGIN_HANDLED;

    if(
equali(szArg"/myacc"))
    {    
        
register_player_menu(id);
        return 
PLUGIN_HANDLED;
    }

    new 
iFilePointeriRestrictedWord;
    new 
iFile file_exists(g_szFile);
    
    if (
iFile)
    {
        new 
szData[128], iSectionbool:bRestrictedWord;

        
iFilePointer fopen(g_szFile"rt");
        
        while(!
feof(iFilePointer))
        {
            
fgets(iFilePointerszDatacharsmax(szData));
            
trim(szData);
            
            if(
szData[0] == '#' || szData[0] == EOS || szData[0] == ';')
                continue;
                
            if(
szData[0] == '[')
            {
                
iSection += 1;
            }
            
            switch(
iSection)
            {
                case 
CHAT_RESTRICTED_WORDS:
                {
                    
iRestrictedWord containi(szArgszData);
                    
                    if(
iRestrictedWord != -1)
                    {
                        
bRestrictedWord true;
                        break;
                    }
                }
            }
        }

        
fclose(iFilePointer);

        if(!
bRestrictedWord)
        {
            new 
iDate[32], iTime[15], iTeam[13];

            
mysql_escape_string(szArgcharsmax(szArg));
        
            
get_time("%d/%m/%Y"iDatecharsmax(iDate));
            
get_time("%H:%M:%S"iTimecharsmax(iTime));

            switch(
get_user_team(id))
            {
                case 
1formatex(iTeamcharsmax(iTeam), "(T)");
                case 
2formatex(iTeamcharsmax(iTeam), "(CT)");
                case 
3,0formatex(iTeamcharsmax(iTeam), "(SPECTATOR)");
            }    

            new 
szQuery[512];

            
formatex(szQuerycharsmax(szQuery), "INSERT INTO `%s` (`name`,`steamid`,`team`,`date`,`time`,`message`) \
            VALUES ('%s','%s','%s','%s','%s','%s')"
,
            
g_szTables[2], g_UserData[id][szName], g_UserData[id][szAuthID], iTeamiDateiTimeszArg);

            
SQL_ThreadQuery(g_SqlTuple"FreeHandle"szQuery);
        }
        else 
        {
            
log_amx("Message from ^"%s^" has been restricted because contain word: ^"%s^""g_UserData[id][szName], szArg[iRestrictedWord]);
        }
    }
    return 
PLUGIN_CONTINUE;

Some ideas?

Last edited by lexzor; 08-25-2021 at 10:19.
lexzor is offline
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 08-25-2021 , 10:44   Re: can't hook say and say_team
Reply With Quote #2

You already hook say / say_team in another plugin. Deactivate plugins one by one and find out which one is.
__________________


Accepting Paid Requests, contact PM.

MVP Of The Round View project on GITHUB / AlliedModders
CSGO REMAKE ~ CSGO MOD [STABLE + SOURCE CODE]
Shadows Adi is offline
lexzor
Veteran Member
Join Date: Nov 2020
Old 08-25-2021 , 15:10   Re: can't hook say and say_team
Reply With Quote #3

yes but the plugin it s first in plugins.ini. when a player send command say to server it should not be checked according to the order of the plugins in plugins.ini
lexzor is offline
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 08-25-2021 , 16:04   Re: can't hook say and say_team
Reply With Quote #4

It doesn't matter, once hooked, always hooked.
__________________


Accepting Paid Requests, contact PM.

MVP Of The Round View project on GITHUB / AlliedModders
CSGO REMAKE ~ CSGO MOD [STABLE + SOURCE CODE]
Shadows Adi is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-25-2021 , 20:48   Re: can't hook say and say_team
Reply With Quote #5

The code is correct for hooking say and say_team so it's something else that is preventing it from working. Maybe the plugin isn't not actually getting loaded or you forgot to upload the wrong version of the .amxx file. I recommend registering your plugin with name, version, and author so that you can then check the "amxx list" to make sure that it's in there and is loading properly. When you make a change, change the version number so that you can verify that the new version is the one that is actually running (I do this all the time during testing).

P.S. reading a file in a function that is called often is generally a bad idea. Load the file once into some variables and then use the variables to check for the words.
__________________
fysiks is offline
lexzor
Veteran Member
Join Date: Nov 2020
Old 08-26-2021 , 06:06   Re: can't hook say and say_team
Reply With Quote #6

Acutally another plugin was using plugin_handled instead of plugin_handled_main.
Quote:
Originally Posted by fysiks View Post
P.S. reading a file in a function that is called often is generally a bad idea. Load the file once into some variables and then use the variables to check for the words.
Should i use arrays?
lexzor is offline
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 08-26-2021 , 07:06   Re: can't hook say and say_team
Reply With Quote #7

Quote:
Originally Posted by lexzor View Post
Should i use arrays?
Arrays, dynamic arrays or tries. You could read file contents in plugin_cfg() forward.
__________________


Accepting Paid Requests, contact PM.

MVP Of The Round View project on GITHUB / AlliedModders
CSGO REMAKE ~ CSGO MOD [STABLE + SOURCE CODE]

Last edited by Shadows Adi; 08-26-2021 at 07:06.
Shadows Adi 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 06:29.


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