AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Hiding commands in public chat (https://forums.alliedmods.net/showthread.php?t=296095)

asw32 04-11-2017 22:42

Hiding commands in public chat
 
Hello,

In CS 1.6 AMXX How do I go about making it so that when people type the following commands in my server, the commands are only shown to that player, not the whole server. Also, I don't want the command to show up as having been typed.

So:

If a player types "thetime" or "/rank" I do not want the command to publicly show up in the server. I only want them to see the return from that command. I don't want other players to see "thetime".

I want to do this for thetime, /rank, /top15, /hp, /nextmap, and /timeleft.

Any help would be appreciated. I saw posts from searching about using PUBLIC_HANDLED and stuff like that, but I couldn't figure out what file to put that in or where to put it.

Thanks in advance.

EFFx 04-12-2017 00:53

Re: Hiding commands in public chat
 
Code:
register_clcmd("say", "cmdSay")

Code:
public cmdSay(id) {     new szWords[20]     read_argv(1, szWords, charsmax(szWords))     remove_quotes (szWords)     if(equal(szWords, "thetime"))     {          client_print(id, print_chat, szWords)          return PLUGIN_HANDLED     }     return PLUGIN_CONTINUE }

I think the original plugin that uses thetime will be affected. If it be, then you need to add the client_print() in the code of your nextmap plugin.

LegacyCode 04-12-2017 04:53

Re: Hiding commands in public chat
 
1 Attachment(s)
Try this:

PHP Code:

#include <amxmodx>

public plugin_init()
{
    
register_plugin"ChatCmdBlocker""0.1""LegacyCode" )

    
register_clcmd"say""handleBlockCmdOutput" )
    
register_clcmd"say_team""handleBlockCmdOutput" )
}

public 
handleBlockCmdOutputid )
{
    new const 
a_ChatCommands[][] =
    {
        
"thetime",
        
"/rank",
        
"/top15",
        
"/hp",
        
"/nextmap",
        
"/timeleft"
    
}

    new 
s_Message[192], s_ChatCmd[16]
    
read_argss_Messagecharsmaxs_Message ) )
    
remove_quotess_Message )
    
trims_Message )

    if ( !
s_Message[0] || !is_user_connectedid ) )
        return 
PLUGIN_HANDLED

    copyc
s_ChatCmdcharsmaxs_ChatCmd ), s_Message' ' )

    for ( new 
isizeof a_ChatCommandsi++ )
    {
        if ( 
equalis_ChatCmda_ChatCommands[i] ) )
            return 
PLUGIN_HANDLED
    
}

    return 
PLUGIN_CONTINUE


Place it at the very start of the "Custom" section in plugins.ini:

Code:

; Custom - Add 3rd party plugins here
block_chat.amxx
...

I hope this is a good attempt at the problem, I'm new to this.
Let me know if it works!

- LegacyCode

asw32 04-12-2017 19:09

Re: Hiding commands in public chat
 
Quote:

Originally Posted by LegacyCode (Post 2511496)
Try this:

PHP Code:

#include <amxmodx>

public plugin_init()
{
    
register_plugin"ChatCmdBlocker""0.1""LegacyCode" )

    
register_clcmd"say""handleBlockCmdOutput" )
    
register_clcmd"say_team""handleBlockCmdOutput" )
}

public 
handleBlockCmdOutputid )
{
    new const 
a_ChatCommands[][] =
    {
        
"thetime",
        
"/rank",
        
"/top15",
        
"/hp",
        
"/nextmap",
        
"/timeleft"
    
}

    new 
s_Message[192], s_ChatCmd[16]
    
read_argss_Messagecharsmaxs_Message ) )
    
remove_quotess_Message )
    
trims_Message )

    if ( !
s_Message[0] || !is_user_connectedid ) )
        return 
PLUGIN_HANDLED

    copyc
s_ChatCmdcharsmaxs_ChatCmd ), s_Message' ' )

    for ( new 
isizeof a_ChatCommandsi++ )
    {
        if ( 
equalis_ChatCmda_ChatCommands[i] ) )
            return 
PLUGIN_HANDLED
    
}

    return 
PLUGIN_CONTINUE


Place it at the very start of the "Custom" section in plugins.ini:

Code:

; Custom - Add 3rd party plugins here
block_chat.amxx
...

I hope this is a good attempt at the problem, I'm new to this.
Let me know if it works!

- LegacyCode

Thanks so much for your effort. And thank you to the other poster as well.

Using yours, Legacy, it works in that it doesn't display the command being said. But for example, when someone types "thetime", it still displays the time to everyone in the server. I want it to only show up to the person who typed it. How would that be done? Also, instead of "/nextmap" and "/timeleft" I need it to work for "nextmap" and "timeleft" instead.

asw32 04-12-2017 19:42

Re: Hiding commands in public chat
 
Nevermind, I figured out how to do /nextmap and /timeleft myself, I just read yours and edited accordingly.

Anyone know how to make it so thetime, nextmap, timeleft only display the result to the typer?

fysiks 04-12-2017 21:47

Re: Hiding commands in public chat
 
Quote:

Originally Posted by asw32 (Post 2511666)
Anyone know how to make it so thetime, nextmap, timeleft only display the result to the typer?

You'll need to edit those plugins.

EFFx 04-12-2017 22:00

Re: Hiding commands in public chat
 
Add on client_print or whatever prints the message, id instead of 0.

asw32 04-13-2017 00:38

Re: Hiding commands in public chat
 
Where do I add that on? I'm trying to learn how to do some of this stuff, I'm not real good at it. Where should I look to add on client_print? And what does that do?

fysiks 04-13-2017 09:26

Re: Hiding commands in public chat
 
Quote:

Originally Posted by asw32 (Post 2511690)
Where do I add that on? I'm trying to learn how to do some of this stuff, I'm not real good at it. Where should I look to add on client_print? And what does that do?

You won't add anything. You need to edit the plugin that produces the message and change the print statement to send it only to the person who typed the command. That is often a client_print() with a 0 and often the variable for the player who used the command is id (this is not always the case, you just have to look at the code to see what the variable names are).

asw32 04-13-2017 19:55

Re: Hiding commands in public chat
 
thanks everyone, really appreciate it


All times are GMT -4. The time now is 17:57.

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