AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   My first plugin (https://forums.alliedmods.net/showthread.php?t=98971)

SpArTaNN 07-31-2009 09:59

My first plugin
 
Hey guys .... This is my first plugin ....... I want to tell me how I can do to disconnect a player with reason ... and the player disconnected to see the reason and admin which disconnected.

Quote:

/*This plugin was made by SpArTaNN !
*With this plugin you can disconnect a specified player !
*Command: amx_disconnect
HF*/

#include <amxmodx>
#include <amxmisc>
public plugin_init()
{
register_plugin("Disconnect Player","1.0","SpArTaNN");
register_concmd("amx_disconnect","disconnect_ cmd",ADMIN_KICK,"- <jucator>");
}
public disconnect_cmd(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,9);
if(!player) return PLUGIN_HANDLED;
new adminname[32],playername[32];
get_user_name(id,adminname,31);
get_user_name(player,playername,31);

client_cmd(player,"disconnect"); //
client_print(0,print_chat,"Admin %s: l-a deconnect pe %s",adminname,playername);

return PLUGIN_HANDLED;
}
sry for my english :oops:

biscuit628 07-31-2009 10:09

Re: My first plugin
 
Quote:

Originally Posted by SpArTaNN (Post 886570)
Hey guys .... This is my first plugin ....... I want to tell me how I can do to disconnect a player with reason ... and the player disconnected to see the reason and admin which disconnected.


sry for my english :oops:

why don't just use amx_kick?

SpArTaNN 07-31-2009 10:18

Re: My first plugin
 
Quote:

Originally Posted by biscuit628 (Post 886578)
why don't just use amx_kick?

Because I wanted to make my first plugin and I wanted to know if it's good .....
That is my first plugin for beginner

OFF: Do not know where they can learn all the functions? :)

Alucard^ 07-31-2009 10:23

Re: My first plugin
 
Quote:

Originally Posted by SpArTaNN (Post 886588)
Because I wanted to make my first plugin and I wanted to know if it's good .....
That is my first plugin for beginner

OFF: Do not know where they can learn all the functions? :)

http://www.amxmodx.org/funcwiki.php

fysiks 07-31-2009 18:56

Re: My first plugin
 
To make the disconnected player see some info you need to use the Half-Life engine command "kick" with a reason.

Also, very important, Learn to indent your code. It makes it much more easy for us (or anyone) to read and understand code.

Here ya go, try this:

PHP Code:

/*This plugin was made by SpArTaNN !
*With this plugin you can disconnect a specified player !
*Command: amx_disconnect
HF*/

#include <amxmodx>
#include <amxmisc>
public plugin_init()
{
    
register_plugin("Disconnect Player","1.0","SpArTaNN");
    
register_concmd("amx_disconnect","disconnect_ cmd",ADMIN_KICK,"- <jucator>");
}
public 
disconnect_cmd(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,9);
    if(!
player)
        return 
PLUGIN_HANDLED;

    new 
adminname[32],playername[32];
    
get_user_name(id,adminname,31);
    
get_user_name(player,playername,31);
    new 
userid_target get_user_userid(player)

    
// client_cmd(player,"disconnect");
    
server_cmd("kick #%d ^"%s^""userid_target"You have been kicked by an admin")
    
client_print(0,print_chat,"Admin %s: l-a deconnect pe %s",adminname,playername);

    return 
PLUGIN_HANDLED;


I added the "server_cmd()" command and commented your client_cmd() command. Oh, and indented your code :).

SpArTaNN 08-01-2009 08:52

Re: My first plugin
 
Quote:

Originally Posted by fysiks (Post 887007)
To make the disconnected player see some info you need to use the Half-Life engine command "kick" with a reason.

Also, very important, Learn to indent your code. It makes it much more easy for us (or anyone) to read and understand code.

Here ya go, try this:

PHP Code:

/*This plugin was made by SpArTaNN !
*With this plugin you can disconnect a specified player !
*Command: amx_disconnect
HF*/

#include <amxmodx>
#include <amxmisc>
public plugin_init()
{
    
register_plugin("Disconnect Player","1.0","SpArTaNN");
    
register_concmd("amx_disconnect","disconnect_ cmd",ADMIN_KICK,"- <jucator>");
}
public 
disconnect_cmd(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,9);
    if(!
player)
        return 
PLUGIN_HANDLED;

    new 
adminname[32],playername[32];
    
get_user_name(id,adminname,31);
    
get_user_name(player,playername,31);
    new 
userid_target get_user_userid(player)

    
// client_cmd(player,"disconnect");
    
server_cmd("kick #%d ^"%s^""userid_target"You have been kicked by an admin")
    
client_print(0,print_chat,"Admin %s: l-a deconnect pe %s",adminname,playername);

    return 
PLUGIN_HANDLED;


I added the "server_cmd()" command and commented your client_cmd() command. Oh, and indented your code :).

Thanks :D:D Now I know some function :D
Thanks everybody for help :D


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

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