HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /* AMX Mod X script.
  2. * Admin Base Plugin
  3. *
  4. * by the AMX Mod X Development Team
  5. * originally developed by OLO
  6. *
  7. * This file is part of AMX Mod X.
  8. *
  9. *
  10. * This program is free software; you can redistribute it and/or modify it
  11. * under the terms of the GNU General Public License as published by the
  12. * Free Software Foundation; either version 2 of the License, or (at
  13. * your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful, but
  16. * WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software Foundation,
  22. * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  23. *
  24. * In addition, as a special exception, the author gives permission to
  25. * link the code of this program with the Half-Life Game Engine ("HL
  26. * Engine") and Modified Game Libraries ("MODs") developed by Valve,
  27. * L.L.C ("Valve"). You must obey the GNU General Public License in all
  28. * respects for all of the code used other than the HL Engine and MODs
  29. * from Valve. If you modify this file, you may extend this exception
  30. * to your version of the file, but you are not obligated to do so. If
  31. * you do not wish to do so, delete this exception statement from your
  32. * version.
  33. *
  34. * Modified for AMXBans 6.0
  35. *
  36. * Based on admins plugin v1.8.1.3746
  37. *
  38. * Rev 2010/04/13
  39. */
  40.  
  41. #include <amxmodx>
  42. #include <amxmisc>
  43. #include <sqlx>
  44.  
  45. new AdminCount;
  46.  
  47. new PLUGINNAME[] = "AMXBans Core"
  48. new PLUGINVERSION[] = "6.0.3"
  49.  
  50. #define ADMIN_LOOKUP (1<<0)
  51. #define ADMIN_NORMAL (1<<1)
  52. #define ADMIN_STEAM (1<<2)
  53. #define ADMIN_IPADDR (1<<3)
  54. #define ADMIN_NAME (1<<4)
  55.  
  56. new g_cmdLoopback[16]
  57. new bool:g_CaseSensitiveName[33];
  58.  
  59. // pcvars
  60. new amx_mode;
  61. new amx_password_field;
  62. new amx_default_access;
  63.  
  64. //amxbans
  65. new pcvarip,pcvarprefix,pcvaradminsfile
  66. new g_ServerAddr[100],g_dbPrefix[32],g_AdminsFromFile
  67. new g_szAdminNick[33][32],g_iAdminUseStaticBantime[33]
  68. new Array:g_AdminNick
  69. new Array:g_AdminUseStaticBantime
  70.  
  71. //multi forward handles
  72. new bool:g_isAdmin[33]
  73. enum MFHANDLE_TYPES {
  74. Amxbans_Sql_Initialized=0,
  75. Admin_Connect,
  76. Admin_Disconnect
  77. }
  78. new MFHandle[MFHANDLE_TYPES]
  79.  
  80. new Handle:info
  81. new bool:g_bSqlInitialized
  82.  
  83. public plugin_init()
  84. {
  85. register_plugin(PLUGINNAME, PLUGINVERSION, "HLXBans Dev Team")
  86.  
  87. register_dictionary("admin.txt")
  88. register_dictionary("common.txt")
  89. amx_mode=register_cvar("amx_mode", "1")
  90. amx_password_field=register_cvar("amx_password_field", "_pw")
  91. amx_default_access=register_cvar("amx_default_access", "")
  92.  
  93. register_cvar("amx_vote_ratio", "0.02")
  94. register_cvar("amx_vote_time", "10")
  95. register_cvar("amx_vote_answers", "1")
  96. register_cvar("amx_vote_delay", "60")
  97. register_cvar("amx_last_voting", "0")
  98. register_cvar("amx_show_activity", "2")
  99. register_cvar("amx_votekick_ratio", "0.40")
  100. register_cvar("amx_voteban_ratio", "0.40")
  101. register_cvar("amx_votemap_ratio", "0.40")
  102.  
  103. set_cvar_float("amx_last_voting", 0.0)
  104.  
  105.  
  106. register_srvcmd("amx_sqladmins", "adminSql")
  107. register_cvar("amx_sql_table", "admins")
  108. // amxbans
  109. pcvarip=register_cvar("amxbans_server_address","")
  110. pcvarprefix=register_cvar("amx_sql_prefix", "amx")
  111. pcvaradminsfile=register_cvar("amxbans_use_admins_file","0")
  112.  
  113. g_AdminNick=ArrayCreate(32,32)
  114. g_AdminUseStaticBantime=ArrayCreate(1,32)
  115. //
  116. register_cvar("amx_sql_host", "127.0.0.1")
  117. register_cvar("amx_sql_user", "root")
  118. register_cvar("amx_sql_pass", "")
  119. register_cvar("amx_sql_db", "amx")
  120. register_cvar("amx_sql_type", "mysql")
  121.  
  122. register_concmd("amx_reloadadmins", "cmdReload", ADMIN_CFG)
  123. //register_concmd("amx_addadmin", "addadminfn", ADMIN_RCON, "<playername|auth> <accessflags> [password] [authtype] - add specified player as an admin to users.ini")
  124.  
  125. format(g_cmdLoopback, 15, "amxauth%c%c%c%c", random_num('A', 'Z'), random_num('A', 'Z'), random_num('A', 'Z'), random_num('A', 'Z'))
  126.  
  127. register_clcmd(g_cmdLoopback, "ackSignal")
  128.  
  129. remove_user_flags(0, read_flags("z")) // Remove 'user' flag from server rights
  130.  
  131. new configsDir[64]
  132. get_configsdir(configsDir, 63)
  133.  
  134. server_cmd("exec %s/amxx.cfg", configsDir) // Execute main configuration file
  135. server_cmd("exec %s/sql.cfg", configsDir)
  136. //server_cmd("exec %s/amxbans.cfg", configsDir)
  137.  
  138. }
  139. public client_connect(id)
  140. {
  141. g_CaseSensitiveName[id] = false;
  142. }
  143. public plugin_cfg() {
  144. //fixx to be sure cfgs are loaded
  145. create_forwards()
  146. set_task(0.1,"delayed_plugin_cfg")
  147. }
  148. create_forwards() {
  149. MFHandle[Amxbans_Sql_Initialized]=CreateMultiForward("amxbans_sql_initialized",ET_IGNORE,FP_CELL,FP_STRING)
  150. MFHandle[Admin_Connect]=CreateMultiForward("amxbans_admin_connect",ET_IGNORE,FP_CELL)
  151. MFHandle[Admin_Disconnect]=CreateMultiForward("amxbans_admin_disconnect",ET_IGNORE,FP_CELL)
  152. }
  153. public delayed_plugin_cfg()
  154. {
  155. //check if amxbans plugins are the first plugins and default admin plugins are disabled
  156. //added for admins who cant read the docs
  157. if(find_plugin_byfile("admin.amxx") != INVALID_PLUGIN_ID) {
  158. log_amx("[AMXBans] WARNING: admin.amxx plugin running! stopped.")
  159. pause("acd","admin.amxx")
  160. }
  161. if(find_plugin_byfile("admin_sql.amxx") != INVALID_PLUGIN_ID) {
  162. log_amx("[AMXBans] WARNING: admin_sql.amxx plugin running! stopped.")
  163. pause("acd","admin_sql.amxx")
  164. }
  165. if(find_plugin_byfile("amxbans_core.amxx") != 0) log_amx("[AMXBans] WARNING: amxbans_core.amxx should be the fist entry in your plugins.ini!")
  166. if(find_plugin_byfile("amxbans_main.amxx") != 1) log_amx("[AMXBans] WARNING: amxbans_main.amxx should be the second entry in your plugins.ini!")
  167.  
  168. get_pcvar_string(pcvarprefix,g_dbPrefix,charsmax(g_dbPrefix))
  169. get_pcvar_string(pcvarip,g_ServerAddr,charsmax(g_ServerAddr))
  170. g_AdminsFromFile=get_pcvar_num(pcvaradminsfile)
  171.  
  172. if(strlen(g_ServerAddr) < 9) {
  173. new ip[32]
  174. get_user_ip(0,ip,31)
  175. formatex(g_ServerAddr,charsmax(g_ServerAddr),"%s",ip)
  176. }
  177. if(get_cvar_num("amxbans_debug") >= 1) server_print("[AMXBans] plugin_cfg: ip %s / prefix %s",g_ServerAddr,g_dbPrefix)
  178.  
  179. server_cmd("amx_sqladmins")
  180. server_exec();
  181.  
  182. set_task(6.1, "delayed_load")
  183. }
  184.  
  185. public delayed_load()
  186. {
  187. new configFile[128], curMap[64], configDir[128]
  188.  
  189. get_configsdir(configDir, sizeof(configDir)-1)
  190. get_mapname(curMap, sizeof(curMap)-1)
  191.  
  192. new i=0;
  193.  
  194. while (curMap[i] != '_' && curMap[i++] != '^0') {/*do nothing*/}
  195.  
  196. if (curMap[i]=='_')
  197. {
  198. // this map has a prefix
  199. curMap[i]='^0';
  200. formatex(configFile, sizeof(configFile)-1, "%s/maps/prefix_%s.cfg", configDir, curMap);
  201.  
  202. if (file_exists(configFile))
  203. {
  204. server_cmd("exec %s", configFile);
  205. }
  206. }
  207.  
  208. get_mapname(curMap, sizeof(curMap)-1)
  209.  
  210.  
  211. formatex(configFile, sizeof(configFile)-1, "%s/maps/%s.cfg", configDir, curMap)
  212.  
  213. if (file_exists(configFile))
  214. {
  215. server_cmd("exec %s", configFile)
  216. }
  217.  
  218. }
  219.  
  220. loadSettings(szFilename[])
  221. {
  222. new File=fopen(szFilename,"r");
  223.  
  224. if (File)
  225. {
  226. new Text[512];
  227. new Flags[32];
  228. new Access[32]
  229. new AuthData[44];
  230. new Password[32];
  231. new Name[32];
  232. new Static[2];
  233.  
  234. while (!feof(File))
  235. {
  236. fgets(File,Text,sizeof(Text)-1);
  237.  
  238. trim(Text);
  239.  
  240. // comment
  241. if (Text[0]==';')
  242. {
  243. continue;
  244. }
  245.  
  246. Flags[0]=0;
  247. Access[0]=0;
  248. AuthData[0]=0;
  249. Password[0]=0;
  250. Name[0] = 0;
  251. Static[0] = 0;
  252.  
  253. // not enough parameters
  254. if (parse(Text, AuthData, charsmax(AuthData), Password, charsmax(Password), Access, charsmax(Access), Flags, charsmax(Flags), Name, charsmax(Name), Static, charsmax(Static)) < 2)
  255. {
  256. continue;
  257. }
  258.  
  259. admins_push(AuthData,Password,read_flags(Access),read_flags(Flags));
  260. ArrayPushString(g_AdminNick, Name);
  261. ArrayPushCell(g_AdminUseStaticBantime, str_to_num(Static));
  262.  
  263. AdminCount++;
  264. }
  265.  
  266. fclose(File);
  267. }
  268.  
  269. if (AdminCount == 1)
  270. {
  271. server_print("[AMXBans] %L", LANG_SERVER, "LOADED_ADMIN");
  272. }
  273. else
  274. {
  275. server_print("[AMXBans] %L", LANG_SERVER, "LOADED_ADMINS", AdminCount);
  276. }
  277.  
  278. return 1;
  279. }
  280.  
  281.  
  282. public adminSql()
  283. {
  284. new table[32], error[128], errno
  285. AdminCount = 0;
  286. admins_flush();
  287.  
  288. SQL_SetAffinity("mysql")
  289. info = SQL_MakeStdTuple()
  290. new Handle:sql = SQL_Connect(info, errno, error, 127)
  291.  
  292. get_cvar_string("amx_sql_table", table, 31)
  293.  
  294. //sql error or amxbans_use_admins_file == 1
  295. if (sql == Empty_Handle || g_AdminsFromFile == 1)
  296. {
  297. if(!g_AdminsFromFile) server_print("[AMXBans] %L", LANG_SERVER, "SQL_CANT_CON", error)
  298.  
  299. //backup to users.ini
  300. new configsDir[64]
  301.  
  302. get_configsdir(configsDir, 63)
  303. format(configsDir, 63, "%s/users.ini", configsDir)
  304. loadSettings(configsDir) // Load admins accounts
  305.  
  306. new players[32], num, pv
  307. new name[32]
  308. get_players(players, num)
  309. for (new i=0; i<num; i++)
  310. {
  311. pv = players[i]
  312. get_user_name(pv, name, 31)
  313. accessUser(pv, name)
  314. }
  315.  
  316. if(!g_bSqlInitialized)
  317. {
  318. new ret
  319. ExecuteForward(MFHandle[Amxbans_Sql_Initialized],ret,info,g_dbPrefix)
  320. }
  321. g_bSqlInitialized=true
  322.  
  323. return PLUGIN_HANDLED
  324. }
  325. if(g_AdminsFromFile > 1) return PLUGIN_HANDLED
  326.  
  327. ArrayClear(g_AdminNick)
  328. ArrayClear(g_AdminUseStaticBantime)
  329.  
  330. new Handle:query
  331.  
  332. //amxbans
  333. new pquery[1024]
  334.  
  335. formatex(pquery,1023,"SELECT aa.steamid,aa.password,aa.access,aa.flags,aa.nickname,ads.custom_flags,ads.use_static_bantime \
  336. FROM %s_amxadmins as aa, %s_admins_servers as ads, %s_serverinfo as si \
  337. WHERE ((ads.admin_id=aa.id) AND (ads.server_id=si.id) AND \
  338. ((aa.days=0) OR (aa.expired>UNIX_TIMESTAMP(NOW()))) AND (si.address='%s'))", g_dbPrefix, g_dbPrefix, g_dbPrefix, g_ServerAddr)
  339.  
  340. query = SQL_PrepareQuery(sql,pquery)
  341.  
  342. SQL_Execute(query)
  343. //
  344.  
  345. if(SQL_NumRows(query)) {
  346. /** do this incase people change the query order and forget to modify below */
  347. new qcolAuth = SQL_FieldNameToNum(query, "steamid")
  348. new qcolPass = SQL_FieldNameToNum(query, "password")
  349. new qcolAccess = SQL_FieldNameToNum(query, "access")
  350. new qcolFlags = SQL_FieldNameToNum(query, "flags")
  351. new qcolNick = SQL_FieldNameToNum(query, "nickname")
  352. new qcolCustom = SQL_FieldNameToNum(query, "custom_flags")
  353. new qcolStatic = SQL_FieldNameToNum(query, "use_static_bantime")
  354.  
  355.  
  356. new AuthData[44];
  357. new Password[44];
  358. new Access[32];
  359. new Flags[32];
  360. new Nick[32];
  361. new Static[5]
  362. new iStatic
  363.  
  364. while (SQL_MoreResults(query))
  365. {
  366. SQL_ReadResult(query, qcolAuth, AuthData, sizeof(AuthData)-1);
  367. SQL_ReadResult(query, qcolPass, Password, sizeof(Password)-1);
  368. SQL_ReadResult(query, qcolStatic, Static, sizeof(Static)-1);
  369. SQL_ReadResult(query, qcolCustom, Access, sizeof(Access)-1);
  370. SQL_ReadResult(query, qcolNick, Nick, sizeof(Nick)-1);
  371. SQL_ReadResult(query, qcolFlags, Flags, sizeof(Flags)-1);
  372.  
  373. //if custom access not set get the global
  374. trim(Access)
  375. if(equal(Access,"")) SQL_ReadResult(query, qcolAccess, Access, sizeof(Access)-1);
  376.  
  377. admins_push(AuthData,Password,read_flags(Access),read_flags(Flags));
  378.  
  379. //save nick
  380. ArrayPushString(g_AdminNick,Nick)
  381.  
  382. //save static bantime
  383. iStatic=1
  384. if(equal(Static,"no")) iStatic=0
  385. ArrayPushCell(g_AdminUseStaticBantime,iStatic)
  386.  
  387. ++AdminCount;
  388. SQL_NextRow(query)
  389. }
  390. }
  391.  
  392. if (AdminCount == 1)
  393. {
  394. server_print("[AMXBans] %L", LANG_SERVER, "SQL_LOADED_ADMIN")
  395. }
  396. else
  397. {
  398. server_print("[AMXBans] %L", LANG_SERVER, "SQL_LOADED_ADMINS", AdminCount)
  399. }
  400.  
  401. SQL_FreeHandle(query)
  402. SQL_FreeHandle(sql)
  403.  
  404.  
  405. if(!g_bSqlInitialized) {
  406. new ret
  407. ExecuteForward(MFHandle[Amxbans_Sql_Initialized],ret,info,g_dbPrefix)
  408. }
  409. g_bSqlInitialized=true
  410.  
  411. new players[32], num, pv
  412. new name[32]
  413. get_players(players, num)
  414. for (new i=0; i<num; i++)
  415. {
  416. pv = players[i]
  417. get_user_name(pv, name, 31)
  418. accessUser(pv, name)
  419. }
  420.  
  421. return PLUGIN_HANDLED
  422. }
  423. public plugin_end() {
  424. if(info != Empty_Handle) SQL_FreeHandle(info)
  425. }
  426.  
  427. public cmdReload(id, level, cid)
  428. {
  429. if (!cmd_access(id, level, cid, 1))
  430. return PLUGIN_HANDLED
  431.  
  432. //strip original flags (patch submitted by mrhunt)
  433. remove_user_flags(0, read_flags("z"))
  434.  
  435. AdminCount = 0
  436. adminSql()
  437.  
  438. if (id != 0)
  439. {
  440. if (AdminCount == 1)
  441. console_print(id, "[AMXBans] %L", LANG_SERVER, "SQL_LOADED_ADMIN")
  442. else
  443. console_print(id, "[AMXBans] %L", LANG_SERVER, "SQL_LOADED_ADMINS", AdminCount)
  444. }
  445.  
  446. return PLUGIN_HANDLED
  447. }
  448.  
  449. getAccess(id, name[], authid[], ip[], password[])
  450. {
  451. new index = -1
  452. new result = 0
  453.  
  454. static Count;
  455. static Flags;
  456. static Access;
  457. static AuthData[44];
  458. static Password[32];
  459.  
  460. g_CaseSensitiveName[id] = false;
  461.  
  462. Count=admins_num();
  463. for (new i = 0; i < Count; ++i)
  464. {
  465. Flags=admins_lookup(i,AdminProp_Flags);
  466. admins_lookup(i,AdminProp_Auth,AuthData,sizeof(AuthData)-1);
  467.  
  468. if (Flags & FLAG_AUTHID)
  469. {
  470. if (equal(authid, AuthData))
  471. {
  472. index = i
  473. break
  474. }
  475. }
  476. else if (Flags & FLAG_IP)
  477. {
  478. new c = strlen(AuthData)
  479.  
  480. if (AuthData[c - 1] == '.') /* check if this is not a xxx.xxx. format */
  481. {
  482. if (equal(AuthData, ip, c))
  483. {
  484. index = i
  485. break
  486. }
  487. } /* in other case an IP must just match */
  488. else if (equal(ip, AuthData))
  489. {
  490. index = i
  491. break
  492. }
  493. }
  494. else
  495. {
  496. if (Flags & FLAG_CASE_SENSITIVE)
  497. {
  498. if (Flags & FLAG_TAG)
  499. {
  500. if (contain(name, AuthData) != -1)
  501. {
  502. index = i
  503. g_CaseSensitiveName[id] = true
  504. break
  505. }
  506. }
  507. else if (equal(name, AuthData))
  508. {
  509. index = i
  510. g_CaseSensitiveName[id] = true
  511. break
  512. }
  513. }
  514. else
  515. {
  516. if (Flags & FLAG_TAG)
  517. {
  518. if (containi(name, AuthData) != -1)
  519. {
  520. index = i
  521. break
  522. }
  523. }
  524. else if (equali(name, AuthData))
  525. {
  526. index = i
  527. break
  528. }
  529. }
  530. }
  531. }
  532.  
  533. if (index != -1)
  534. {
  535. Access=admins_lookup(index,AdminProp_Access);
  536. //amxbans
  537. ArrayGetString(g_AdminNick,index,g_szAdminNick[id],31)
  538. g_iAdminUseStaticBantime[id]=ArrayGetCell(g_AdminUseStaticBantime,index)
  539. //
  540.  
  541. if (Flags & FLAG_NOPASS)
  542. {
  543. result |= 8
  544. new sflags[32]
  545.  
  546. get_flags(Access, sflags, 31)
  547. set_user_flags(id, Access)
  548.  
  549. new ret
  550. if(!g_isAdmin[id]) ExecuteForward(MFHandle[Admin_Connect],ret,id)
  551. g_isAdmin[id]=true
  552.  
  553. log_amx("Login: ^"%s<%d><%s><>^" became an admin (account ^"%s^") (access ^"%s^") (address ^"%s^") (nick ^"%s^") (static %d)", \
  554. name, get_user_userid(id), authid, AuthData, sflags, ip,g_szAdminNick[id],g_iAdminUseStaticBantime[id])
  555. }
  556. else
  557. {
  558.  
  559. admins_lookup(index,AdminProp_Password,Password,sizeof(Password)-1);
  560.  
  561. if (equal(password, Password))
  562. {
  563. result |= 12
  564. set_user_flags(id, Access)
  565.  
  566. new sflags[32]
  567. get_flags(Access, sflags, 31)
  568.  
  569. new ret
  570. if(!g_isAdmin[id]) ExecuteForward(MFHandle[Admin_Connect],ret,id)
  571. g_isAdmin[id]=true
  572.  
  573. log_amx("Login: ^"%s<%d><%s><>^" became an admin (account ^"%s^") (access ^"%s^") (address ^"%s^") (nick ^"%s^") (static %d)", \
  574. name, get_user_userid(id), authid, AuthData, sflags, ip,g_szAdminNick[id],g_iAdminUseStaticBantime[id])
  575. }
  576. else
  577. {
  578. result |= 1
  579.  
  580. if (Flags & FLAG_KICK)
  581. {
  582. result |= 2
  583. g_isAdmin[id]=false
  584. log_amx("Login: ^"%s<%d><%s><>^" kicked due to invalid password (account ^"%s^") (address ^"%s^")", name, get_user_userid(id), authid, AuthData, ip)
  585. }
  586. }
  587. }
  588. }
  589. else if (get_pcvar_float(amx_mode) == 2.0)
  590. {
  591. result |= 2
  592. }
  593. else
  594. {
  595. new defaccess[32]
  596.  
  597. get_pcvar_string(amx_default_access, defaccess, 31)
  598.  
  599. if (!strlen(defaccess))
  600. {
  601. copy(defaccess, 32, "z")
  602. }
  603.  
  604. new idefaccess = read_flags(defaccess)
  605.  
  606. if (idefaccess)
  607. {
  608. result |= 8
  609. set_user_flags(id, idefaccess)
  610. }
  611. }
  612.  
  613. return result
  614. }
  615.  
  616. accessUser(id, name[] = "")
  617. {
  618. remove_user_flags(id)
  619.  
  620. new userip[32], userauthid[32], password[32], passfield[32], username[32]
  621.  
  622. get_user_ip(id, userip, 31, 1)
  623. get_user_authid(id, userauthid, 31)
  624.  
  625. if (name[0])
  626. {
  627. copy(username, 31, name)
  628. }
  629. else
  630. {
  631. get_user_name(id, username, 31)
  632. }
  633.  
  634. get_pcvar_string(amx_password_field, passfield, 31)
  635. get_user_info(id, passfield, password, 31)
  636.  
  637. new result = getAccess(id, username, userauthid, userip, password)
  638.  
  639. if (result & 1)
  640. {
  641. client_cmd(id, "echo ^"* %L^"", id, "INV_PAS")
  642. }
  643.  
  644. if (result & 2)
  645. {
  646. client_cmd(id, "%s", g_cmdLoopback)
  647. return PLUGIN_HANDLED
  648. }
  649.  
  650. if (result & 4)
  651. {
  652. client_cmd(id, "echo ^"* %L^"", id, "PAS_ACC")
  653. }
  654.  
  655. if (result & 8)
  656. {
  657. client_cmd(id, "echo ^"* %L^"", id, "PRIV_SET")
  658. }
  659.  
  660. return PLUGIN_CONTINUE
  661. }
  662.  
  663. public client_infochanged(id)
  664. {
  665. if (!is_user_connected(id) || !get_pcvar_num(amx_mode))
  666. {
  667. return PLUGIN_CONTINUE
  668. }
  669.  
  670. new newname[32], oldname[32]
  671.  
  672. get_user_name(id, oldname, 31)
  673. get_user_info(id, "name", newname, 31)
  674.  
  675. if (g_CaseSensitiveName[id])
  676. {
  677. if (!equal(newname, oldname))
  678. {
  679. accessUser(id, newname)
  680. }
  681. }
  682. else
  683. {
  684. if (!equali(newname, oldname))
  685. {
  686. accessUser(id, newname)
  687. }
  688. }
  689. return PLUGIN_CONTINUE
  690. }
  691. public client_disconnect(id) {
  692. if(g_isAdmin[id]) {
  693. new ret
  694. ExecuteForward(MFHandle[Admin_Disconnect],ret,id)
  695. }
  696. g_isAdmin[id]=false
  697. }
  698. public ackSignal(id)
  699. {
  700. server_cmd("kick #%d ^"%L^"", get_user_userid(id), id, "NO_ENTRY")
  701. return PLUGIN_HANDLED
  702. }
  703.  
  704. public client_authorized(id)
  705. return get_pcvar_num(amx_mode) ? accessUser(id) : PLUGIN_CONTINUE
  706.  
  707. public client_putinserver(id)
  708. {
  709. if (!is_dedicated_server() && id == 1)
  710. return get_pcvar_num(amx_mode) ? accessUser(id) : PLUGIN_CONTINUE
  711.  
  712. return PLUGIN_CONTINUE
  713. }
  714.  
  715. //natives
  716. public plugin_natives() {
  717. register_library("AMXBansCore")
  718.  
  719. register_native("amxbans_get_db_prefix","native_amxbans_get_prefix")
  720. register_native("amxbans_get_admin_nick","native_amxbans_get_nick")
  721. register_native("amxbans_get_static_bantime","native_amxbans_static_bantime")
  722. }
  723. public native_amxbans_get_prefix() {
  724. new len= get_param(2)
  725. set_array(1,g_dbPrefix,len)
  726. }
  727. public native_amxbans_get_nick() {
  728.  
  729. new id = get_param(1)
  730. new len= get_param(3)
  731.  
  732. set_array(2,g_szAdminNick[id],len)
  733. }
  734. public native_amxbans_static_bantime() {
  735. new id = get_param(1)
  736. if(get_cvar_num("amxbans_debug") >= 3) log_amx("[AMXBans Core] Native static bantime: id: %d | result: %d",id,g_iAdminUseStaticBantime[id])
  737. return g_iAdminUseStaticBantime[id]
  738. }
  739.