Znalazlem ostatnio plugin "ClientChecker". Ma on za zadanie sprawdzac u graczy, cvary, rate, itp. oraz kickowac za zbyt duzy ping.
Link do pluginu: http://amxx.pl/topic...nt-checker-101/
Chcialbym aby ktos kto ogarnia to wszystko lub korzystal z pluginu wytlumaczyl mi jakich ustawien (komend) dokladnie pilnuje i w jaki sposob (kickuje, zmienia czy co)
chcialbym tez dowiedziec sie jak mozna zmodyfikowac ten kod by pilnowal takze interpu w danym przedziale oraz ew. cl_rate (wartosc w okolicach 20000).
/* Client Checker What does it do? It can check client rates It can check client CVARS which can be configured in a config file It can show a (dis)connect message from clients (possibility to show from which country the player connects) It can kick players with high ping (Used / Modified the HPK code) CVARS: * cc_connectmsg - Shows who is (dis)connecting * cc_showgeoip - Shows connecting player country * cc_ratecheck - Check client rates * cc_cvarcheck - Check client cvars (using the config file) * cc_pingcheck - High ping kick * cc_writelog - Write invalid client settings and Admin actions to a log file * cc_chkdelay - Delay between checks in seconds * cc_maxping - Maximum allowed ping * cc_maxpingwarns - Ping check cycles before kick * cc_minupdaterate - Minimum allowed cl_updaterate * cc_mincmdrate - Minimum allowed cl_cmdrate * cc_minrate - Minimum allowed rate * cc_messagetype - Show message about invalid settings to: + 0 = Nobody + 1 = AMX Admins + 2 = Checked Player + AMX Admins + 3 = All players * cc_agreemenu - This will show the agreement menu * cc_agreetimeout - How long the client has to accept * cc_maxitems - This is to set how many cvars will be checked in one check cycle * cc_writecfg - Write changes to the client checker config file * cc_maxinvalid - Maximum allowed invalid changes of settings from a client before they will be kicked * cc_showinfo - Show info in client console * cc_realoadcfg - Reload the cvar checker config file * cc_daystosave - How long the agreement of a client should be saved CVAR Check Config: cvar { max_value - Use this for numeric values only min_value - Use this for numeric values only set_value - Value that will replace the invalid value (when using '*' as value it will set to the avg of the min and max value) equal_to - Value must be equal to this, if not change it to the set_value !equal_to - Value can not be equal to this, if it is change it to the set_value contains - Value contains this. Change value to set_value (use comma to use spererate values) !contains - Value does not contain this. Change value to set_value (use comma to use spererate values) regex - Use a regex pattern (http://www.troubleshooters.com/codecorn/littperl/perlreg.htm } Examples: gl_polyoffset { max_value 4 set_value 4 } max_smokepuffs { min_value 120 set_value 120 } name { contains ****,shit,cunt set_value BANNED_NAME } Requirements: This plugin requires amxmodx 1.7 or later to work! Change log: 1.0.1: - Changed the CVAR checker config (it will still read its old config) - Agree save is now using nvault to store steamid's. And it will remove entries older than 14 days by default (only if the SQL version is not used). 1.0.0: - Added SQL support 0.0.9: - Bugfix: Always showing agreement menu even while steamid was in saved list! - Did some optimization 0.0.8 Optimized: - Optimized the code - Added option to show the info in console when client joins the server (cc_showinfo) 0.0.8: - Bugfix: now using get_players instead of get_playersnum so all messages should be working now. 0.0.7: - Changed the maximum save value to 512 (this is defined in the source code and can be changed to use a low or higher number) - Added quick cvar check when a client joins the server. - Added option to auto kick clients that keep changing there settings to an invalid value. (The number of invalid changes can be set in the config. And will only start after the first check). - Added option to automaticly write admin changes to the config file. 0.0.6: - Added option to show a agreement menu before the client checker starts. If the user doesnt agree he/she will be removed from the server. - Added option to keep a little save file of the users who agreed (up to 64 records) - Added a limit to maximum cvar checks in one check cycle. This is to prevent flooding with big cvar check lists. The maximum items to check can be set with "cc_maxitems". 0.0.5: - Small bug fix with geoip when a bot joins the server. Also added some code to check if the country isnt matching error. 0.0.4: - Fixed the cc_showgeoip cvar (it did not check if it was en/dis-abled) - Added messages for High ping kick - Added pcvars to make it faster 0.0.3: - Fixed bug in Cvar checker - Code revision (cleaned up some of the mess) 0.0.2: Public version 0.0.1: Private test version */ // Log file new const logfile[] = "ClientChecker.log" // Config file new const cfgfile[] = "ClientChecker.cfg" // CVARs config file new const cvarsfile[] = "chk_cvars.cfg" // Uncomment next line to make use of the SQL stuff #define USESQL // Maximum cvar items 256 items should be enough #define MAXITEMS 256 /*************************/ /* Code starts from here */ /*************************/ #include <amxmodx> #include <amxmisc> #include <geoip> #include <nvault> #include <regex> #if defined USESQL #include <dbi> #define VERSION "1.0.1-SQL" #else #define VERSION "1.0.1" #endif #define PLUGIN "Client Checker" #define AUTHOR "Crazed" new iPingkick[33] // High Ping count new menu_timer[33] // Agree menu timer new cvar_chkitem[33] // Current checked item (for fast chk) new client_isettings[33] // Invalid settings count new cvars_buf[MAXITEMS+1][64] // Holds all CVARs that needs to be checked new cvar_items // CVAR item count new bool:b_geoip // Holds true when GeoIP module is loaded new keys = (1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<6|1<<7|1<<8|1<<9) // Menu keys new bool:b_oldcfg // if set to true still use old cvar check stuff new g_configfile[128] new g_chkcvarfile[128] #if !defined USESQL new const g_savefile[] = "agreesavefile" #endif #if defined USESQL new Sql:sql new sql_host[256], sql_user[128], sql_pass[128], sql_dbname[128] // SQL pcvars new cvar_sqlhost, cvar_sqluser, cvar_sqlpass, cvar_sqldbname #else new cvar_daystosave #endif // pcvars new cvar_connectmsg, cvar_ratecheck, cvar_pingcheck, cvar_cvarcheck, cvar_messagetype, cvar_showgeoip, cvar_writelog, cvar_chkdelay, cvar_maxping, cvar_maxpingwarns, cvar_minupdaterate, cvar_mincmdrate, cvar_minrate, cvar_agreetimeout, cvar_agreemenu, cvar_maxitems, cvar_maxinvalid, cvar_writecfg, cvar_showinfo // enable / disable cvars #define AdminCMDs1 9 static const array_enable_disable[AdminCMDs1][] = { "cc_connectmsg", "cc_ratecheck", "cc_pingcheck", "cc_cvarcheck", "cc_showgeoip", "cc_writelog", "cc_agreemenu", "cc_writecfg", "cc_showinfo" } // Other cvars #define AdminCMDs2 11 static const array_cmd_cvars[AdminCMDs2][] = { "cc_chkdelay", "cc_maxping", "cc_maxpingwarns", "cc_minupdaterate", "cc_mincmdrate", "cc_minrate", "cc_messagetype", "cc_agreetimeout", "cc_maxitems", "cc_maxinvalid", "cc_daystosave" } // Initiate Plugin public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR) cvar_connectmsg = register_cvar("cc_connectmsg", "1") cvar_ratecheck = register_cvar("cc_ratecheck", "1") cvar_pingcheck = register_cvar("cc_pingcheck", "1") cvar_cvarcheck = register_cvar("cc_cvarcheck", "1") cvar_messagetype = register_cvar("cc_messagetype", "1") cvar_showgeoip = register_cvar("cc_showgeoip", "1") cvar_writelog = register_cvar("cc_writelog", "1") cvar_chkdelay = register_cvar("cc_chkdelay", "3") cvar_maxping = register_cvar("cc_maxping", "100") cvar_maxpingwarns = register_cvar("cc_maxpingwarns", "5") cvar_minupdaterate = register_cvar("cc_minupdaterate", "60") cvar_mincmdrate = register_cvar("cc_mincmdrate", "60") cvar_minrate = register_cvar("cc_minrate", "15000") cvar_agreetimeout = register_cvar("cc_agreetimeout", "30") cvar_agreemenu = register_cvar("cc_agreemenu", "1") cvar_maxitems = register_cvar("cc_maxitems", "5") cvar_maxinvalid = register_cvar("cc_maxinvalid", "10") cvar_writecfg = register_cvar("cc_writecfg", "1") cvar_showinfo = register_cvar("cc_showinfo", "1") #if defined USESQL cvar_sqlhost = register_cvar("cc_sqlhost", "localhost:3306") cvar_sqluser = register_cvar("cc_sqluser", "my_user") cvar_sqlpass = register_cvar("cc_sqlpass", "my_pass") cvar_sqldbname = register_cvar("cc_sqldbname", "ClientChecker") #else cvar_daystosave = register_cvar("cc_daystosave", "14") #endif // agreement menu register_menucmd(register_menuid("\yClient Checker"), 1023, "cc_menuhandle") new i // Register Admin Commands for (i = 0;i < AdminCMDs1;i++) register_concmd(array_enable_disable[i], "Admin_Commands", ADMIN_CFG) for (i = 0;i < AdminCMDs2;i++) register_concmd(array_cmd_cvars[i], "Admin_Commands", ADMIN_CFG) register_concmd("cc_reloadcfg", "Admin_Commands", ADMIN_CFG) // Check if the GeoIP Module is loaded if (is_module_loaded("geoip") != -1) b_geoip = true } // Plugin Configure public plugin_cfg() { new cfgdir[32] // Load CFG file get_configsdir(cfgdir, 31) formatex(g_configfile, 63, "%s/%s", cfgdir, cfgfile) if (file_exists(g_configfile)) { server_print("[Rzeznia.eu] Ladowanie %s", cfgfile) server_cmd("exec %s", g_configfile) } // Load cvars + settings to buffer formatex(g_chkcvarfile, 63, "%s/%s", cfgdir, cvarsfile) if (file_exists(g_chkcvarfile)) { server_print("[Rzeznia.eu] Ladowanie %s", cvarsfile) load_cvarsconfig() } #if !defined USESQL // Clear old entries new vault = nvault_open(g_savefile) nvault_prune(vault, 0, get_systime() - (get_pcvar_num(cvar_daystosave)*86400)) nvault_close(vault) #endif } #if !defined USESQL // Write Save file Write_AgreeSave(id) { new auth[35] get_user_authid(id, auth, 34) new vault = nvault_open(g_savefile) nvault_set(vault, auth, "1") nvault_close(vault) } // Check if user has agreed in the past Check_AgreeSave(id) { new auth[35], bool:out, timestamp, value[2] get_user_authid(id, auth, 34) new vault = nvault_open(g_savefile) if (nvault_lookup(vault, auth, value, sizeof(value)-1, timestamp)) { out = true nvault_touch(vault, auth) } nvault_close(vault) return out } #endif // Client left the server public client_disconnect(id) { // Print message about disconnecting user if enabled if (get_pcvar_num(cvar_connectmsg)) { new name[32] get_user_name(id, name, 31) client_print(0, print_chat, "%s, disconnected.", name) } // Remove checker task if (task_exists(id)) remove_task(id) return PLUGIN_CONTINUE } // Client put in server public client_putinserver(id) { new is_bot = is_user_bot(id) new is_hltv = is_user_hltv(id) // Print message about connecting user if enabled if (get_pcvar_num(cvar_connectmsg)) { new name[32] get_user_name(id, name, 31) // Use GeoIP Module if it is loaded if (b_geoip && get_pcvar_num(cvar_showgeoip) && !is_bot && !is_hltv) { // Check the GeoIP for country new country[46], ip[33] get_user_ip(id, ip, 32) geoip_country(ip, country, 45) if (!equali(country, "error")) client_print(0, print_chat, "%s, connected. (%s)", name, country) else client_print(0, print_chat, "%s, connected.", name) } else client_print(0, print_chat, "%s, connected.", name) } iPingkick[id] = 0 // Reset ping kick counter cvar_chkitem[id] = 0 // Reset invalid settings counter if (!is_bot && !is_hltv) { new param[1] param[0] = id if (get_pcvar_num(cvar_agreemenu)) { #if defined USESQL if (!sql_checkid(id)) set_task(0.5, "cc_showmenu", id, _,_, "b") else set_task(5.0, "startchk", id, param, 1) #else if (!Check_AgreeSave(id)) set_task(0.5, "cc_showmenu", id, _,_, "b") else set_task(5.0, "startchk", id, param, 1) #endif } else set_task(5.0, "startchk", id, param, 1) } return PLUGIN_CONTINUE } // Format the menu for agreement stock format_menu(id) { new menu[1024],tmp[256] formatex(tmp, sizeof(tmp)-1, "\yClient Checker (%d secs)^n^n", menu_timer[id]) // Menu Topic strcat(menu, tmp, sizeof(menu)-1) formatex(tmp, sizeof(tmp)-1, "Serwer uzywa Client Checkera do sprawdzania twoich ustwien.^n") // Menu 1st rule strcat(menu, tmp, sizeof(menu)-1) formatex(tmp, sizeof(tmp)-1, "Oznacza to ze nieprawidlowe ustawienia zostana zmienione^n") // Menu 2nd rule strcat(menu, tmp, sizeof(menu)-1) formatex(tmp, sizeof(tmp)-1, "do wartosci dopuszczalnej na serwerze.^n") // Menu 3rd rule strcat(menu, tmp, sizeof(menu)-1) formatex(tmp, sizeof(tmp)-1, "Zgadzasz sie?^n^n") // Menu 4th rule strcat(menu, tmp, sizeof(menu)-1) formatex(tmp, sizeof(tmp)-1, "1. Tak, Zgadzam sie^n") // Menu 5th rule (Agree) strcat(menu, tmp, sizeof(menu)-1) formatex(tmp, sizeof(tmp)-1, "2. Nie zgadzam sie (zostaniesz wyrzucony z serwera!)") // Menu 6th rule (Disagree) strcat(menu, tmp, sizeof(menu)-1) return menu } // Show agreement menu public cc_showmenu(id) { new team[16], teamID = get_user_team(id, team, 15); if (teamID == 1 || teamID == 2 || equal(team, "SPECTATOR")) { // remove old task if (task_exists(id)) remove_task(id) menu_timer[id] = get_pcvar_num(cvar_agreetimeout) show_menu(id, keys, format_menu(id)) set_task(1.0, "cc_updatemenu", id, _,_, "a", menu_timer[id]+1) } } // Update agreement menu public cc_updatemenu(id) { --menu_timer[id] if (menu_timer[id] < 0) { new name[32], uID = get_user_userid(id) get_user_name(id, name, 31) client_print(0, print_chat, "[Rzeznia.eu] %s, nie zaakceptowal regulaminu. (Czas minal)", name) server_cmd("kick #%d ^"Nie zaakceptowales regulaminu! (Time out)^"", uID) } else show_menu(id, keys, format_menu(id)) } // Handle the keys for agreement menu public cc_menuhandle(id, key) { switch(key) { case 0: // Agree { // Remove Menu update task if (task_exists(id)) remove_task(id) new param[1];param[0] = id startchk(param) // save agreement #if defined USESQL sql_addid(id) #else if (!Check_AgreeSave(id)) { Write_AgreeSave(id) } #endif } case 1: // Disagree { // Remove Menu update task if (task_exists(id)) remove_task(id) new name[32], uID = get_user_userid(id) get_user_name(id, name, 31) client_print(0, print_chat, "[Rzeznia.eu] %s, nie zaakceptowal regulaminu.", name) server_cmd("kick #%d ^"Nie zaakceptowales regulaminu!^"", uID) } default: // Wrong key press cc_showmenu(id) } } // Start Checks public startchk(param[]) { new id = param[0] // Print crap in console if (get_pcvar_num(cvar_showinfo)) { client_print(id, print_console, "------[ Client Checker ]------") client_print(id, print_console, "Version: %s", VERSION) client_print(id, print_console, "Sprawdzanie pingu: %s", get_num_str(cvar_pingcheck)) client_print(id, print_console, "Sprawdzanie rate: %s", get_num_str(cvar_ratecheck)) client_print(id, print_console, "Sprawdzanie cvarow: %s", get_num_str(cvar_cvarcheck)) client_print(id, print_console, "------------------------------") client_print(id, print_console, "Max Ping: %d", get_pcvar_num(cvar_maxping)) client_print(id, print_console, "Ostrzezenia: %d", get_pcvar_num(cvar_maxpingwarns)) client_print(id, print_console, "Min rate: %d", get_pcvar_num(cvar_minrate)) client_print(id, print_console, "Min updaterate: %d", get_pcvar_num(cvar_minupdaterate)) client_print(id, print_console, "Min cmdrate: %d", get_pcvar_num(cvar_mincmdrate)) client_print(id, print_console, "------------------------------") } // Ping check messages if (get_pcvar_num(cvar_pingcheck)) client_print(id, print_chat, "[Rzeznia.eu] Gracze z pingiem wyzszym niz %d zostana wyrzuceni!", get_pcvar_num(cvar_maxping)) // Run all checks before check cycle starts. set_task(0.5, "FastCheck", id, param, 1, "b") } public FastCheck(param[]) { new id = param[0] // Check rates if ((get_pcvar_num(cvar_ratecheck)) && (cvar_chkitem[id] == 0)) { query_client_cvar(id, "rate", "ClientCvarResult") query_client_cvar(id, "cl_updaterate", "ClientCvarResult") query_client_cvar(id, "cl_cmdrate", "ClientCvarResult") } // Check other cvars if (get_pcvar_num(cvar_cvarcheck)) { new left[64], right[64] strtok(cvars_buf[cvar_chkitem[id]], left, 63,right,63,' ') if (get_pcvar_num(cvar_showinfo)) client_print(id, print_console, "[Rzeznia.eu] Kontrola: %s", left) query_client_cvar(id, left, "ClientCvarResult") } if (!get_pcvar_num(cvar_cvarcheck) || (cvar_chkitem[id] >= cvar_items-1)) { cvar_chkitem[id] = 0 remove_task(id) // Set task to check every X seconds set_task(float(get_pcvar_num(cvar_chkdelay)), "CheckClient", id, param, 1, "b") return PLUGIN_HANDLED } cvar_chkitem[id]++ return PLUGIN_CONTINUE } get_num_str(pcvar) { new tmp[9] switch(get_pcvar_num(pcvar)) { case 0: tmp = "disabled" case 1: tmp = "enabled" } return tmp } public CheckClient(param[]) { new id = param[0] if (!is_user_connected(id)) { remove_task(id) return PLUGIN_HANDLED } // Ping Check if enabled if (get_pcvar_num(cvar_pingcheck)) { new ping, loss get_user_ping(id, ping, loss) if (ping > get_pcvar_num(cvar_maxping)) { ++iPingkick[id] client_print(id, print_chat, "[Rzeznia.eu] Twoj ping jest zbyt wysoki! (%d/%d)", iPingkick[id],get_pcvar_num(cvar_maxpingwarns)) } else if (iPingkick[id] > 0) --iPingkick[id] if (iPingkick[id] > get_pcvar_num(cvar_maxpingwarns)) KickPlayer(id) } // Check rates if (get_pcvar_num(cvar_ratecheck)) { query_client_cvar(id, "rate", "ClientCvarResult") query_client_cvar(id, "cl_updaterate", "ClientCvarResult") query_client_cvar(id, "cl_cmdrate", "ClientCvarResult") } // Check other cvars if (get_pcvar_num(cvar_cvarcheck)) { new left[64],right[64] new tmp = cvar_chkitem[id] + get_pcvar_num(cvar_maxitems) if (tmp > cvar_items) tmp = cvar_items for (new i = cvar_chkitem[id]; i < tmp; i++) { strtok(cvars_buf[i], left, 63,right,63,' ') query_client_cvar(id, left, "ClientCvarResult") } if (tmp >= cvar_items) cvar_chkitem[id] = 0 else cvar_chkitem[id] += get_pcvar_num(cvar_maxitems) } return PLUGIN_CONTINUE } public ClientCvarResult(id, const cvar[], const value[]) { new minrate, mincmdrate, minupdrate minrate = get_pcvar_num(cvar_minrate) mincmdrate = get_pcvar_num(cvar_mincmdrate) minupdrate = get_pcvar_num(cvar_minupdaterate) new Float:f_value = str_to_float(value) if (equali(value, "Bad CVAR request")) return PLUGIN_HANDLED // Check Rates else if ((equal(cvar, "rate")) && (f_value < minrate)) { cc_messagetype(id, cvar, value) console_cmd(id, "rate %d", minrate) return PLUGIN_HANDLED } else if ((equal(cvar, "cl_updaterate")) && (f_value < minupdrate)) { cc_messagetype(id, cvar, value) console_cmd(id, "cl_updaterate %d", minupdrate) return PLUGIN_HANDLED } else if ((equal(cvar, "cl_cmdrate")) && (f_value < mincmdrate)) { cc_messagetype(id, cvar,value) console_cmd(id, "cl_cmdrate %d", mincmdrate) return PLUGIN_HANDLED } else { // Check Other Cvars if (b_oldcfg) { new left[64], right[64], chkcvar[64], chkvalue[64], setvalue[64], methode[64] new Float:f_chkvalue for (new i = 1; i < cvar_items; i++) { strtok(cvars_buf[i], left, 63, right, 63, ';');chkcvar = left;setvalue = right strtok(chkcvar, left, 63, right, 63, ' ',1);chkcvar = left;methode = right strtok(methode, left, 63, right, 63, ' ',1);methode = left;chkvalue = right f_chkvalue = str_to_float(chkvalue) // cvar must be equal if ((equal(methode, "=")) && (equal(chkcvar, cvar)) && (!equal(chkvalue, value))) { cc_messagetype(id,cvar,value) console_cmd(id, "%s %s", cvar, setvalue) } // cvar must be bigger else if ((equal(methode, ">")) && (equal(chkcvar, cvar)) && (f_value > f_chkvalue)) { cc_messagetype(id,cvar,value) console_cmd(id, "%s %s", cvar, setvalue) } // cvar must be smaller else if ((equal(methode, "<")) && (equal(chkcvar, cvar)) && (f_value < f_chkvalue)) { cc_messagetype(id,cvar,value) console_cmd(id, "%s %s", cvar, setvalue) } // cvar can be all except else if ((equal(methode, "!")) && (equal(chkcvar, cvar)) && (equal(value, chkvalue))) { cc_messagetype(id,cvar,value) console_cmd(id, "%s %s", cvar, setvalue) } } } else { new v_value[1024], timestamp new vault = nvault_open("CvarCheck") new x = nvault_lookup(vault, cvar, v_value, sizeof(v_value)-1, timestamp) nvault_close(vault) if (!x) return PLUGIN_HANDLED new setvalue[32], getvalue[32] new Float:maxvalue, Float:minvalue copy(setvalue, sizeof(setvalue)-1, get_value(v_value,"set_value")) if (contain(v_value, "min_value") >= 0) { copy(getvalue, sizeof(getvalue)-1, get_value(v_value, "min_value")) minvalue = str_to_float(getvalue) if (equal(setvalue, "*") && contain(v_value, "max_value") != -1) { copy(getvalue, sizeof(getvalue)-1, get_value(v_value, "max_value")) maxvalue = str_to_float(getvalue) if (f_value < minvalue || f_value > maxvalue) { new avgvalue[32] float_to_str((minvalue+maxvalue)/2, avgvalue, sizeof(avgvalue)-1) cc_messagetype(id,cvar,value) console_cmd(id, "%s %s", cvar, avgvalue) return PLUGIN_HANDLED } } else if (f_value < minvalue) { cc_messagetype(id,cvar,value) console_cmd(id, "%s %s", cvar, setvalue) return PLUGIN_HANDLED } } if (contain(v_value, "max_value") >= 0) { maxvalue = Float:str_to_float(get_value(v_value, "max_value")) if (f_value > maxvalue) { cc_messagetype(id,cvar,value) console_cmd(id, "%s %s", cvar, setvalue) return PLUGIN_HANDLED } } if (contain(v_value, "equal_to") >= 0) { if (cc_compare(value, get_value(v_value, "equal_to"), 1)) { cc_messagetype(id,cvar,value) console_cmd(id, "%s %s", cvar, setvalue) return PLUGIN_HANDLED } } if (contain(v_value, "!equal_to") >= 0) { if (!cc_compare(value, get_value(v_value, "!equal_to"), 1)) { cc_messagetype(id,cvar,value) console_cmd(id, "%s %s", cvar, setvalue) return PLUGIN_HANDLED } } if (contain(v_value, "contains") >= 0) { if (cc_compare(value, get_value(v_value, "contains"), 2)) { cc_messagetype(id,cvar,value) console_cmd(id, "%s %s", cvar, setvalue) return PLUGIN_HANDLED } } if (contain(v_value, "!contains") >= 0) { if (!cc_compare(value, get_value(v_value, "!contains"), 2)) { cc_messagetype(id,cvar,value) console_cmd(id, "%s %s", cvar, setvalue) return PLUGIN_HANDLED } } if (contain(v_value, "regex") >= 0) { new pattern[256], Regex:re, ret , error[128] copy(pattern, sizeof(pattern)-1, get_value(v_value, "regex")) re = regex_match(value, pattern, ret, error, sizeof(error)-1) if (re >= REGEX_OK) { cc_messagetype(id,cvar,value) console_cmd(id, "%s %s", cvar, setvalue) return PLUGIN_HANDLED } } } } return PLUGIN_CONTINUE } cc_messagetype(id, const cvar[], const value[]) { new name[32], is_admin, is_hltv, num get_user_name(id, name, 31) new type = get_pcvar_num(cvar_messagetype) /* type 1: Admins only type 2: Checked Player + Admins type 3: All Players */ if (type == 3) client_print(0, print_chat, "%d %s: %s %s", id, name, cvar, value) else { new players[32], player get_players(players, num, "c") for (new i = 0;i < num;i++) { player = players[i] is_hltv = is_user_hltv(player) if (!is_hltv) { is_admin = is_user_admin(player) switch(type) { case 1: { if (is_admin) client_print(player, print_chat, "%d %s: %s %s", id, name, cvar, value) } case 2: { client_print(id, print_chat, "%d %s: %s %s", id, name ,cvar, value) if (is_admin && id != player) client_print(player, print_chat, "%d %s: %s %s", id, name, cvar, value) } } } } } // Write log if (get_pcvar_num(cvar_writelog)) { new auth [35] get_user_authid(id, auth, 34) log_to_file(logfile, "(%s) %s: %s %s",auth, name, cvar, value) } // Invalid settings counter num = get_pcvar_num(cvar_maxinvalid) if (num > 0) { client_isettings[id]++ if (client_isettings[id] >= num) { new uID = get_user_userid(id) server_cmd("banid 1 #%d", uID) client_print(id, print_console, "Kicked: Stale nieprawidlowe ustawienia!") server_cmd("kick #%d ^"Kicked: stale nieprawidlowe ustawienia!^"", uID) client_print(0, print_chat, "[Rzeznia.eu] %s, zostal wyrzucony za ciagle zmienianie ustawien na nieodpowiednie!", name) } } return PLUGIN_CONTINUE } KickPlayer(id) { new name[32] get_user_name(id, name, 31) new uID = get_user_userid(id) server_cmd("banid 1 #%d", uID) client_print(id, print_console, "Wyrzucony ze wzgledu na wysoki ping!") server_cmd("kick #%d ^"Wyrzucony ze wzgledu na wysoki ping!^"", uID) client_print(0, print_chat, "[Rzeznia.eu] %s, zostal wyrzucony za zbyt wysoki ping!", name) } // Admin Commands public Admin_Commands(id) { new value[8], num_value, cmd[16], name[32], uID[35], uIP[32], i if (!is_user_admin(id)) { client_print(id, print_console, "Odmowa dostepu!") return PLUGIN_HANDLED } read_argv(1, value, 7) read_argv(0, cmd, 15) num_value = str_to_num(value) get_user_name(id, name, 31) get_user_ip(id, uIP, 31) get_user_authid(id, uID, 34) if (equali(cmd, "cc_reloadcfg")) { client_print(id, print_console, "Reloading CVAR Checker") cvar_items = 0 load_cvarsconfig() } for (i = 0;i < AdminCMDs1;i++) { if (equali(array_enable_disable[i], cmd)) { if (equali(value, "")) { client_print(id, print_console, "^"%s^" ^"%d^"", cmd, get_cvar_num(cmd)) } else if (!is_str_num(value)) { client_print(id, print_console, "0 = Disable") client_print(id, print_console, "1 = Enable") } else if ((num_value == 0) || (num_value == 1)) { if (get_cvar_num(cmd) != num_value) { set_cvar_num(cmd, num_value) client_print(id, print_console, "Changed cvar: %s %d", cmd, num_value) // Write to log (if enabled) if (get_pcvar_num(cvar_writelog) || equali(cmd, "cc_writelog")) log_to_file(logfile, "Changed cvar: %s %d (by %s : %s : %s)", cmd, num_value, name, uID, uIP) // Write new setting to config (if enabled) if (get_pcvar_num(cvar_writecfg) || equali(cmd, "cc_writecfg")) write_cfg(id, cmd, value) } else client_print(id, print_console, "Nothing to be changed") } else { client_print(id, print_console, "0 = Disable") client_print(id, print_console, "1 = Enable") } return PLUGIN_HANDLED } } for (i = 0;i < AdminCMDs2;i++) { if (equali(array_cmd_cvars[i], cmd)) { if (equali(value, "") || strlen(value) == 0) { client_print(id, print_console, "^"%s^" ^"%d^"", cmd, get_cvar_num(cmd)) } else if (!is_str_num(value)) { client_print(id, print_console, "Podana wartosc jest nieodpowiednia.") } // Check delay changed: Update tasks with new check delay else if ((equali("cc_chkdelay", cmd)) && (get_pcvar_num(cvar_chkdelay) != num_value)) { new players[32], num, player get_players(players, num, "c") for (i = 0; i < num;i++) { player = players[i] if (task_exists(player)) change_task(player, str_to_float(value)) } } else if (get_cvar_num(cmd) != num_value) { set_cvar_num(cmd, num_value) client_print(id, print_console, "Zmieniono cvar: %s %d", cmd, num_value) // Write to log (if enabled) if (get_pcvar_num(cvar_writelog) || equali(cmd, "cc_writelog")) log_to_file(logfile, "Changed cvar: %s %d (by %s : %s : %s)", cmd, num_value, name, uID, uIP) // Write new setting to config (if enabled) if (get_pcvar_num(cvar_writecfg) || equali(cmd, "cc_writecfg")) write_cfg(id, cmd, value) } else client_print(id, print_console, "Nic sie nie zmienilo") break // Break the loop } } return PLUGIN_HANDLED } // Write new setting to config file write_cfg(id, const cmd[], const value[]) { new buffer[1024], bool:b_wrote, line = 0, len new bufsize = sizeof(buffer)-1 if (file_exists(g_configfile)) { new left[64], right[32], data[1024] while(read_file(g_configfile, line, buffer, bufsize, len)) { strtok(buffer,left, 63, right, 31) if (equal(left, cmd)) { formatex(data, 1023, "%s %s", cmd, value) write_file(g_configfile, data, line) b_wrote = true } ++line } if (strfind(buffer, "^n") == -1) write_file(g_configfile, "") } if (!b_wrote) { formatex(buffer, bufsize, "%s %s", cmd, value) write_file(g_configfile, buffer) } client_print(id, print_console, "Wrote ^"%s %s^" to ^"%s^"", cmd, value, cfgfile) return PLUGIN_CONTINUE } cc_compare(const value1[], const value2[], method) { new left[128], right[1024] new bool:loop = true strtok(value2, left, sizeof(left)-1, right, sizeof(right)-1, ',') while(loop) { switch(method) { case 1: // equal to { // check if value is numeric if (is_str_num(left)) if (str_to_float(left) == str_to_float(value1)) return true if (equali(left, value1)) return true } case 2: // contains { if (containi(value1,left) >= 0) return true } } strtok(right, left, sizeof(left)-1, right, sizeof(right)-1, ',') if (contain(right, ",") == -1 && strlen(left) == 0) loop = false } return false } get_value(const value[], const type[]) { new pos = strfind(value, type) new len = strlen(type) new left[1024] new right[2] strtok(value[len+pos+1], left, sizeof(left)-1, right, sizeof(right)-1, ';') return left } load_cvarsconfig() { new line, text[1024], txtlen, bool:b_open // remove old nvault file new nvault_file[92] get_datadir(nvault_file, sizeof(nvault_file)-1) format(nvault_file, sizeof(nvault_file)-1, "%s/vault/CvarCheck.vault", nvault_file) if (file_exists(nvault_file)) delete_file(nvault_file) new item[64], value[2048], timestamp new vault = nvault_open("CvarCheck") new left[64], right[256] new Regex:re, ret, error[128] while (read_file(g_chkcvarfile, line, text, sizeof(text)-1, txtlen)) { trim(text) if ((strfind(text, "//", 0, 0) != 0 || strfind(text, ";", 0, 0) != 0) && txtlen > 0) { // check if using the old config file re = regex_match(text, ".+\s[=,>,<,!]\s.+;.+", ret, error, sizeof(error)-1) if (re >= REGEX_OK) { server_print("[Rzeznia.eu] Wykryto stary plik config") b_oldcfg = true break } strtok(text, left, sizeof(left)-1, right, sizeof(right)-1) // split line if (b_open) { if (equal(text, "}")) { b_open = false nvault_set(vault, item, value) copy(value, sizeof(value)-1, "") // Clear value continue } else if (equal(left, "min_value")) { format(value, sizeof(value)-1, "%s;min_value:%s", value, right) } else if (equal(left, "max_value")) { format(value, sizeof(value)-1, "%s;max_value:%s", value, right) } else if (equal(left, "set_value")) { format(value, sizeof(value)-1, "set_value:%s%s", right, value) } else if (equal(left, "contains")) { format(value, sizeof(value)-1, "%s;contains:%s", value, right) } else if (equal(left, "!contains")) { format(value, sizeof(value)-1, "%s;!contains:%s", value, right) } else if (equal(left, "equal_to")) { format(value, sizeof(value)-1, "%s;equal_to:%s", value, right) } else if (equal(left, "!equal_to")) { format(value, sizeof(value)-1, "%s;!equal_to:%s", value, right) } else if(equal(left, "regex")) { format(value, sizeof(value)-1, "%s;regex:%s", value, right) } } } if (strlen(left) > 0 && equal(right, "{")) // Check line for "item {" { b_open = true copy(item, sizeof(item)-1, left) nvault_lookup(vault, item, value , sizeof(value)-1, timestamp) cvars_buf[cvar_items] = item cvar_items++ } line++ } nvault_close(vault) if (b_oldcfg) { new buf[64] new fp=fopen(g_chkcvarfile, "rt") cvar_items = 0 new len, x while (!feof(fp)) { fgets(fp, buf, sizeof(buf)-1) trim(buf) len = strlen(buf) if (len > 0) { // Check if line starts with comment sign if (cvar_items == MAXITEMS) break x = strfind(buf, "//", 0, 0) if (x != 0) { cvars_buf[cvar_items] = buf cvar_items++ } } } fclose(fp) } } #if defined USESQL public sql_connect() { new error[256] get_pcvar_string(cvar_sqlhost, sql_host, sizeof(sql_host)) get_pcvar_string(cvar_sqluser, sql_user, sizeof(sql_user)) get_pcvar_string(cvar_sqlpass, sql_pass, sizeof(sql_pass)) get_pcvar_string(cvar_sqldbname, sql_dbname, sizeof(sql_dbname)) sql = dbi_connect(sql_host, sql_user, sql_pass, sql_dbname, error, sizeof(error)-1) if (sql <= SQL_FAILED) log_amx("SQL CONNECT ERROR: %s", error) } public sql_checkid(id) { sql_connect() if (sql <= SQL_FAILED) { log_amx("Could not check database due to a connection error!") return 0 } else { new steamid[35] get_user_authid(id, steamid, sizeof(steamid)-1) new query[256] formatex(query, sizeof(query)-1, "SELECT steamid FROM s_SteamIDs WHERE steamid = '%s'", steamid) new Result:result = dbi_query(sql, query) dbi_close(sql) if (result >= RESULT_OK) { new temp[35] dbi_result(result, "steamid", temp, sizeof(temp)-1) dbi_free_result(result) if (equali(temp, steamid)) return 1 } } return 0 } public sql_addid(id) { sql_connect() if (sql <= SQL_FAILED) log_amx("Nie mozna dodac nowego steamid do bazy danych z powodu bledu polaczenia!") else { new steamid[35] get_user_authid(id, steamid, sizeof(steamid)-1) new query[256] formatex(query, sizeof(query)-1, "INSERT INTO s_SteamIDs (steamid) values ('%s')", steamid) new Result:result = dbi_query(sql, query) if (result == RESULT_FAILED) log_amx("SQL Nie udalo sie dodac nowego steamid do bazy danych") } dbi_close(sql) } #endif
Użytkownik jakotakitu edytował ten post 20.04.2012 11:36