Forum
Gag - Printable Version

+- Forum (https://dm20.net/forum)
+-- Forum: Scripting (https://dm20.net/forum/forumdisplay.php?fid=5)
+--- Forum: Showcase (https://dm20.net/forum/forumdisplay.php?fid=6)
+--- Thread: Gag (/showthread.php?tid=8)



Gag - marcudaniel1337 - 07-28-2024

An useful tool for admins to ban players from chatting. Usage: amx_gag <name>, amx_ungag <name>

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

public plugin_init()
{
    register_plugin("Gag", "1.0", "sToP !")

    register_concmd("amx_gag", "gag", ADMIN_KICK, "<player>")
    register_concmd("amx_ungag", "ungag", ADMIN_KICK, "<player>")

    register_clcmd("say", "chat_manager")
    register_clcmd("say_team", "chat_manager")
    register_clcmd("voicecomm", "chat_manager")
}

public gag(id, level, cid)
{
    if( cmd_access(id, level, cid, 2) )
    {
        new arg[32];
        read_argv ( 1 , arg , charsmax(arg) )
        new target = cmd_target ( id , arg , CMDTARGET_OBEY_IMMUNITY | CMDTARGET_ALLOW_SELF | CMDTARGET_ONLY_ALIVE )

        if( target )
        {
            if ( is_user_admin(target) )
            {
                client_print(id, print_console, "[HL.DM20.NET] User is admin, no changes done.")
                return PLUGIN_HANDLED
            }

            new flags = read_flags("m")
            set_user_flags(target, flags)
            client_print(id, print_console, "[HL.DM20.NET] Player has been gagged.")
            }
        }

    return PLUGIN_HANDLED
}

public ungag(id, level, cid)
{
    if( cmd_access(id, level, cid, 2) )
    {
        new arg[32];
        read_argv ( 1 , arg , charsmax(arg) )
        new target = cmd_target ( id , arg , CMDTARGET_OBEY_IMMUNITY | CMDTARGET_ALLOW_SELF | CMDTARGET_ONLY_ALIVE )

        if( target )
        {
            if ( is_user_admin(target) )
            {
                client_print(id, print_console, "[HL.DM20.NET] User is admin, no changes done.")
                return PLUGIN_HANDLED
            }

            new flags = read_flags("m")
            remove_user_flags(target, flags)
            client_print(id, print_console, "[HL.DM20.NET] Player has been ungagged.")
            }
        }

    return PLUGIN_HANDLED
}

public chat_manager(id)
{
    if ( is_user_admin(id) )
    {
        return PLUGIN_CONTINUE
    }

    if(get_user_flags(id) & read_flags("m"))
    {
        client_print(id, print_chat, "[HL.DM20.NET] You have gag.")
        return PLUGIN_HANDLED        
    }
    return PLUGIN_CONTINUE
}