Raised This Month: $ Target: $400
 0% 

chat kick command with reason


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
reinert
Veteran Member
Join Date: Feb 2007
Old 05-09-2011 , 08:31   chat kick command with reason
Reply With Quote #1

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)
reinert is offline
lis_16
Senior Member
Join Date: Feb 2008
Old 05-09-2011 , 08:44   Re: chat kick command with reason
Reply With Quote #2

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
lis_16 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-09-2011 , 14:49   Re: chat kick command with reason
Reply With Quote #3

Quote:
Originally Posted by lis_16 View Post
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
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.
__________________
fysiks is offline
lis_16
Senior Member
Join Date: Feb 2008
Old 05-09-2011 , 16:43   Re: chat kick command with reason
Reply With Quote #4

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 ;]
lis_16 is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 05-09-2011 , 17:13   Re: chat kick command with reason
Reply With Quote #5

I suggest you just use this plugin.
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
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 04:19.


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