AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   amx_kick help (https://forums.alliedmods.net/showthread.php?t=131895)

nikhilgupta345 07-10-2010 01:33

amx_kick help
 
I'm a complete newb at scripting, and I can't get my amx_kick plugin to work. I don't want the user to be able to put the userid of the user or anything. Just part of the name. When I test it out, nothing happens, it doesn't kick. Can you tell me what's wrong with the code?
Code:

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "amx_kick"
#define AUTHOR "nikhilgupta345"
#define VERSION "1.0"

public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_concmd("amx_kick", "cmd_kick", ADMIN_KICK, "<nick>")
}

public cmd_kick(id, level, cid)

{
if (!cmd_access(id, level, cid, 2))
return PLUGIN_HANDLED


new arg[32]
read_argv(1, arg, 31)

new player=cmd_target(id, arg, CMDTARGET_OBEY_IMMUNITY | CMDTARGET_ALLOW_SELF)
if(!player)
{

    console_print(id, "Cannot find player %s", arg)
}
else {
server_cmd("kick %s", arg)
}
return PLUGIN_HANDLED
}

P.S. I took some of the code from the admincmd.sma

Vechta 07-10-2010 02:15

Re: amx_kick help
 
Use Emp's Menu tutorial to find players in a menu its better..

nikhilgupta345 07-10-2010 02:26

Re: amx_kick help
 
Yes, but I would still like to know how find a player when im making concmd's. Without having to make a menu.

fysiks 07-10-2010 02:32

Re: amx_kick help
 
Quote:

Originally Posted by nikhilgupta345 (Post 1233894)
I'm a complete newb at scripting, and I can't get my amx_kick plugin to work. I don't want the user to be able to put the userid of the user or anything. Just part of the name. When I test it out, nothing happens, it doesn't kick. Can you tell me what's wrong with the code?

P.S. I took some of the code from the admincmd.sma

You still have to use the user id to kick the person like it is done in admincmd.sma. To disallow a person from putting in a user id you would have to use a modified version of cmd_target().

Oh, and cmd_target() will already print a message if the player doesn't exist. You don't need to duplicate that.

Quote:

Originally Posted by Vechta (Post 1233906)
Use Emp's Menu tutorial to find players in a menu its better..

OMG, don't convince people that menus are better, they are not. I never use menus when playing in game (other than voting for an option which is forced upon me lol).

nikhilgupta345 07-10-2010 02:42

Re: amx_kick help
 
And what exactly is the modified version of cmd_target?

fysiks 07-10-2010 02:45

Re: amx_kick help
 
Quote:

Originally Posted by nikhilgupta345 (Post 1233922)
And what exactly is the modified version of cmd_target?

You have to modify it to work as you want it. You can get the code from amxmisc.inc and rename the function and modify it to work how you want it to work.

I think you can just remove this line for your own version of it:

Code:

player = find_player("k",str_to_num(arg[1]));

nikhilgupta345 07-10-2010 10:17

Re: amx_kick help
 
Why are each of the parameters different? Like it gets the authid twice and the name twice. Why is that? This is from admincmd.sma

Code:

get_user_authid(id, authid, 31)
    get_user_authid(player, authid2, 31)
    get_user_name(player, name2, 31)
    get_user_name(id, name, 31)


fysiks 07-10-2010 12:50

Re: amx_kick help
 
Quote:

Originally Posted by nikhilgupta345 (Post 1234258)
Why are each of the parameters different? Like it gets the authid twice and the name twice. Why is that? This is from admincmd.sma

Code:

get_user_authid(id, authid, 31)
    get_user_authid(player, authid2, 31)
    get_user_name(player, name2, 31)
    get_user_name(id, name, 31)


If you read through the code you will see that one is for the person executing the command and the other is the target player (the one being kicked).

nikhilgupta345 07-10-2010 14:27

Re: amx_kick help
 
Oh, I see it now. Thanks so much


All times are GMT -4. The time now is 07:08.

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