Raised This Month: $ Target: $400
 0% 

My first plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SpArTaNN
New Member
Join Date: Jul 2009
Old 07-31-2009 , 09:59   My first plugin
Reply With Quote #1

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
SpArTaNN is offline
biscuit628
Senior Member
Join Date: Jun 2007
Location: 香港HongKong
Old 07-31-2009 , 10:09   Re: My first plugin
Reply With Quote #2

Quote:
Originally Posted by SpArTaNN View Post
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
why don't just use amx_kick?
__________________
My Plugins

C4man with fun

Sniper Skill bonus
-------------------------
Sorry for my poor English!
biscuit628 is offline
SpArTaNN
New Member
Join Date: Jul 2009
Old 07-31-2009 , 10:18   Re: My first plugin
Reply With Quote #3

Quote:
Originally Posted by biscuit628 View Post
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?
SpArTaNN is offline
Alucard^
AMXX Moderator: Others
Join Date: Sep 2007
Location: Street
Old 07-31-2009 , 10:23   Re: My first plugin
Reply With Quote #4

Quote:
Originally Posted by SpArTaNN View Post
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
__________________
Approved Plugins - Steam Profile

Public non-terminated projects:
All Admins Menu, HLTV parameters, Subnick,
Second Password (cool style), InfoZone,
Binary C4 plant/defuse, and more...

Private projects:
NoSpec (+menu), NV Surf Management,
PM Adanved System, KZ longjump2, and more...
Alucard^ is offline
Send a message via Skype™ to Alucard^
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-31-2009 , 18:56   Re: My first plugin
Reply With Quote #5

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 .
__________________
fysiks is offline
SpArTaNN
New Member
Join Date: Jul 2009
Old 08-01-2009 , 08:52   Re: My first plugin
Reply With Quote #6

Quote:
Originally Posted by fysiks View Post
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 Now I know some function
Thanks everybody for help
SpArTaNN is offline
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 18:19.


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