· 8 years ago · Mar 12, 2018, 07:36 PM
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
35// Uncomment for SQL version
36 #define USING_SQL
37
38#include <amxmodx>
39#include <amxmisc>
40#if defined USING_SQL
41#include <sqlx>
42#endif
43
44//new Vector:AdminList;
45
46new AdminCount;
47
48new PLUGINNAME[] = "AMX Mod X"
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
56new g_cmdLoopback[16]
57new bool:g_CaseSensitiveName[33];
58
59// pcvars
60new amx_mode;
61new amx_password_field;
62new amx_default_access;
63
64public plugin_init()
65{
66#if defined USING_SQL
67 register_plugin("Admin Base (SQL)", AMXX_VERSION_STR, "AMXX Dev Team")
68#else
69 register_plugin("Admin Base", AMXX_VERSION_STR, "AMXX Dev Team")
70#endif
71 register_dictionary("admin.txt")
72 register_dictionary("common.txt")
73 amx_mode=register_cvar("amx_mode", "1")
74 amx_password_field=register_cvar("amx_password_field", "_pw")
75 amx_default_access=register_cvar("amx_default_access", "")
76
77 register_cvar("amx_vote_ratio", "0.02")
78 register_cvar("amx_vote_time", "10")
79 register_cvar("amx_vote_answers", "1")
80 register_cvar("amx_vote_delay", "60")
81 register_cvar("amx_last_voting", "0")
82 register_cvar("amx_show_activity", "2")
83 register_cvar("amx_votekick_ratio", "0.40")
84 register_cvar("amx_voteban_ratio", "0.40")
85 register_cvar("amx_votemap_ratio", "0.40")
86
87 set_cvar_float("amx_last_voting", 0.0)
88
89#if defined USING_SQL
90 register_srvcmd("amx_sqladmins", "adminSql")
91 register_cvar("amx_sql_table", "admins")
92#endif
93 register_cvar("amx_sql_host", "127.0.0.1")
94 register_cvar("amx_sql_user", "root")
95 register_cvar("amx_sql_pass", "")
96 register_cvar("amx_sql_db", "amx")
97 register_cvar("amx_sql_type", "mysql")
98
99 register_concmd("amx_reloadadmins", "cmdReload", ADMIN_CFG)
100 register_concmd("amx_addadmin", "addadminfn", ADMIN_RCON, "<playername|auth> <accessflags> [password] [authtype] - add specified player as an admin to users.ini")
101
102 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'))
103
104 register_clcmd(g_cmdLoopback, "ackSignal")
105
106 remove_user_flags(0, read_flags("z")) // Remove 'user' flag from server rights
107
108 new configsDir[64]
109 get_configsdir(configsDir, 63)
110
111 server_cmd("exec %s/amxx.cfg", configsDir) // Execute main configuration file
112 server_cmd("exec %s/sql.cfg", configsDir)
113
114 // Create a vector of 5 cells to store the info.
115 //AdminList=vector_create(5);
116
117
118#if defined USING_SQL
119 server_cmd("amx_sqladmins")
120#else
121 format(configsDir, 63, "%s/users.ini", configsDir)
122 loadSettings(configsDir) // Load admins accounts
123#endif
124}
125public client_connect(id)
126{
127 g_CaseSensitiveName[id] = false;
128}
129public addadminfn(id, level, cid)
130{
131 if (!cmd_access(id, level, cid, 3))
132 return PLUGIN_HANDLED
133
134 new idtype = ADMIN_STEAM | ADMIN_LOOKUP
135
136 if (read_argc() >= 5)
137 {
138 new t_arg[16]
139 read_argv(4, t_arg, 15)
140
141 if (equali(t_arg, "steam") || equali(t_arg, "steamid") || equali(t_arg, "auth"))
142 {
143 idtype = ADMIN_STEAM
144 }
145 else if (equali(t_arg, "ip"))
146 {
147 idtype = ADMIN_IPADDR
148 }
149 else if (equali(t_arg, "name") || equali(t_arg, "nick"))
150 {
151 idtype = ADMIN_NAME
152
153 if (equali(t_arg, "name"))
154 idtype |= ADMIN_LOOKUP
155 } else {
156 console_print(id, "[%s] Unknown id type ^"%s^", use one of: steamid, ip, name", PLUGINNAME, t_arg)
157 return PLUGIN_HANDLED
158 }
159 }
160
161 new arg[33]
162 read_argv(1, arg, 32)
163 new player = -1
164
165 if (idtype & ADMIN_STEAM)
166 {
167 if (containi(arg, "STEAM_0:") == -1)
168 {
169 idtype |= ADMIN_LOOKUP
170 player = cmd_target(id, arg, CMDTARGET_ALLOW_SELF | CMDTARGET_NO_BOTS)
171 } else {
172 new _steamid[44]
173 static _players[32], _num, _pv
174 get_players(_players, _num)
175 for (new _i=0; _i<_num; _i++)
176 {
177 _pv = _players[_i]
178 get_user_authid(_pv, _steamid, sizeof(_steamid)-1)
179 if (!_steamid[0])
180 continue
181 if (equal(_steamid, arg))
182 {
183 player = _pv
184 break
185 }
186 }
187 if (player < 1)
188 {
189 idtype &= ~ADMIN_LOOKUP
190 }
191 }
192 }
193 else if (idtype & ADMIN_NAME)
194 {
195 player = cmd_target(id, arg, CMDTARGET_ALLOW_SELF | CMDTARGET_NO_BOTS)
196
197 if (player)
198 idtype |= ADMIN_LOOKUP
199 else
200 idtype &= ~ADMIN_LOOKUP
201 }
202 else if (idtype & ADMIN_IPADDR)
203 {
204 new len = strlen(arg)
205 new dots, chars
206
207 for (new i = 0; i < len; i++)
208 {
209 if (arg[i] == '.')
210 {
211 if (!chars || chars > 3)
212 break
213
214 if (++dots > 3)
215 break
216
217 chars = 0
218 } else {
219 chars++
220 }
221
222 if (dots != 3 || !chars || chars > 3)
223 {
224 idtype |= ADMIN_LOOKUP
225 player = find_player("dh", arg)
226 }
227 }
228 }
229
230 if (idtype & ADMIN_LOOKUP && !player)
231 {
232 console_print(id, "%L", id, "CL_NOT_FOUND")
233 return PLUGIN_HANDLED
234 }
235
236 new flags[64]
237 read_argv(2, flags, 63)
238
239 new password[64]
240 if (read_argc() >= 4)
241 read_argv(3, password, 63)
242
243 new auth[33]
244 new Comment[33]; // name of player to pass to comment field
245 if (idtype & ADMIN_LOOKUP)
246 {
247 get_user_name(player, Comment, sizeof(Comment)-1)
248 if (idtype & ADMIN_STEAM)
249 {
250 get_user_authid(player, auth, 32)
251 }
252 else if (idtype & ADMIN_IPADDR)
253 {
254 get_user_ip(player, auth, 32)
255 }
256 else if (idtype & ADMIN_NAME)
257 {
258 get_user_name(player, auth, 32)
259 }
260 } else {
261 copy(auth, 32, arg)
262 }
263
264 new type[16], len
265
266 if (idtype & ADMIN_STEAM)
267 len += format(type[len], 15-len, "c")
268 else if (idtype & ADMIN_IPADDR)
269 len += format(type[len], 15-len, "d")
270
271 if (strlen(password) > 0)
272 len += format(type[len], 15-len, "a")
273 else
274 len += format(type[len], 15-len, "e")
275
276 AddAdmin(id, auth, flags, password, type, Comment)
277 cmdReload(id, ADMIN_CFG, 0)
278
279 if (player > 0)
280 {
281 new name[32]
282 get_user_info(player, "name", name, 31)
283 accessUser(player, name)
284 }
285
286 return PLUGIN_HANDLED
287}
288
289AddAdmin(id, auth[], accessflags[], password[], flags[], comment[]="")
290{
291#if defined USING_SQL
292 new error[128], errno
293
294 new Handle:info = SQL_MakeStdTuple()
295 new Handle:sql = SQL_Connect(info, errno, error, 127)
296
297 if (sql == Empty_Handle)
298 {
299 server_print("[AMXX] %L", LANG_SERVER, "SQL_CANT_CON", error)
300 //backup to users.ini
301#endif
302 // Make sure that the users.ini file exists.
303 new configsDir[64]
304 get_configsdir(configsDir, 63)
305 format(configsDir, 63, "%s/users.ini", configsDir)
306
307 if (!file_exists(configsDir))
308 {
309 console_print(id, "[%s] File ^"%s^" doesn't exist.", PLUGINNAME, configsDir)
310 return
311 }
312
313 // Make sure steamid isn't already in file.
314 new line = 0, textline[256], len
315 const SIZE = 63
316 new line_steamid[SIZE + 1], line_password[SIZE + 1], line_accessflags[SIZE + 1], line_flags[SIZE + 1], parsedParams
317
318 // <name|ip|steamid> <password> <access flags> <account flags>
319 while ((line = read_file(configsDir, line, textline, 255, len)))
320 {
321 if (len == 0 || equal(textline, ";", 1))
322 continue // comment line
323
324 parsedParams = parse(textline, line_steamid, SIZE, line_password, SIZE, line_accessflags, SIZE, line_flags, SIZE)
325
326 if (parsedParams != 4)
327 continue // Send warning/error?
328
329 if (containi(line_flags, flags) != -1 && equal(line_steamid, auth))
330 {
331 console_print(id, "[%s] %s already exists!", PLUGINNAME, auth)
332 return
333 }
334 }
335
336 // If we came here, steamid doesn't exist in users.ini. Add it.
337 new linetoadd[512]
338
339 if (comment[0]==0)
340 {
341 formatex(linetoadd, 511, "^r^n^"%s^" ^"%s^" ^"%s^" ^"%s^"", auth, password, accessflags, flags)
342 }
343 else
344 {
345 formatex(linetoadd, 511, "^r^n^"%s^" ^"%s^" ^"%s^" ^"%s^" ; %s", auth, password, accessflags, flags, comment)
346 }
347 console_print(id, "Adding:^n%s", linetoadd)
348
349 if (!write_file(configsDir, linetoadd))
350 console_print(id, "[%s] Failed writing to %s!", PLUGINNAME, configsDir)
351#if defined USING_SQL
352 }
353
354 new table[32]
355
356 get_cvar_string("amx_sql_table", table, 31)
357
358 new Handle:query = SQL_PrepareQuery(sql, "SELECT * FROM `%s` WHERE (`auth` = '%s')", table, auth)
359
360 if (!SQL_Execute(query))
361 {
362 SQL_QueryError(query, error, 127)
363 server_print("[AMXX] %L", LANG_SERVER, "SQL_CANT_LOAD_ADMINS", error)
364 console_print(id, "[AMXX] %L", LANG_SERVER, "SQL_CANT_LOAD_ADMINS", error)
365 } else if (SQL_NumResults(query)) {
366 console_print(id, "[%s] %s already exists!", PLUGINNAME, auth)
367 } else {
368 console_print(id, "Adding to database:^n^"%s^" ^"%s^" ^"%s^" ^"%s^"", auth, password, accessflags, flags)
369
370 SQL_QueryAndIgnore(sql, "REPLACE INTO `%s` (`auth`, `password`, `access`, `flags`) VALUES ('%s', '%s', '%s', '%s')", table, auth, password, accessflags, flags)
371 }
372
373 SQL_FreeHandle(query)
374 SQL_FreeHandle(sql)
375 SQL_FreeHandle(info)
376#endif
377
378}
379public plugin_cfg()
380{
381 set_task(6.1, "delayed_load")
382}
383
384public delayed_load()
385{
386 new configFile[128], curMap[64], configDir[128]
387
388 get_configsdir(configDir, sizeof(configDir)-1)
389 get_mapname(curMap, sizeof(curMap)-1)
390
391 new i=0;
392
393 while (curMap[i] != '_' && curMap[i++] != '^0') {/*do nothing*/}
394
395 if (curMap[i]=='_')
396 {
397 // this map has a prefix
398 curMap[i]='^0';
399 formatex(configFile, sizeof(configFile)-1, "%s/maps/prefix_%s.cfg", configDir, curMap);
400
401 if (file_exists(configFile))
402 {
403 server_cmd("exec %s", configFile);
404 }
405 }
406
407 get_mapname(curMap, sizeof(curMap)-1)
408
409
410 formatex(configFile, sizeof(configFile)-1, "%s/maps/%s.cfg", configDir, curMap)
411
412 if (file_exists(configFile))
413 {
414 server_cmd("exec %s", configFile)
415 }
416
417}
418
419loadSettings(szFilename[])
420{
421 new File=fopen(szFilename,"r");
422
423 if (File)
424 {
425 new Text[512];
426 new Flags[32];
427 new Access[32]
428 new AuthData[44];
429 new Password[32];
430
431 while (!feof(File))
432 {
433 fgets(File,Text,sizeof(Text)-1);
434
435 trim(Text);
436
437 // comment
438 if (Text[0]==';')
439 {
440 continue;
441 }
442
443 Flags[0]=0;
444 Access[0]=0;
445 AuthData[0]=0;
446 Password[0]=0;
447
448 // not enough parameters
449 if (parse(Text,AuthData,sizeof(AuthData)-1,Password,sizeof(Password)-1,Access,sizeof(Access)-1,Flags,sizeof(Flags)-1) < 2)
450 {
451 continue;
452 }
453
454 admins_push(AuthData,Password,read_flags(Access),read_flags(Flags));
455
456 AdminCount++;
457 }
458
459 fclose(File);
460 }
461
462 if (AdminCount == 1)
463 {
464 server_print("[AMXX] %L", LANG_SERVER, "LOADED_ADMIN");
465 }
466 else
467 {
468 server_print("[AMXX] %L", LANG_SERVER, "LOADED_ADMINS", AdminCount);
469 }
470
471 return 1;
472}
473
474#if defined USING_SQL
475public adminSql()
476{
477 new table[32], error[128], type[12], errno
478
479 new Handle:info = SQL_MakeStdTuple()
480 new Handle:sql = SQL_Connect(info, errno, error, 127)
481
482 get_cvar_string("amx_sql_table", table, 31)
483
484 SQL_GetAffinity(type, 11)
485
486 if (sql == Empty_Handle)
487 {
488 server_print("[AMXX] %L", LANG_SERVER, "SQL_CANT_CON", error)
489
490 //backup to users.ini
491 new configsDir[64]
492
493 get_configsdir(configsDir, 63)
494 format(configsDir, 63, "%s/users.ini", configsDir)
495 loadSettings(configsDir) // Load admins accounts
496
497 return PLUGIN_HANDLED
498 }
499
500 new Handle:query
501
502 if (equali(type, "sqlite"))
503 {
504 if (!sqlite_TableExists(sql, table))
505 {
506 SQL_QueryAndIgnore(sql, "CREATE TABLE %s ( auth TEXT NOT NULL DEFAULT '', password TEXT NOT NULL DEFAULT '', access TEXT NOT NULL DEFAULT '', flags TEXT NOT NULL DEFAULT '' )", table)
507 }
508
509 query = SQL_PrepareQuery(sql, "SELECT auth, password, access, flags FROM %s", table)
510 } else {
511 SQL_QueryAndIgnore(sql, "CREATE TABLE IF NOT EXISTS `%s` ( `auth` VARCHAR( 32 ) NOT NULL, `password` VARCHAR( 32 ) NOT NULL, `access` VARCHAR( 32 ) NOT NULL, `flags` VARCHAR( 32 ) NOT NULL ) COMMENT = 'AMX Mod X Admins'", table)
512 query = SQL_PrepareQuery(sql,"SELECT `auth`,`password`,`access`,`flags` FROM `%s`", table)
513 }
514
515 if (!SQL_Execute(query))
516 {
517 SQL_QueryError(query, error, 127)
518 server_print("[AMXX] %L", LANG_SERVER, "SQL_CANT_LOAD_ADMINS", error)
519 } else if (!SQL_NumResults(query)) {
520 server_print("[AMXX] %L", LANG_SERVER, "NO_ADMINS")
521 } else {
522
523 AdminCount = 0
524
525 /** do this incase people change the query order and forget to modify below */
526 new qcolAuth = SQL_FieldNameToNum(query, "auth")
527 new qcolPass = SQL_FieldNameToNum(query, "password")
528 new qcolAccess = SQL_FieldNameToNum(query, "access")
529 new qcolFlags = SQL_FieldNameToNum(query, "flags")
530
531 new AuthData[44];
532 new Password[44];
533 new Access[32];
534 new Flags[32];
535
536 while (SQL_MoreResults(query))
537 {
538 SQL_ReadResult(query, qcolAuth, AuthData, sizeof(AuthData)-1);
539 SQL_ReadResult(query, qcolPass, Password, sizeof(Password)-1);
540 SQL_ReadResult(query, qcolAccess, Access, sizeof(Access)-1);
541 SQL_ReadResult(query, qcolFlags, Flags, sizeof(Flags)-1);
542
543 admins_push(AuthData,Password,read_flags(Access),read_flags(Flags));
544
545 ++AdminCount;
546 SQL_NextRow(query)
547 }
548
549 if (AdminCount == 1)
550 {
551 server_print("[AMXX] %L", LANG_SERVER, "SQL_LOADED_ADMIN")
552 }
553 else
554 {
555 server_print("[AMXX] %L", LANG_SERVER, "SQL_LOADED_ADMINS", AdminCount)
556 }
557
558 SQL_FreeHandle(query)
559 SQL_FreeHandle(sql)
560 SQL_FreeHandle(info)
561 }
562
563 return PLUGIN_HANDLED
564}
565#endif
566
567public cmdReload(id, level, cid)
568{
569 if (!cmd_access(id, level, cid, 1))
570 return PLUGIN_HANDLED
571
572 //strip original flags (patch submitted by mrhunt)
573 remove_user_flags(0, read_flags("z"))
574
575 admins_flush();
576
577#if !defined USING_SQL
578 new filename[128]
579
580 get_configsdir(filename, 127)
581 format(filename, 63, "%s/users.ini", filename)
582
583 AdminCount = 0;
584 loadSettings(filename); // Re-Load admins accounts
585
586 if (id != 0)
587 {
588 if (AdminCount == 1)
589 {
590 console_print(id, "[AMXX] %L", LANG_SERVER, "LOADED_ADMIN");
591 }
592 else
593 {
594 console_print(id, "[AMXX] %L", LANG_SERVER, "LOADED_ADMINS", AdminCount);
595 }
596 }
597#else
598 AdminCount = 0
599 adminSql()
600
601 if (id != 0)
602 {
603 if (AdminCount == 1)
604 console_print(id, "[AMXX] %L", LANG_SERVER, "SQL_LOADED_ADMIN")
605 else
606 console_print(id, "[AMXX] %L", LANG_SERVER, "SQL_LOADED_ADMINS", AdminCount)
607 }
608#endif
609
610 new players[32], num, pv
611 new name[32]
612 get_players(players, num)
613 for (new i=0; i<num; i++)
614 {
615 pv = players[i]
616 get_user_name(pv, name, 31)
617 accessUser(pv, name)
618 }
619
620 return PLUGIN_HANDLED
621}
622
623getAccess(id, name[], authid[], ip[], password[])
624{
625 new index = -1
626 new result = 0
627
628 static Count;
629 static Flags;
630 static Access;
631 static AuthData[44];
632 static Password[32];
633
634 g_CaseSensitiveName[id] = false;
635
636 Count=admins_num();
637 for (new i = 0; i < Count; ++i)
638 {
639 Flags=admins_lookup(i,AdminProp_Flags);
640 admins_lookup(i,AdminProp_Auth,AuthData,sizeof(AuthData)-1);
641
642 if (Flags & FLAG_AUTHID)
643 {
644 if (equal(authid, AuthData))
645 {
646 index = i
647 break
648 }
649 }
650 else if (Flags & FLAG_IP)
651 {
652 new c = strlen(AuthData)
653
654 if (AuthData[c - 1] == '.') /* check if this is not a xxx.xxx. format */
655 {
656 if (equal(AuthData, ip, c))
657 {
658 index = i
659 break
660 }
661 } /* in other case an IP must just match */
662 else if (equal(ip, AuthData))
663 {
664 index = i
665 break
666 }
667 }
668 else
669 {
670 if (Flags & FLAG_CASE_SENSITIVE)
671 {
672 if (Flags & FLAG_TAG)
673 {
674 if (contain(name, AuthData) != -1)
675 {
676 index = i
677 g_CaseSensitiveName[id] = true
678 break
679 }
680 }
681 else if (equal(name, AuthData))
682 {
683 index = i
684 g_CaseSensitiveName[id] = true
685 break
686 }
687 }
688 else
689 {
690 if (Flags & FLAG_TAG)
691 {
692 if (containi(name, AuthData) != -1)
693 {
694 index = i
695 break
696 }
697 }
698 else if (equali(name, AuthData))
699 {
700 index = i
701 break
702 }
703 }
704 }
705 }
706
707 if (index != -1)
708 {
709 Access=admins_lookup(index,AdminProp_Access);
710
711 if (Flags & FLAG_NOPASS)
712 {
713 result |= 8
714 new sflags[32]
715
716 get_flags(Access, sflags, 31)
717 set_user_flags(id, Access)
718
719 log_amx("Login: ^"%s<%d><%s><>^" became an admin (account ^"%s^") (access ^"%s^") (address ^"%s^")", name, get_user_userid(id), authid, AuthData, sflags, ip)
720 }
721 else
722 {
723
724 admins_lookup(index,AdminProp_Password,Password,sizeof(Password)-1);
725
726 if (equal(password, Password))
727 {
728 result |= 12
729 set_user_flags(id, Access)
730
731 new sflags[32]
732 get_flags(Access, sflags, 31)
733
734 log_amx("Login: ^"%s<%d><%s><>^" became an admin (account ^"%s^") (access ^"%s^") (address ^"%s^")", name, get_user_userid(id), authid, AuthData, sflags, ip)
735 }
736 else
737 {
738 result |= 1
739
740 if (Flags & FLAG_KICK)
741 {
742 result |= 2
743 log_amx("Login: ^"%s<%d><%s><>^" kicked due to invalid password (account ^"%s^") (address ^"%s^")", name, get_user_userid(id), authid, AuthData, ip)
744 }
745 }
746 }
747 }
748 else if (get_pcvar_float(amx_mode) == 2.0)
749 {
750 result |= 2
751 }
752 else
753 {
754 new defaccess[32]
755
756 get_pcvar_string(amx_default_access, defaccess, 31)
757
758 if (!strlen(defaccess))
759 {
760 copy(defaccess, 32, "z")
761 }
762
763 new idefaccess = read_flags(defaccess)
764
765 if (idefaccess)
766 {
767 result |= 8
768 set_user_flags(id, idefaccess)
769 }
770 }
771
772 return result
773}
774
775accessUser(id, name[] = "")
776{
777 remove_user_flags(id)
778
779 new userip[32], userauthid[32], password[32], passfield[32], username[32]
780
781 get_user_ip(id, userip, 31, 1)
782 get_user_authid(id, userauthid, 31)
783
784 if (name[0])
785 {
786 copy(username, 31, name)
787 }
788 else
789 {
790 get_user_name(id, username, 31)
791 }
792
793 get_pcvar_string(amx_password_field, passfield, 31)
794 get_user_info(id, passfield, password, 31)
795
796 new result = getAccess(id, username, userauthid, userip, password)
797
798 if (result & 1)
799 {
800 client_cmd(id, "echo ^"* %L^"", id, "INV_PAS")
801 }
802
803 if (result & 2)
804 {
805 client_cmd(id, "%s", g_cmdLoopback)
806 return PLUGIN_HANDLED
807 }
808
809 if (result & 4)
810 {
811 client_cmd(id, "echo ^"* %L^"", id, "PAS_ACC")
812 }
813
814 if (result & 8)
815 {
816 client_cmd(id, "echo ^"* %L^"", id, "PRIV_SET")
817 }
818
819 return PLUGIN_CONTINUE
820}
821
822public client_infochanged(id)
823{
824 if (!is_user_connected(id) || !get_pcvar_num(amx_mode))
825 {
826 return PLUGIN_CONTINUE
827 }
828
829 new newname[32], oldname[32]
830
831 get_user_name(id, oldname, 31)
832 get_user_info(id, "name", newname, 31)
833
834 if (g_CaseSensitiveName[id])
835 {
836 if (!equal(newname, oldname))
837 {
838 accessUser(id, newname)
839 }
840 }
841 else
842 {
843 if (!equali(newname, oldname))
844 {
845 accessUser(id, newname)
846 }
847 }
848 return PLUGIN_CONTINUE
849}
850
851public ackSignal(id)
852{
853 server_cmd("kick #%d ^"%L^"", get_user_userid(id), id, "NO_ENTRY")
854 return PLUGIN_HANDLED
855}
856
857public client_authorized(id)
858 return accessUser(id)
859
860public client_putinserver(id)
861{
862 if (!is_dedicated_server() && id == 1)
863 return accessUser(id)
864
865 return PLUGIN_CONTINUE
866}