AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   chat kick command with reason (https://forums.alliedmods.net/showthread.php?t=156598)

reinert 05-09-2011 08:31

chat kick command with reason
 
Hey, how to make a chat kick command with reason ? Right now I've this:

PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <colorchat>

#define PLUGIN "Plugin name"
#define VERSION "1.0"
#define AUTHOR "ADDiNOL"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("say ""hook_say")
}

public 
hook_say(id)
{
    new 
arg[64];
    
read_args(argcharsmax(arg));
    
remove_quotes(arg);
    
    new 
cmd[10], rest[54];
    
parse(argcmdcharsmax(cmd), restcharsmax(rest));
    if(
get_user_flags(id) & ADMIN_BAN)
    {
        if(
equali(cmd"!kick") || equali(cmd"!k"))
        {    
            new 
player cmd_target(idrestCMDTARGET_OBEY_IMMUNITY);
            
            new 
name[35];
            
get_user_name(playernamecharsmax(name));
            
            if(
player)
            {
                
client_cmd(player"disconnect;echo ^"kicked^"")
                switch(
cs_get_user_team(player))
                {
                    case 
CS_TEAM_CTclient_print_color(0BLUE"^4[ INFO ]^1 Admin kicked player ^3^"%s^""name)
                    case 
CS_TEAM_Tclient_print_color(0RED"^4[ INFO ]^1 Admin kicked player ^3^"%s^""name)
                    case 
CS_TEAM_SPECTATORCS_TEAM_UNASSIGNEDclient_print_color(0GREY"^4[ INFO ]^1 Admin kicked player ^3^"%s^""name)
                }
            }
            else
            {
                
client_print_color(idDontChange"^4[ INFO ]^1 Player ^3^"%s^"^1 not found"name)
            }
            return 
PLUGIN_HANDLED_MAIN;
        }
    }
    return 
PLUGIN_CONTINUE;


Command should be !kick player_name reason here.

like:
!kick reinert Use of abusive language (Swearing)

lis_16 05-09-2011 08:44

Re: chat kick command with reason
 
I think you want to get cmd_target with player name and reason, so it won't work, you should parse from rest player name and the reason and then get cmd_target. But I'm not good at this like others :P

fysiks 05-09-2011 14:49

Re: chat kick command with reason
 
Quote:

Originally Posted by lis_16 (Post 1466124)
I think you want to get cmd_target with player name and reason, so it won't work, you should parse from rest player name and the reason and then get cmd_target. But I'm not good at this like others :P

The variable "rest" will only contain the name in this case (see how parse actually works).

@reinert

You should use strbreak() for this situation:

PHP Code:

strbreak(szArgszCmdcharsmax(szCmd), szArgcharsmax(szArg))
strbreak(szArgszTargetcharsmax(szTarget), szReasoncharsmax(szReason)) 

Also, use server_cmd("kick #%d ^"%s^"", get_user_userid(player), szReason) because it will show the reason in the kick dialog. Not everyone uses/knows about the console. They can't not read it this way.

lis_16 05-09-2011 16:43

Re: chat kick command with reason
 
Oh, i see, it separate only the first word, and miss the rest. But in this case he left his reason typed in say if he don't use strbreak. fysiks big + for u ;]

Emp` 05-09-2011 17:13

Re: chat kick command with reason
 
I suggest you just use this plugin.


All times are GMT -4. The time now is 04:19.

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