AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   * How Kick a Player? * (https://forums.alliedmods.net/showthread.php?t=129839)

D3v1L 06-17-2010 12:13

* How Kick a Player? *
 
Hello all!

Who can help me and fix it? I need, if an admin say in chat, but not in console:
  • .kick <username> - and <username> will be kicked.

I have scripted, but it doesn't works. Here is a code:
Code:

/* Edited Code */
/* ********* */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN    "Kick Plugin"
#define VERSION    "0.1"
#define AUTHOR    "D3v1L"

#define ACCESS    ADMIN_KICK
#define PREFIX    "[NEF]"

new g_kickCmd[] = ".kick"
new g_fCvarMsg

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_clcmd("say", "cmd_Kick")
    g_fCvarMsg = register_cvar("amx_show_msg_1all_0id", "1")
}

public cmd_Kick(id)
{
    new args[32]
    read_args(args, charsmax(args))

    new target = cmd_target(id, args, CMDTARGET_OBEY_IMMUNITY | CMDTARGET_ALLOW_SELF)

    if (!target)
        return PLUGIN_CONTINUE

    new admin_name[32], target_name[32]
    get_user_name(id, admin_name, charsmax(admin_name))
    get_user_name(target, target_name, charsmax(target_name))

    new fix[192]
    format(fix, charsmax(fix), "%s", target)


    if (containi(args, g_kickCmd) != -1 && containi(args, fix) != -1)
    {
        if (!access(id, ACCESS))
        {
            client_print(id, print_chat, "%s You have no access to that command.", PREFIX)
            return PLUGIN_HANDLED
        }

        server_cmd("kick #%d", get_user_userid(target))
        client_print(get_pcvar_num(g_fCvarMsg) ? 0 : id, print_chat, "%s Admin %s: kicked %s", PREFIX, admin_name, target_name)
    }

    return PLUGIN_CONTINUE
}

Sorry for my very bad english.
Thanks for all!

Alucard^ 06-17-2010 12:26

Re: * How Kick a Player? *
 
Code:
    if (!cmd_access(id, level, cid, 2))     {         client_print(id, print_chat, "%s You have no access to tha command.")         return PLUGIN_HANDLED     }

With this, if someone don't have the ACCESS and don't send the second parameter, the say is blocked, so that is wrong. You have to check first if the first paramter is ".kick"

Code:
    new args[32]     read_args(args, charsmax(args))     new target = cmd_target(id, args, CMDTARGET_OBEY_IMMUNITY | CMDTARGET_ALLOW_SELF)

With read_args( ) you are getting a line of all arguments (all the message said by player).

You can't use cmd_target( ) for that.

D3v1L 06-17-2010 14:23

Re: * How Kick a Player? *
 
Thanks for the explanation.
So, do you can fix it to go "Kick Plugin" working?

Alucard^ 06-17-2010 14:53

Re: * How Kick a Player? *
 
Well, sry but you are in Scripting help, so... you have to learn, if you want a request you have the request forum.

First fix the things that i mentioned, and then post your code.

D3v1L 06-17-2010 15:44

Re: * How Kick a Player? *
 
I have fixed (with access flags), that you mentioned, view first post.
And now, do you can help me?

fysiks 06-17-2010 18:08

Re: * How Kick a Player? *
 
Ok, you can look here for one method. Or possibly use this if you plan on more commands in chat.

D3v1L 06-18-2010 04:35

Re: * How Kick a Player? *
 
Thank you, fysiks. I'll try this, although I liked my code. But thanks. :)

fysiks 06-18-2010 19:33

Re: * How Kick a Player? *
 
Quote:

Originally Posted by D3v1L (Post 1212262)
although I liked my code.

Well, if you get it to work then that's great. I was just offering some ways that I know work :).


All times are GMT -4. The time now is 14:48.

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