Code:
/********************************************************************************
* Plugin name: Ban myg0ts.
* Made by: Dygear
* Modules required:
* Warranties : This file is provided as is (no warranties).
********************************************************************************/
#include <amxmodx>
public plugin_init() {
register_plugin("Ban myg0ts.","0.1","Dygear")
}
public client_connect(id) {
checkid(id)
return PLUGIN_HANDLED
}
public client_infochanged(id) {
checkid(id)
return PLUGIN_HANDLED
}
public checkid(id) {
new dyAuthID[32], dyUserIP[32], dyUserName[32]
get_user_authid( id, dyAuthID, 31 )
get_user_ip( id, dyUserIP, 31, 1 )
get_user_name( id, dyUserName, 31 )
if( containi( dyUserName,"myg0t" )!=-1 ){
server_cmd( "banid ^"%d^" ^"%s^" kick;wait;writeid", 0, dyAuthID )
server_cmd( "banip ^"%d^" ^"%s^" writeip, 0, dyUserIP" )
log_amx( "Player '%s' Has Been Permanently Banned Due To Him Being In myg0t!", dyUserName )
}
}
These are include files, they take informaion from the include forlder and to find the syntax of that command.
#include <%name%> will read from %name%.inc. For example, if you include <amxmodx> then it will read from amxmodx.inc
Code:
public plugin_init() {
register_plugin("Ban myg0ts.","0.1","Dygear")
}
Function is called just after server activation.
Good place for configuration loading, commands and cvars registration.
In Plugin_init() you will allways see register_plugin().
register_plugin("[Plugin Name]","[Version]","[Author]")
Code:
public client_connect(id) {
checkid(id)
return PLUGIN_HANDLED
}
This is called when the client 1st connects to the server, checkid(id) tells this to go down in to code and find checkid(id).
Code:
public client_infochanged(id) {
checkid(id)
return PLUGIN_HANDLED
}
Whenever player info is changed, this function is called.
When the client changes there (fe) name, client_infochanged() is called.
Once more, checkid(id) tells this to go down in to code and find checkid(id).
Code:
public checkid(id) {
new dyAuthID[32], dyUserIP[32], dyUserName[32]
get_user_authid( id, dyAuthID, 31 )
get_user_ip( id, dyUserIP, 31, 1 )
get_user_name( id, dyUserName, 31 )
// More Code Here
}
This is the meat of the code, the new dyAuthID[32], dyUserIP[32], dyUserName[32] are made so we can wight to that, 32 for 32bits.
get_user_authid(index, authid[] ,len); This returns the SteamID/WonID depending on what version of CS your running.
get_user_ip(index,ip[],len, without_port = 0); Returns ip.
get_user_name(index,name[],len); Returns player name.
Code:
if( containi( dyUserName,"myg0t" )!=-1 ){
server_cmd( "banid ^"%d^" ^"%s^" kick;wait;writeid", 0, dyAuthID )
server_cmd( "banip ^"%d^" ^"%s^" writeip, 0, dyUserIP" )
log_amx( "Player '%s' Has Been Permanently Banned Due To Him Being In myg0t!", dyUserName )
}
If; Performs conditional processing in small plugins.
containi(const source[],const string[]); (for this plugin) It checks if dyUserName contains the string "myg0t" and does not metter if its uper or lower case.
server_cmd(const command[],{Float,_}:...); Executes command on a server console.
log_amx(const string[], {Float,_}:...); Logs something into the current amx logfile.
Summary :
If a user connects with a name contaning myg0t, or they change there name to something that contanes myg0t, ban them and log that "Player '[Name of the offender]' Has Been Permanently Banned Due To Him Being In myg0t!".