Guest User

Untitled

a guest
Jan 14th, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.48 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <fakemeta>
  3. #include <sqlx>
  4. #include <cstrike>
  5. #include <amxmisc>
  6. #include <fun>
  7.  
  8. #define VERSION "1.0"
  9. // 密碼最短長度
  10. #define PASSWORD_MIN_LEN 6
  11. #define MAX_LOGIN_ATTEMPTS 3
  12. #define BAN_TIME 3
  13. // user_activity 1 - 註冊中 2 - 登入中 3 - 輸入舊密碼 4 - 輸入新密碼
  14. new user_status[33],user_activity[33],user_len[33],user_password[33][33],user_wrong[33],mysqlx_host,mysqlx_user,mysqlx_db,mysqlx_pass,gmsgScreenFade,user_rest[33]
  15. new bool:user_putinserver[33]
  16. new Handle:g_hTuple
  17. new bool:user_connect[33]
  18. new const szTables[][] =
  19. {
  20. "CREATE TABLE IF NOT EXISTS `register_system` ( `user_id` varchar(64) NOT NULL,`user_password` varchar(128) default NULL,`user_ip` varchar(32) default NULL,PRIMARY KEY (`user_id`) ) TYPE=MyISAM;"
  21. }
  22.  
  23. public plugin_init()
  24. {
  25. gmsgScreenFade = get_user_msgid("ScreenFade")
  26. register_plugin("註冊/登入系統", VERSION, "slyh")
  27. register_clcmd("say", "user_say", ADMIN_ALL)
  28. register_clcmd("say /login", "user_login", ADMIN_ALL)
  29. register_event("ScreenFade","Event_ScreenFade","b")
  30. register_forward(FM_ClientUserInfoChanged, "Fwd_ClientInfoChanged")
  31. mysqlx_host = register_cvar ("regsys_host", "localhost")
  32. mysqlx_user = register_cvar ("regsys_user", "")
  33. mysqlx_pass = register_cvar ("regsys_pass", "")
  34. mysqlx_db = register_cvar ("regsys_dbname", "register_system")
  35. MySQLx_Init()
  36. }
  37.  
  38. public user_say(id,level,cid)
  39. {
  40. if( ( !cmd_access(id, level, cid, 2) ) || user_activity[id] == 0)
  41. return PLUGIN_CONTINUE
  42.  
  43. new name[32],message[128]
  44. get_user_name(id,name,31)
  45. switch(user_activity[id])
  46. {
  47. case 1:
  48. {
  49. new arg_pass[32]
  50. read_argv(1, arg_pass, 31)
  51. new len = strlen(arg_pass);
  52. if(len < PASSWORD_MIN_LEN || len > 20)
  53. {
  54. format(message,127,"^x04[hk-fun.com提醒你] ^x01密碼長度最少需有 %d 位, 最多不可超過 20 位, 請輸入一個新的密碼.",PASSWORD_MIN_LEN)
  55. client_color(id,id,message)
  56. client_cmd(id,"messagemode")
  57. return PLUGIN_HANDLED
  58. }
  59. format(message,127,"^x04[hk-fun.com提醒你] ^x01你已成功註冊, 請謹記你的密碼: %s .",arg_pass)
  60. access_user(id)
  61. client_color(id,id,message)
  62. user_password[id] = arg_pass
  63. user_status[id] = 3
  64. user_activity[id] = 0
  65. set_task(2.5,"Reset_Screen",id)
  66. set_task(3.0,"chooseteam",id)
  67. set_task(1.1,"hud_finish",id)
  68. client_cmd(id,"setinfo ^"_reg^" ^"%s^"",arg_pass)
  69. new name[32],ip[32]
  70. get_user_name(id,name,31)
  71. get_user_ip(id,ip,31,1)
  72. static szQuery[128];
  73. formatex( szQuery, 127, "REPLACE INTO `register_system` (`user_id`, `user_password`, `user_ip`) VALUES ('%s', '%s', '%s');",name,arg_pass,ip)
  74. SQL_ThreadQuery( g_hTuple, "QuerySetData", szQuery);
  75. return PLUGIN_HANDLED
  76. }
  77. case 2:
  78. {
  79. new arg_pass[32]
  80. read_argv(1, arg_pass, 31)
  81. user_password[id] = arg_pass
  82. LoadData(id)
  83. return PLUGIN_HANDLED
  84. }
  85. case 3:
  86. {
  87. new arg_pass[32]
  88. read_argv(1, arg_pass, 31)
  89. user_password[id] = arg_pass
  90. LoadData(id)
  91. return PLUGIN_HANDLED
  92. }
  93. case 4:
  94. {
  95. new arg_pass[32]
  96. read_argv(1, arg_pass, 31)
  97. new len = strlen(arg_pass);
  98. if(len < PASSWORD_MIN_LEN || len > 20)
  99. {
  100. format(message,127,"^x04[hk-fun.com提醒你] ^x01密碼長度最少需有 %d 位, 最多不可超過 20 位, 請輸入一個新的密碼.",PASSWORD_MIN_LEN)
  101. client_color(id,id,message)
  102. client_cmd(id,"messagemode")
  103. return PLUGIN_HANDLED
  104. }
  105. format(message,127,"^x04[hk-fun.com提醒你] ^x01你已成功更換密碼, 請謹記你的密碼: %s .",arg_pass)
  106. client_color(id,id,message)
  107. user_password[id] = arg_pass
  108. user_status[id] = 3
  109. user_activity[id] = 0
  110. set_task(2.5,"Reset_Screen",id)
  111. set_task(3.0,"chooseteam",id)
  112. set_task(1.1,"hud_finish",id)
  113. new name[32],ip[32]
  114. get_user_name(id,name,31)
  115. get_user_ip(id,ip,31,1)
  116. static szQuery[128];
  117. formatex( szQuery, 127, "REPLACE INTO `register_system` (`user_id`, `user_password`, `user_ip`) VALUES ('%s', '%s', '%s');",name,arg_pass,ip)
  118. SQL_ThreadQuery( g_hTuple, "QuerySetData", szQuery);
  119. return PLUGIN_HANDLED
  120. }
  121. }
  122. return PLUGIN_CONTINUE
  123. }
  124.  
  125. public QuerySelectData( iFailState, Handle:hQuery, szError[ ], iError, iData[ ], iDataSize, Float:fQueueTime )
  126. {
  127. if( iFailState == TQUERY_CONNECT_FAILED
  128. || iFailState == TQUERY_QUERY_FAILED )
  129. {
  130. log_amx( "%s", szError );
  131.  
  132. return;
  133. }
  134. else
  135. {
  136. new id = iData[ 0 ];
  137.  
  138. new password = SQL_FieldNameToNum(hQuery, "user_password")
  139. new pw[44]
  140. while (SQL_MoreResults(hQuery))
  141. {
  142. new name[32],message[128]
  143. get_user_name(id,name,31)
  144. SQL_ReadResult(hQuery, password, pw, sizeof(pw)-1)
  145. if(user_connect[id])
  146. {
  147. new password[32]
  148. user_len[id] = strlen(pw)
  149. user_connect[id] = false
  150. get_user_info(id, "_reg", password, 31)
  151. if(equali(pw, password))
  152. {
  153. user_status[id] = 3
  154. access_user(id)
  155. }
  156. else
  157. {
  158. if(user_putinserver[id])
  159. {
  160. set_task(1.0, "force_login", id, _, _, "a", 20)
  161. set_task(20.0,"check_user",id)
  162. }
  163. user_rest[id] = 20
  164. }
  165. }
  166. else
  167. {
  168. if(!equali(pw, user_password[id]))
  169. {
  170. format(message,127,"^x04[hk-fun.com提醒你] ^x01密碼錯誤, 你只有 %d 次機會.",MAX_LOGIN_ATTEMPTS)
  171. client_color(id,id,message)
  172. user_wrong[id] += 1
  173. client_cmd(id,"messagemode")
  174. if(user_wrong[id] >= MAX_LOGIN_ATTEMPTS)
  175. {
  176. format(message,127,"^x04[hk-fun.com提醒你] ^x01由於 ^x03%s^x01 輸入了 %d 次錯誤的密碼, 所以已被封禁 %d 分鐘.",name,MAX_LOGIN_ATTEMPTS,BAN_TIME)
  177. client_color(0,id,message)
  178. server_cmd("banid ^"%d^" ^"#%i^"",BAN_TIME,get_user_userid(id))
  179. server_cmd("kick #%i ^"由於你輸入了 %d 次錯誤的密碼, 所以已被封禁 %d 分鐘!^"",get_user_userid(id),MAX_LOGIN_ATTEMPTS,BAN_TIME);
  180. }
  181. }
  182. else
  183. {
  184. if(user_activity[id] == 3)
  185. {
  186. format(message,127,"^x04[hk-fun.com提醒你] ^x01已認證身份, 請輸入新密碼.")
  187. client_color(id,id,message)
  188. user_activity[id] = 4
  189. client_cmd(id,"messagemode")
  190. }
  191. else
  192. {
  193. format(message,127,"^x04[hk-fun.com提醒你] ^x01你已成功登入.")
  194. client_color(id,id,message)
  195. user_status[id] = 3
  196. user_activity[id] = 0
  197. set_task(2.5,"Reset_Screen",id)
  198. set_task(3.0,"chooseteam",id)
  199. set_task(1.1,"hud_finish",id)
  200. access_user(id)
  201. }
  202. }
  203. }
  204. SQL_NextRow(hQuery)
  205. }
  206. }
  207. }
  208.  
  209. public user_login(id)
  210. {
  211. if(user_status[id] == 3)
  212. {
  213. new menu = menu_create("\y歡迎使用登記系統, 你現已登入:", "login_menu_handler")
  214. menu_additem(menu, "\d註冊", "1", 0)
  215. menu_additem(menu, "\d登錄", "2", 0)
  216. menu_additem(menu, "\w更改密碼", "3", 0)
  217. //menu_additem(menu, "\d設定(暫未開放)", "4", 0)
  218. menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
  219. menu_display(id, menu, 0)
  220. return PLUGIN_HANDLED
  221. }
  222. if(user_len[id] >= PASSWORD_MIN_LEN)
  223. {
  224. new menu = menu_create("\y歡迎使用登記系統, 請完成登入程序:", "login_menu_handler")
  225. menu_additem(menu, "\d註冊", "1", 0)
  226. menu_additem(menu, "\w登錄", "2", 0)
  227. menu_additem(menu, "\d更改密碼", "3", 0)
  228. menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
  229. menu_display(id, menu, 0)
  230. return PLUGIN_HANDLED
  231. }
  232. else
  233. {
  234. new menu = menu_create("\y歡迎使用登記系統, 請完成註冊程序:", "login_menu_handler")
  235. menu_additem(menu, "\w註冊", "1", 0)
  236. menu_additem(menu, "\d登錄", "2", 0)
  237. menu_additem(menu, "\d更改密碼", "3", 0)
  238. menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
  239. menu_display(id, menu, 0)
  240. return PLUGIN_HANDLED
  241. }
  242. return PLUGIN_HANDLED
  243. }
  244.  
  245. public login_menu_handler(id, menu, item)
  246. {
  247. if( item == MENU_EXIT )
  248. {
  249. menu_destroy(menu)
  250. return PLUGIN_HANDLED
  251. }
  252.  
  253. new data[6], iName[64]
  254. new access, callback
  255.  
  256. menu_item_getinfo(menu, item, access, data,5, iName, 63, callback)
  257. new key = str_to_num(data)
  258. switch(key)
  259. {
  260. case 1:
  261. {
  262. if(user_status[id] != 3 && user_len[id] < PASSWORD_MIN_LEN)
  263. {
  264. user_activity[id] = 1
  265. if(is_user_alive(id))
  266. {
  267. user_kill(id)
  268. cs_set_user_deaths(id, cs_get_user_deaths(id) - 1)
  269. set_user_frags(id, get_user_frags(id) + 1 )
  270. }
  271. cs_set_user_team(id,CS_TEAM_SPECTATOR)
  272. Fade_To_Black(id)
  273. client_cmd(id,"messagemode")
  274. hud(id)
  275. }
  276. }
  277. case 2:
  278. {
  279. if(user_status[id] != 3 && user_len[id] >= PASSWORD_MIN_LEN)
  280. {
  281. user_activity[id] = 2
  282. if(is_user_alive(id))
  283. {
  284. user_kill(id)
  285. cs_set_user_deaths(id, cs_get_user_deaths(id) - 1)
  286. set_user_frags(id, get_user_frags(id) + 1 )
  287. }
  288. cs_set_user_team(id,CS_TEAM_SPECTATOR)
  289. Fade_To_Black(id)
  290. client_cmd(id,"messagemode")
  291. hud(id)
  292. }
  293. }
  294. case 3:
  295. {
  296. if(user_status[id] == 3)
  297. {
  298. user_activity[id] = 3
  299. if(is_user_alive(id))
  300. {
  301. user_kill(id)
  302. cs_set_user_deaths(id, cs_get_user_deaths(id) - 1)
  303. set_user_frags(id, get_user_frags(id) + 1 )
  304. }
  305. cs_set_user_team(id,CS_TEAM_SPECTATOR)
  306. Fade_To_Black(id)
  307. client_cmd(id,"messagemode")
  308. hud(id)
  309. }
  310. }
  311. case 4:
  312. {
  313. //setting_menu(id)
  314. }
  315. }
  316. menu_destroy(menu)
  317. return PLUGIN_HANDLED
  318. }
  319.  
  320. public setting_menu(id)
  321. {
  322. new menu = menu_create("\y系統設定:", "setting_menu_handler")
  323. menu_additem(menu, "\w返回主目錄", "2", 0)
  324. menu_setprop(menu, MPROP_EXIT, MEXIT_NEVER)
  325. menu_display(id, menu, 0)
  326. }
  327. public setting_menu_handler(id, menu, item)
  328. {
  329. if( item == MENU_EXIT )
  330. {
  331. menu_destroy(menu)
  332. return PLUGIN_HANDLED
  333. }
  334.  
  335. new data[6], iName[64]
  336. new access, callback
  337.  
  338. menu_item_getinfo(menu, item, access, data,5, iName, 63, callback)
  339. new key = str_to_num(data)
  340. switch(key)
  341. {
  342. case 2:
  343. {
  344. user_login(id)
  345. }
  346. }
  347. menu_destroy(menu)
  348. return PLUGIN_HANDLED
  349. }
  350.  
  351. public hud(id)
  352. {
  353. switch(user_activity[id])
  354. {
  355. case 1:
  356. {
  357. set_hudmessage(0, 0, 0, -1.0, -1.0, 2, 1.0, 1.0, 0.0, 0.0, -1)
  358. show_hudmessage(id, "你只要輸入密碼, 再按Enter, 即完成整個註冊過程!^n注意事項:^n1.密碼長度不得短於 %d 位^n2.密碼長度不得長於 20 位",PASSWORD_MIN_LEN)
  359. set_task(1.0,"hud",id)
  360. }
  361. case 2:
  362. {
  363. set_hudmessage(0, 0, 0, -1.0, -1.0, 2, 1.0, 1.0, 0.0, 0.0, -1)
  364. show_hudmessage(id, "你只要輸入密碼, 再按Enter, 即完成整個登入過程!^n注意事項:^n你只有 %d 次錯誤輸入密碼的機會,^n機會用盡後, 你將會被封禁 %d 分鐘!",MAX_LOGIN_ATTEMPTS,BAN_TIME)
  365. set_task(1.0,"hud",id)
  366. }
  367. case 3:
  368. {
  369. set_hudmessage(0, 0, 0, -1.0, -1.0, 2, 1.0, 1.0, 0.0, 0.0, -1)
  370. show_hudmessage(id, "請你輸入舊密碼以確認身份!")
  371. set_task(1.0,"hud",id)
  372. }
  373. case 4:
  374. {
  375. set_hudmessage(0, 0, 0, -1.0, -1.0, 2, 1.0, 1.0, 0.0, 0.0, -1)
  376. show_hudmessage(id, "你只要新輸入密碼, 再按Enter, 即完成整個密碼更換過程!^n注意事項:^n1.新密碼長度不得短於 %d 位^n2.新密碼長度不得長於 20 位",PASSWORD_MIN_LEN)
  377. set_task(1.0,"hud",id)
  378. }
  379. }
  380. }
  381.  
  382. public Event_ScreenFade(id)
  383. {
  384. if(user_activity[id] > 0)
  385. {
  386. Fade_To_Black(id)
  387. }
  388. }
  389.  
  390. public Fade_To_Black(id)
  391. {
  392. message_begin ( MSG_ONE_UNRELIABLE , gmsgScreenFade , _ , id ) ;
  393. write_short ( ( 1<<3 ) | ( 1<<8 ) | ( 1<<10 ) ) ;
  394. write_short ( ( 1<<3 ) | ( 1<<8 ) | ( 1<<10 ) ) ;
  395. write_short ( ( 1<<0 ) | ( 1<<2 ) ) ;
  396. write_byte ( 0 ) ;
  397. write_byte ( 0 ) ;
  398. write_byte ( 0 ) ;
  399. write_byte ( 255 ) ;
  400. message_end ( ) ;
  401. }
  402.  
  403. public Reset_Screen(id)
  404. {
  405. message_begin ( MSG_ONE_UNRELIABLE , gmsgScreenFade , _ , id ) ;
  406. write_short ( 1<<2 ) ;
  407. write_short ( 0 ) ;
  408. write_short ( 0 ) ;
  409. write_byte ( 0 ) ;
  410. write_byte ( 0 ) ;
  411. write_byte ( 0 ) ;
  412. write_byte ( 0 ) ;
  413. message_end ( ) ;
  414. }
  415.  
  416. public MySQLx_Init()
  417. {
  418. new szHost[64], szUser[32], szPass[32], szDB[128];
  419.  
  420. get_pcvar_string( mysqlx_host, szHost, charsmax( szHost ) );
  421. get_pcvar_string( mysqlx_user, szUser, charsmax( szUser ) );
  422. get_pcvar_string( mysqlx_pass, szPass, charsmax( szPass ) );
  423. get_pcvar_string( mysqlx_db, szDB, charsmax( szDB ) );
  424.  
  425. g_hTuple = SQL_MakeDbTuple( szHost, szUser, szPass, szDB );
  426.  
  427. for ( new i = 0; i < sizeof szTables; i++ )
  428. {
  429. SQL_ThreadQuery( g_hTuple, "QueryCreateTable", szTables[i])
  430. }
  431. }
  432.  
  433. public QueryCreateTable( iFailState, Handle:hQuery, szError[ ], iError, iData[ ], iDataSize, Float:fQueueTime )
  434. {
  435. if( iFailState == TQUERY_CONNECT_FAILED
  436. || iFailState == TQUERY_QUERY_FAILED )
  437. {
  438. log_amx( "%s", szError );
  439.  
  440. return;
  441. }
  442. }
  443.  
  444. public LoadData(id)
  445. {
  446. new name[32]
  447. get_user_name(id,name,31)
  448.  
  449. static szQuery[ 128 ], iData[ 1 ];
  450. formatex( szQuery, 127, "SELECT `user_password` FROM `register_system` WHERE ( `user_id` = '%s' );",name);
  451.  
  452. iData[ 0 ] = id;
  453. SQL_ThreadQuery( g_hTuple, "QuerySelectData", szQuery, iData, 1 );
  454. }
  455.  
  456. public QuerySetData( iFailState, Handle:hQuery, szError[ ], iError, iData[ ], iDataSize, Float:fQueueTime )
  457. {
  458. if( iFailState == TQUERY_CONNECT_FAILED
  459. || iFailState == TQUERY_QUERY_FAILED )
  460. {
  461. log_amx( "%s", szError );
  462.  
  463. return;
  464. }
  465. }
  466.  
  467. public plugin_natives()
  468. {
  469. register_native("get_user_status", "native_get_user_status", 1)
  470. register_native("get_user_pwlen", "native_get_user_pwlen", 1)
  471. }
  472.  
  473. public hud_finish(id)
  474. {
  475. set_hudmessage(0, 0, 0, -1.0, -1.0, 0, 0.0, 2.0, 0.0, 0.0, -1)
  476. show_hudmessage(id, "你已完成登入/註冊/更換密碼過程!")
  477. }
  478.  
  479. public client_connect(id)
  480. {
  481. user_putinserver[id] = false
  482. user_activity[id] = 0
  483. user_wrong[id] = 0
  484. user_status[id] = 0
  485. user_len[id] = 0
  486. user_connect[id] = true
  487. remove_task(id)
  488. LoadData(id)
  489. }
  490.  
  491. public client_putinserver(id)
  492. {
  493. user_putinserver[id] = true
  494. if(!user_connect[id])
  495. {
  496. set_task(1.0, "force_login", id, _, _, "a", 20)
  497. set_task(20.0,"check_user",id)
  498. }
  499. if( ( get_user_flags(id) & ADMIN_KICK ) && ( user_status[id] !=3 ) )
  500. {
  501. remove_user_flags(id)
  502. }
  503. set_task(1.0,"not_login",id+987654)
  504. }
  505. public messengmode(id)
  506. {
  507. client_cmd(id,"messagemode")
  508. }
  509.  
  510. public client_disconnect(id)
  511. {
  512. user_activity[id] = 0
  513. user_wrong[id] = 0
  514. user_status[id] = 0
  515. user_len[id] = 0
  516. remove_task(id)
  517. user_connect[id] = false
  518. }
  519.  
  520. public Fwd_ClientInfoChanged(id, buffer)
  521. {
  522. if (!is_user_connected(id))
  523. return FMRES_IGNORED;
  524.  
  525. static name[32], val[32];
  526. get_user_name(id, name, sizeof name - 1)
  527.  
  528. engfunc(EngFunc_InfoKeyValue, buffer, "name", val, sizeof val - 1);
  529.  
  530. if(equal(val, name))
  531. return FMRES_IGNORED;
  532.  
  533. engfunc(EngFunc_SetClientKeyValue, id, buffer, "name", name);
  534.  
  535. client_cmd(id, "name ^"%s^"; setinfo name ^"%s^"", name, name);
  536.  
  537. client_print(id, print_console, "遊戲中不允許更換名字.");
  538.  
  539. return FMRES_SUPERCEDE;
  540. }
  541.  
  542. public native_get_user_status(id)
  543. {
  544. return user_status[id]
  545. }
  546.  
  547. public native_get_user_pwlen(id)
  548. {
  549. return user_len[id]
  550. }
  551.  
  552. public chooseteam(id)
  553. {
  554. client_cmd(id,"chooseteam")
  555. }
  556.  
  557. public client_color(playerid, colorid, msg[]){
  558. message_begin(playerid?MSG_ONE:MSG_ALL,get_user_msgid("SayText"),{0,0,0},playerid)
  559. write_byte(colorid)
  560. write_string(msg)
  561. message_end()
  562. }
  563.  
  564. public not_login(taskid)
  565. {
  566. new id = taskid-987654
  567. if(user_status[id] != 3)
  568. {
  569. set_hudmessage(255, 0, 0, -1.0, 0.7, 0, 0.0, 0.1, 0.0, 0.0)
  570. show_hudmessage(id,"請說/login註冊/登錄, 否則你將受以下限制^n失去管理員權力")
  571. set_task(0.1,"not_login",id)
  572. }
  573. }
  574.  
  575. access_user(id)
  576. {
  577. remove_user_flags(id)
  578.  
  579. new userip[32], userauthid[32], password[32], username[32]
  580.  
  581. get_user_ip(id, userip, 31, 1)
  582. get_user_authid(id, userauthid, 31)
  583. get_user_name(id, username, 31)
  584.  
  585. get_user_info(id, "_pw", password, 31)
  586.  
  587. getAccess(id, username, userauthid, userip, password)
  588.  
  589. return PLUGIN_CONTINUE
  590. }
  591.  
  592. getAccess(id, name[], authid[], ip[], password[])
  593. {
  594. new index = -1
  595. new result = 0
  596.  
  597. static Count;
  598. static Flags;
  599. static Access;
  600. static AuthData[44];
  601. static Password[32];
  602.  
  603. Count=admins_num();
  604. for (new i = 0; i < Count; ++i)
  605. {
  606. Flags=admins_lookup(i,AdminProp_Flags);
  607. admins_lookup(i,AdminProp_Auth,AuthData,sizeof(AuthData)-1);
  608.  
  609. if (Flags & FLAG_AUTHID)
  610. {
  611. if (equal(authid, AuthData))
  612. {
  613. index = i
  614. break
  615. }
  616. }
  617. else if (Flags & FLAG_IP)
  618. {
  619. new c = strlen(AuthData)
  620.  
  621. if (AuthData[c - 1] == '.') /* check if this is not a xxx.xxx. format */
  622. {
  623. if (equal(AuthData, ip, c))
  624. {
  625. index = i
  626. break
  627. }
  628. } /* in other case an IP must just match */
  629. else if (equal(ip, AuthData))
  630. {
  631. index = i
  632. break
  633. }
  634. }
  635. else
  636. {
  637. if (Flags & FLAG_CASE_SENSITIVE)
  638. {
  639. if (Flags & FLAG_TAG)
  640. {
  641. if (contain(name, AuthData) != -1)
  642. {
  643. index = i
  644. break
  645. }
  646. }
  647. else if (equal(name, AuthData))
  648. {
  649. index = i
  650. break
  651. }
  652. }
  653. else
  654. {
  655. if (Flags & FLAG_TAG)
  656. {
  657. if (containi(name, AuthData) != -1)
  658. {
  659. index = i
  660. break
  661. }
  662. }
  663. else if (equali(name, AuthData))
  664. {
  665. index = i
  666. break
  667. }
  668. }
  669. }
  670. }
  671.  
  672. if (index != -1)
  673. {
  674. Access=admins_lookup(index,AdminProp_Access);
  675.  
  676. if (Flags & FLAG_NOPASS)
  677. {
  678. result |= 8
  679. new sflags[32]
  680.  
  681. get_flags(Access, sflags, 31)
  682. set_user_flags(id, Access)
  683.  
  684. log_amx("Login: ^"%s<%d><%s><>^" became an admin (account ^"%s^") (access ^"%s^") (address ^"%s^")", name, get_user_userid(id), authid, AuthData, sflags, ip)
  685. }
  686. else
  687. {
  688.  
  689. admins_lookup(index,AdminProp_Password,Password,sizeof(Password)-1);
  690.  
  691. if (equal(password, Password))
  692. {
  693. result |= 12
  694. set_user_flags(id, Access)
  695.  
  696. new sflags[32]
  697. get_flags(Access, sflags, 31)
  698.  
  699. log_amx("Login: ^"%s<%d><%s><>^" became an admin (account ^"%s^") (access ^"%s^") (address ^"%s^")", name, get_user_userid(id), authid, AuthData, sflags, ip)
  700. }
  701. else
  702. {
  703. result |= 1
  704.  
  705. if (Flags & FLAG_KICK)
  706. {
  707. result |= 2
  708. log_amx("Login: ^"%s<%d><%s><>^" kicked due to invalid password (account ^"%s^") (address ^"%s^")", name, get_user_userid(id), authid, AuthData, ip)
  709. }
  710. }
  711. }
  712. }
  713. }
  714.  
  715. public force_login(id)
  716. {
  717. if(user_status[id] != 3)
  718. {
  719. user_rest[id] -= 1
  720. set_hudmessage(255, 0, 0, -1.0, -1.0, 0, 0.0, 1.0, 0.0, 0.0)
  721. show_hudmessage(id,"你的暱稱已被使用,請登入或轉換另一個名字,否則你將會於 %i 秒後被踢除",user_rest[id]) //這行可以更改
  722. remove_task(id+987654)
  723. }
  724. }
  725.  
  726. public check_user(id)
  727. {
  728. if(user_status[id] != 3)
  729. {
  730. server_cmd("kick #%i ^"你因尚未登入而被踢除^"",get_user_userid(id)) // 這行也是可以更改
  731. }
  732. }
Add Comment
Please, Sign In to add comment