HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /*
  2. Copyright 2011 - 2012, m0skVi4a ;]
  3. Plugin created in Rousse, Bulgaria
  4.  
  5.  
  6. Plugin thread 1:
  7. https://forums.alliedmods.net/showthread.php?t=171460
  8.  
  9. Plugin thread 2:
  10. http://amxmodxbg.org/forum/viewtopic.php?t=37116
  11.  
  12. Original posted by m0skVi4a ;]
  13.  
  14.  
  15.  
  16. Description:
  17.  
  18. This is Register System. You can put a password to your name and if someone connect to the server with the same name he will be kicked if he does not login.
  19.  
  20.  
  21. Commands:
  22.  
  23. say /reg
  24. say_team /reg
  25. Open the register system menu
  26.  
  27.  
  28. CVARS:
  29.  
  30. "rs_on" - Is the plugin on(1) or off(0). Default: 1
  31. "rs_save_type" - Where to seve the information: to file(0) or to MySQL(1). Default: 0
  32. "rs_host" - The host for the database. Default: 127.0.0.1
  33. "rs_user" - The username for the database login. Default: root
  34. "rs_pass" - The password for the database login. Default:
  35. "rs_db" - The database name. Default: registersystem
  36. "rs_password_prefix" - The prefix of the setinfo for the Auto Login function. Default: _rspass
  37. "rs_register_time" - How much time has the client to register. If is set to 0 registration is not mandatory. Default: 0
  38. "rs_login_time" - How much time has the client to login if is registered. Default: 60.0
  39. "rs_messages" - What messages will be displayed when the client connect - only hud messages(1), only chat messages(2) or hud and chat messages(3). Default: 3
  40. "rs_password_len" - What is minimum length of the password. Default: 6
  41. "rs_attempts" - How much attempts has the client to login if he type wrong password. Default: 3
  42. "rs_chngpass_times" - How much times can the client change his password per map. Default: 3
  43. "rs_register_log" - Is it allowed the plugin to log in file when the client is registered. Default: 1
  44. "rs_chngpass_log" - Is it allowed the plugin to log in file when the client has change his password. Default: 1
  45. "rs_autologin_log" - Is it allowed the plugin to log in file when the client has change his Auto Login function. Default: 1
  46. "rs_name_change" - Which of the clients can change their names - all clients(0), all clients without Logged cients(1) or no one can(2). Default: 1
  47. "rs_blind" - Whether clients who have not Logged or who must Register be blinded. Default: 1
  48. "rs_chat" - Whether clients who have not Logged or who must Register chat's be blocked. Default: 1
  49. "rs_logout" - What to do when client Logout - kick him from the server(0) or wait to Login during the Login time(1). Default: 0
  50.  
  51.  
  52. All CVARS are without quotes
  53.  
  54.  
  55. Credits:
  56.  
  57. m0skVi4a ;] - for the idea and make the plugin
  58. ConnorMcLeod - for his help to block the name change for logged clients
  59. Sylwester - for the idea for the encrypt
  60. dark_style - for ideas in the plugin
  61.  
  62.  
  63. Changelog:
  64.  
  65. November 6, 2011 - V1.0 BETA:
  66. - First Release
  67.  
  68. November 20, 2011 - V1.1 FINAL
  69. - Fixed some bugs
  70. - Added hange Password function
  71. - Added Info/Help
  72. - Added cvars to show when the client is registered and change his password
  73. - Password are now encrypted for more safety
  74.  
  75. November 23, 2011 - V1.1 FINAL FIX 1
  76. - Fixed bug if the client type more than CVAR setted attempts passwords
  77.  
  78. November 28, 2011 - V1.1 FINAL FIX 2
  79. - Fixed bug if that the menu does not pop up when user connect
  80.  
  81. December 26, 2011 - V2.0
  82. - Fixed bug if player change his name and the system does not check the new name
  83. - Added block chooseteam if the client is registered but not logged
  84. - Added MySQL support
  85. - Added .cfg file to manually set the settings of the system
  86. - Added CVAR for to set which clients can change their names
  87. - Added auto login on changevel or client retry
  88.  
  89. December 27, 2011 - V2.0 FIX 1
  90. - Fixed bug with the kick function
  91.  
  92. January 3, 2012 - V2.0 FIX 2
  93. - Fixed bug with the auto login function that does not work on steam clients
  94.  
  95. January 24, 2012 - V3.0
  96. - Fixed bug with the MYSQL Connection
  97. - Added new style of the Change Password function
  98. - Removed some CVARs and added new
  99. - Now in the Register System file or into MYSQL table is not saving the date and time for registering or for changing password for the client. They are saving in special log file with name register_system_log.txt
  100.  
  101. February 17, 2012 - V4.0
  102. - Fixed some little bugs
  103. - Added new style of the main menu
  104. - Removed the possibility of SQL Injection
  105. - The whole name change function is rewritten
  106. - Added option for the not registered and not logged clients to be blinded
  107. - Added option for the not registered and not logged clients chat's to be blocked
  108. - Added showing information in the consoles of the clients about why they are kicked
  109.  
  110. February 19, 2012 - V4.0 FIX 1
  111. - Fixed bug with the join in the Spectator team
  112. - Added the Auto Assign option in the main menu
  113. - Small rewrite of the Auto Login function
  114.  
  115. March 10, 2012 - V5.0
  116. - Fixed bug with % that replace the space in the name of the client
  117. - Fixed the bug with the menu that stands when client choose team
  118. - Fixed some little bugs
  119. - Added new style of the main menu
  120.  
  121.  
  122. Visit www.forums.alliedmods.net
  123. Visit www.amxmodxbg.org
  124.  
  125.  
  126. Contact me on:
  127. E-MAIL: pvldimitrov@abv.bg
  128. SKYPE: pa7ohin
  129. */
  130.  
  131.  
  132. #include <amxmodx>
  133. #include <amxmisc>
  134. #include <cstrike>
  135. #include <fakemeta>
  136. #include <sqlx>
  137.  
  138. #define TASK_MESS 2133
  139. #define TASK_KICK 3312
  140. #define SALT "8c4f4370c53e0c1e1ae9acd577dddbed" //The SALT for the password encryption. It can be edited!
  141.  
  142. new g_on, g_save, g_host, g_user, g_pass, g_db, g_setinfo_pr, g_regtime, g_logtime, g_msg, g_pass_length, g_attempts, g_chp_time, g_reg_log, g_chp_log, g_aulog_log, g_name, g_blind, g_chat, g_logout; //cvar pointers
  143. new reg_file[256], configs_dir[64], file[192], params[2], name[32], check_name[32], check_pass[34], check_status[10], query[512], password[34][34], namepass[512], typedpass[32], new_pass[33][33], passsalt[64], hash[34], pass_prefix[32]; //arrays
  144. new bool:is_logged[33], bool:is_registered[33], bool:is_autolog[33], attempts[33], times[33]; //Booleans and other arrays
  145. new menu[512], keys, length; //variables and array for the menus
  146. new Handle:g_SQLTuple, g_error[512]; //SQL array and handle
  147. new g_saytxt, g_screenfade; //other variables
  148. new const prefix[] = "[Regisztracios Rendszer]"; //The prefix in the chat messages. It can be edited!
  149. new const log_file[] = "register_system_log.txt"; //The name of the log file. It can be edited!
  150. new const JOIN_TEAM_MENU_FIRST[] = "#Team_Select"; //The text of the Team Select menu. DO NOT CHANGE!
  151. new const JOIN_TEAM_MENU_FIRST_SPEC[] = "#Team_Select_Spect"; //The text of the Spectator Team Select menu. DO NOT CHANGE!
  152. new const JOIN_TEAM_MENU_INGAME[] = "#IG_Team_Select"; //The text of the Ingame Team Select menu. DO NOT CHANGE!
  153. new const JOIN_TEAM_MENU_INGAME_SPEC[] = "#IG_Team_Select_Spect"; //The text of the Ingame Spectator Team Select menu. DO NOT CHANGE!
  154. new const JOIN_TEAM_VGUI_MENU = 2; //The number of the VGUI menu for Team Select. DO NOT CHANGE!
  155. new const NAME_CHANGE_MSG[] = "#Cstrike_Name_Change"; ////The text of the Name Change Message. DO NOT CHANGE!
  156.  
  157. /*==============================================================================
  158. Start of Plugin Init
  159. ================================================================================*/
  160. public plugin_init()
  161. {
  162. register_plugin("Register System", "5.0", "m0skVi4a ;]")
  163.  
  164. g_on = register_cvar("rs_on", "1") //Is the plugin on(1) or off(0)
  165. g_save = register_cvar("rs_save_type", "0") //Where to seve the information: to file(0) or to MySQL(1).
  166. g_host = register_cvar("rs_host", "127.0.0.1") //The host for the database.
  167. g_user = register_cvar("rs_user", "root") //The username for the database login.
  168. g_pass = register_cvar("rs_pass", "") //The password for the database login.
  169. g_db = register_cvar("rs_db", "registersystem") //The database name.
  170. g_setinfo_pr = register_cvar("rs_password_prefix", "_rspass") //The prefix of the setinfo for the auto login.
  171. g_regtime = register_cvar("rs_register_time", "0") //How much time has the client to register. If is set to 0 registration is not mandatory.
  172. g_logtime = register_cvar("rs_login_time", "60.0") //How much time has the client to login if is registered.
  173. g_msg = register_cvar("rs_messages", "3") //What messages will be displayed when the client connect - only hud messages(1), only chat messages(2) or hud and chat messages(3).
  174. g_pass_length = register_cvar("rs_password_length", "6") //What is minimum length of the password.
  175. g_attempts = register_cvar("rs_attempts", "3") //How much attempts has the client to login if he type wrong password.
  176. g_chp_time = register_cvar("rs_chngpass_times", "3") //How much times can the client change his password per map.
  177. g_reg_log = register_cvar("rs_register_log", "1") //Is it allowed the plugin to log in file when the client is registered.
  178. g_chp_log = register_cvar("rs_chngpass_log", "1") //Is it allowed the plugin to log in file when the client has change his password.
  179. g_aulog_log = register_cvar("rs_autologin_log", "1") //Is it allowed the plugin to log in file when the client has change his Auto Login function.
  180. g_name = register_cvar("rs_name_change", "1") //Which of the clients can change their names - all clients(0), all clients without Logged cients(2) or no one can(3).
  181. g_blind = register_cvar("rs_blind", "1") //Whether clients who have not Logged or who must Register be blinded.
  182. g_chat = register_cvar("rs_chat", "1") //Whether clients who have not Logged or who must Register chat's be blocked.
  183. g_logout = register_cvar("rs_logout", "0") //What to do when client Logout - kick him from the server(0) or wait to Login during the Login time(1).
  184.  
  185. register_message(get_user_msgid("ShowMenu"), "ShowMenu")
  186. register_message(get_user_msgid("VGUIMenu"), "VGUIMenu")
  187. register_menucmd(register_menuid("Main Menu"), 1023, "HandlerMainMenu")
  188. register_menucmd(register_menuid("Options Menu"), 1023, "HandlerOptionsMenu")
  189. register_menucmd(register_menuid("Password Menu"), 1023, "HandlerConfirmPasswordMenu")
  190. register_clcmd("jointeam", "HookJoinCommands")
  191. register_clcmd("chooseteam", "HookJoinCommands")
  192. register_clcmd("say", "HookSayCommands")
  193. register_clcmd("say_team", "HookSayCommands")
  194. register_clcmd("LOGIN_PASS", "Login")
  195. register_clcmd("REGISTER_PASS", "Register")
  196. register_clcmd("CHANGE_PASS_NEW", "ChangePasswordNew")
  197. register_clcmd("CHANGE_PASS_OLD", "ChangePasswordOld")
  198. register_clcmd("AUTO_LOGIN_PASS", "AutoLoginPassword")
  199.  
  200. register_forward(FM_PlayerPreThink, "PlayerPreThink")
  201. register_forward(FM_ClientUserInfoChanged, "ClientInfoChanged")
  202.  
  203. register_dictionary("register_system.txt")
  204. g_saytxt = get_user_msgid("SayText")
  205. g_screenfade = get_user_msgid("ScreenFade")
  206. }
  207. /*==============================================================================
  208. End of Plugin Init
  209. ================================================================================*/
  210.  
  211. /*==============================================================================
  212. Start of Executing plugin's config and choose the save mode
  213. ================================================================================*/
  214. public plugin_cfg()
  215. {
  216. if(!get_pcvar_num(g_on))
  217. return PLUGIN_HANDLED
  218.  
  219. get_configsdir(configs_dir, charsmax(configs_dir))
  220. formatex(file, charsmax(file), "%s/registersystem.cfg", configs_dir)
  221.  
  222. if(!file_exists(file))
  223. {
  224. server_print("%L", LANG_SERVER, "ERROR_CFG", file)
  225. }
  226. else
  227. {
  228. server_cmd("exec %s", file)
  229. server_print("%L", LANG_SERVER, "CFG_EXEC", file)
  230. }
  231.  
  232. if(get_pcvar_num(g_save))
  233. {
  234. new Host[64], User[32], Pass[32], DB[128];
  235.  
  236. get_pcvar_string(g_host, Host, charsmax(Host))
  237. get_pcvar_string(g_user, User, charsmax(User))
  238. get_pcvar_string(g_pass, Pass, charsmax(Pass))
  239. get_pcvar_string(g_db, DB, charsmax(DB))
  240.  
  241. g_SQLTuple = SQL_MakeDbTuple(Host, User, Pass, DB)
  242.  
  243. new errorcode, Handle:SqlConnection = SQL_Connect(g_SQLTuple, errorcode, g_error, charsmax(g_error))
  244.  
  245. if(SqlConnection == Empty_Handle)
  246. {
  247. server_print("%L", LANG_SERVER, "ERROR_MYSQL")
  248. set_fail_state(g_error)
  249. }
  250. else
  251. {
  252. server_print("%L", LANG_SERVER, "MYSQL_CONNECT")
  253. }
  254.  
  255. new Handle:Query
  256.  
  257. Query = SQL_PrepareQuery(SqlConnection, "CREATE TABLE IF NOT EXISTS registersystem (Name VARCHAR(32), Password VARCHAR(34), Status VARCHAR(10))")
  258.  
  259. if(!SQL_Execute(Query))
  260. {
  261. SQL_QueryError(Query, g_error, charsmax(g_error))
  262. set_fail_state(g_error)
  263. }
  264.  
  265. SQL_FreeHandle(Query)
  266. SQL_FreeHandle(SqlConnection)
  267. }
  268. else
  269. {
  270. get_configsdir(configs_dir, charsmax(configs_dir))
  271. formatex(reg_file, charsmax(reg_file), "%s/regusers.ini", configs_dir)
  272.  
  273. if(!file_exists(reg_file))
  274. {
  275. write_file(reg_file,";Register System file^n;Modifying may cause the clients to can not Login!^n^n")
  276. server_print("%L", LANG_SERVER, "ERROR_FILE", reg_file)
  277. }
  278. }
  279. return PLUGIN_CONTINUE
  280. }
  281. /*==============================================================================
  282. End of Executing plugin's config and choose the save mode
  283. ================================================================================*/
  284.  
  285. /*==============================================================================
  286. Start of Client's connect and disconenct functions
  287. ================================================================================*/
  288. public client_connect(id)
  289. {
  290. is_logged[id] = false
  291. is_registered[id] = false
  292. is_autolog[id] = false
  293. attempts[id] = 0
  294. times[id] = 0
  295. remove_task(id+TASK_MESS)
  296. CheckClient(id)
  297. }
  298.  
  299. public client_putinserver(id)
  300. {
  301. ShowMsg(id)
  302. }
  303.  
  304. public client_disconnect(id)
  305. {
  306. is_logged[id] = false
  307. is_registered[id] = false
  308. is_autolog[id] = false
  309. attempts[id] = 0
  310. times[id] = 0
  311. remove_task(id+TASK_MESS)
  312. remove_task(id+TASK_KICK)
  313. }
  314. /*==============================================================================
  315. End of Client's connect and disconenct functions
  316. ================================================================================*/
  317.  
  318. /*==============================================================================
  319. Start of Show Menu functions
  320. ================================================================================*/
  321. public ShowMenu(msgid, dest, id)
  322. {
  323. if(get_pcvar_num(g_on))
  324. {
  325. new menu_text[64]
  326.  
  327. get_msg_arg_string(4, menu_text, charsmax(menu_text))
  328.  
  329. if(equal(menu_text, JOIN_TEAM_MENU_FIRST) || equal(menu_text, JOIN_TEAM_MENU_FIRST_SPEC) || equal(menu_text, JOIN_TEAM_MENU_INGAME) || equal(menu_text, JOIN_TEAM_MENU_INGAME_SPEC))
  330. {
  331. Menu(id)
  332.  
  333. return PLUGIN_HANDLED
  334. }
  335.  
  336. return PLUGIN_CONTINUE
  337. }
  338. return PLUGIN_CONTINUE
  339. }
  340.  
  341. public VGUIMenu(msgid, dest, id)
  342. {
  343. if(get_pcvar_num(g_on))
  344. {
  345. if(get_msg_arg_int(1) == JOIN_TEAM_VGUI_MENU)
  346. {
  347. Menu(id)
  348.  
  349. return PLUGIN_HANDLED
  350. }
  351.  
  352. return PLUGIN_CONTINUE
  353. }
  354.  
  355. return PLUGIN_CONTINUE
  356. }
  357. /*==============================================================================
  358. End of Show Menu functions
  359. ================================================================================*/
  360.  
  361. /*==============================================================================
  362. Start of Check Client functions
  363. ================================================================================*/
  364. public CheckClient(id)
  365. {
  366. if(!get_pcvar_num(g_on) || is_user_bot(id))
  367. return PLUGIN_HANDLED
  368.  
  369. is_registered[id] = false
  370. is_autolog[id] = false
  371. is_logged[id] = false
  372. remove_task(id+TASK_KICK)
  373.  
  374. if(get_pcvar_num(g_save))
  375. {
  376. get_user_name(id, name, charsmax(name))
  377.  
  378. new data[1]
  379. data[0] = id
  380.  
  381. formatex(query, charsmax(query), "SELECT `Password`, `Status` FROM `registersystem` WHERE Name = ^"%s^";", name)
  382.  
  383. SQL_ThreadQuery(g_SQLTuple, "QuerySelectData", query, data, 1)
  384. }
  385. else
  386. {
  387. new file = fopen(reg_file, "r")
  388.  
  389. while(!feof(file))
  390. {
  391. get_user_name(id, name, charsmax(name))
  392. fgets(file, namepass, charsmax(namepass))
  393. parse(namepass, check_name, charsmax(check_name), check_pass, charsmax(check_pass), check_status, charsmax(check_status))
  394.  
  395. if(namepass[0] == ';')
  396. continue
  397.  
  398. if(equal(check_name, name))
  399. {
  400. is_registered[id] = true
  401. password[id] = check_pass
  402.  
  403. if(is_user_connected(id))
  404. {
  405. user_silentkill(id)
  406. cs_set_user_team(id, CS_TEAM_UNASSIGNED)
  407. ShowMsg(id)
  408. Menu(id)
  409. }
  410.  
  411. if(equal(check_status, "LOGGED"))
  412. {
  413. is_autolog[id] = true
  414. CheckAutoLogin(id)
  415. }
  416.  
  417. break
  418. }
  419. }
  420. fclose(file)
  421. }
  422. return PLUGIN_CONTINUE
  423. }
  424.  
  425. public QuerySelectData(FailState, Handle:Query, error[], errorcode, data[], datasize, Float:fQueueTime)
  426. {
  427. if(FailState == TQUERY_CONNECT_FAILED || FailState == TQUERY_QUERY_FAILED)
  428. {
  429. log_amx("%s", error)
  430. return
  431. }
  432. else
  433. {
  434. new id = data[0];
  435. new col_pass = SQL_FieldNameToNum(Query, "Password")
  436. new col_status = SQL_FieldNameToNum(Query, "Status")
  437.  
  438. while(SQL_MoreResults(Query))
  439. {
  440. SQL_ReadResult(Query, col_pass, check_pass, charsmax(check_pass))
  441. SQL_ReadResult(Query, col_status, check_status, charsmax(check_status))
  442. is_registered[id] = true
  443. password[id] = check_pass
  444.  
  445. if(is_user_connected(id))
  446. {
  447. user_silentkill(id)
  448. cs_set_user_team(id, CS_TEAM_UNASSIGNED)
  449. ShowMsg(id)
  450. Menu(id)
  451. }
  452.  
  453. if(equal(check_status, "LOGGED"))
  454. {
  455. is_autolog[id] = true
  456. CheckAutoLogin(id)
  457. }
  458. SQL_NextRow(Query)
  459. }
  460. }
  461. }
  462.  
  463. public CheckAutoLogin(id)
  464. {
  465. new client_password[32];
  466. get_pcvar_string(g_setinfo_pr, pass_prefix, charsmax(pass_prefix))
  467. get_user_info(id, pass_prefix, client_password, charsmax(client_password))
  468. formatex(passsalt, charsmax(passsalt), "%s%s", client_password, SALT)
  469. md5(passsalt, hash)
  470.  
  471. if(equal(hash, password[id]))
  472. {
  473. is_logged[id] = true
  474. }
  475. }
  476. /*==============================================================================
  477. End of Check Client functions
  478. ================================================================================*/
  479.  
  480. /*==============================================================================
  481. Start of Show Client's informative messages
  482. ================================================================================*/
  483. public ShowMsg(id)
  484. {
  485. if(!get_pcvar_num(g_on))
  486. return PLUGIN_HANDLED
  487.  
  488. set_task(5.0, "Messages", id+TASK_MESS)
  489.  
  490. params[0] = id
  491.  
  492. if(!is_registered[id])
  493. {
  494. if(get_pcvar_float(g_regtime) != 0)
  495. {
  496. params[1] = 1
  497. set_task(get_pcvar_float(g_regtime), "KickPlayer", id+TASK_KICK, params, sizeof params)
  498. return PLUGIN_HANDLED
  499. }
  500. }
  501. else
  502. {
  503. params[1] = 2
  504. set_task(get_pcvar_float(g_logtime), "KickPlayer", id+TASK_KICK, params, sizeof params)
  505. return PLUGIN_HANDLED
  506. }
  507. return PLUGIN_CONTINUE
  508. }
  509.  
  510. public Messages(id)
  511. {
  512. id -= TASK_MESS
  513.  
  514. if(get_pcvar_num(g_msg) == 1 || get_pcvar_num(g_msg) == 3)
  515. {
  516. if(!is_registered[id])
  517. {
  518. if(get_pcvar_float(g_regtime) != 0)
  519. {
  520. set_hudmessage(255, 0, 0, -1.0, -1.0, 0, 0.5, 5.0, 2.0, 2.0, -1)
  521. show_hudmessage(id, "%L", LANG_SERVER, "REGISTER_HUD", get_pcvar_num(g_regtime))
  522. }
  523. else
  524. {
  525. set_hudmessage(0, 255, 0, -1.0, -1.0, 0, 0.5, 5.0, 2.0, 2.0, -1)
  526. show_hudmessage(id, "%L", LANG_SERVER, "YOUCANREG_HUD", get_pcvar_num(g_regtime))
  527. }
  528. }
  529. else if(!is_logged[id])
  530. {
  531. set_hudmessage(255, 0, 0, -1.0, -1.0, 0, 0.5, 5.0, 2.0, 2.0, -1)
  532. show_hudmessage(id, "%L", LANG_SERVER, "LOGIN_HUD", get_pcvar_num(g_logtime))
  533. }
  534. else if(is_autolog[id])
  535. {
  536. set_hudmessage(0, 255, 0, -1.0, -1.0, 0, 0.5, 5.0, 2.0, 2.0, -1)
  537. show_hudmessage(id, "%L", LANG_SERVER, "AUTO_LOGIN_HUD")
  538. }
  539. }
  540.  
  541. if(get_pcvar_num(g_msg) == 2 || get_pcvar_num(g_msg) == 3)
  542. {
  543. if(!is_registered[id])
  544. {
  545. if(get_pcvar_float(g_regtime) != 0)
  546. {
  547. client_printcolor(id, "%L", LANG_SERVER, "REGISTER_CHAT", prefix, get_pcvar_num(g_regtime))
  548. }
  549. else
  550. {
  551. client_printcolor(id, "%L", LANG_SERVER, "YOUCANREG_CHAT", prefix, get_pcvar_num(g_regtime))
  552. }
  553. }
  554. else if(!is_logged[id])
  555. {
  556. client_printcolor(id, "%L", LANG_SERVER, "LOGIN_CHAT", prefix, get_pcvar_num(g_logtime))
  557. }
  558. else if(is_autolog[id])
  559. {
  560. client_printcolor(id, "%L", LANG_SERVER, "AUTO_LOGIN_CHAT", prefix)
  561. }
  562. }
  563. }
  564. /*==============================================================================
  565. End of Show Client's informative messages
  566. ================================================================================*/
  567.  
  568. /*==============================================================================
  569. Start of Hook Client's jointeam commands
  570. ================================================================================*/
  571. public HookJoinCommands(id)
  572. {
  573. if(get_pcvar_num(g_on))
  574. {
  575. if((!is_registered[id] && get_pcvar_float(g_regtime)) || (is_registered[id] && !is_logged[id]))
  576. {
  577. Menu(id)
  578. return PLUGIN_HANDLED
  579. }
  580.  
  581. return PLUGIN_CONTINUE
  582. }
  583.  
  584. return PLUGIN_CONTINUE
  585. }
  586. /*==============================================================================
  587. End of Hook Client's jointeam commands
  588. ================================================================================*/
  589.  
  590. /*==============================================================================
  591. Start of Hook Client's say commands
  592. ================================================================================*/
  593. public HookSayCommands(id)
  594. {
  595. new g_message[16];
  596. read_args(g_message, charsmax(g_message))
  597. remove_quotes(g_message)
  598.  
  599. if(get_pcvar_num(g_on))
  600. {
  601. if(equal(g_message, "/reg"))
  602. {
  603. Menu(id)
  604. }
  605. else if(get_pcvar_num(g_chat))
  606. {
  607. if(!is_registered[id] && get_pcvar_float(g_regtime))
  608. {
  609. client_printcolor(id, "%L", LANG_SERVER, "CHAT_REG", prefix)
  610. return PLUGIN_HANDLED
  611. }
  612. else if(is_registered[id] && !is_logged[id])
  613. {
  614. client_printcolor(id, "%L", LANG_SERVER, "CHAT_LOG", prefix)
  615. return PLUGIN_HANDLED
  616. }
  617. }
  618. }
  619.  
  620. return PLUGIN_CONTINUE
  621. }
  622. /*==============================================================================
  623. End of Hook Client's say commands
  624. ================================================================================*/
  625.  
  626. /*==============================================================================
  627. Start of the Main Menu function
  628. ================================================================================*/
  629. public Menu(id)
  630. {
  631. if(!get_pcvar_num(g_on) || !is_user_connected(id))
  632. return PLUGIN_HANDLED
  633.  
  634. length = 0
  635.  
  636. if(is_registered[id])
  637. {
  638. if(is_logged[id])
  639. {
  640. length += formatex(menu[length], charsmax(menu) - length, "%L", LANG_SERVER, "MAIN_MENU_LOG")
  641. keys = MENU_KEY_1|MENU_KEY_2|MENU_KEY_5|MENU_KEY_6|MENU_KEY_7|MENU_KEY_9|MENU_KEY_0
  642. }
  643. else
  644. {
  645. length += formatex(menu[length], charsmax(menu) - length, "%L", LANG_SERVER, "MAIN_MENU_REG")
  646. keys = MENU_KEY_7|MENU_KEY_9
  647. }
  648. }
  649. else
  650. {
  651. if(get_pcvar_float(g_regtime) == 0)
  652. {
  653. length += formatex(menu[length], charsmax(menu) - length, "%L", LANG_SERVER, "MAIN_MENU_NOTREG")
  654. keys = MENU_KEY_1|MENU_KEY_2|MENU_KEY_5|MENU_KEY_6|MENU_KEY_8|MENU_KEY_9|MENU_KEY_0
  655. }
  656. else
  657. {
  658. length += formatex(menu[length], charsmax(menu) - length, "%L", LANG_SERVER, "MAIN_MENU_NOTREG_FORCE")
  659. keys = MENU_KEY_8|MENU_KEY_9
  660. }
  661. }
  662. show_menu(id, keys, menu, -1, "Main Menu")
  663.  
  664. return PLUGIN_CONTINUE
  665. }
  666.  
  667. public HandlerMainMenu(id, key)
  668. {
  669. switch(key)
  670. {
  671. case 0:
  672. {
  673. client_cmd(id, "jointeam 1")
  674. }
  675. case 1:
  676. {
  677. client_cmd(id, "jointeam 2")
  678. }
  679. case 4:
  680. {
  681. client_cmd(id, "jointeam 5")
  682. }
  683. case 5:
  684. {
  685. client_cmd(id, "jointeam 6")
  686. }
  687. case 6:
  688. {
  689. if(!is_logged[id])
  690. {
  691. client_cmd(id, "messagemode LOGIN_PASS")
  692. Menu(id)
  693. }
  694. else
  695. {
  696. is_logged[id] = false
  697.  
  698. if(is_autolog[id])
  699. {
  700. AutoLogin(id)
  701. }
  702. get_pcvar_string(g_setinfo_pr, pass_prefix, charsmax(pass_prefix))
  703. client_cmd(id, "setinfo %s ^"^"", pass_prefix)
  704. client_printcolor(id, "%L", LANG_SERVER, "LOG_OUT", prefix)
  705.  
  706. if(get_pcvar_num(g_logout))
  707. {
  708. ShowMsg(id)
  709. Menu(id)
  710. }
  711. else
  712. {
  713. params[0] = id
  714. params[1] = 4
  715. set_task(2.0, "KickPlayer", id+TASK_KICK, params, sizeof params)
  716. }
  717. }
  718. }
  719. case 7:
  720. {
  721. client_cmd(id, "messagemode REGISTER_PASS")
  722. Menu(id)
  723. }
  724. case 8:
  725. {
  726. OptionsMenu(id)
  727. }
  728. case 9:
  729. {
  730. return PLUGIN_HANDLED
  731. }
  732. }
  733. return PLUGIN_HANDLED
  734. }
  735. /*==============================================================================
  736. End of the Main Menu function
  737. ================================================================================*/
  738.  
  739. /*==============================================================================
  740. Start of the Options Menu function
  741. ================================================================================*/
  742. public OptionsMenu(id)
  743. {
  744. if(!get_pcvar_num(g_on) || !is_user_connected(id))
  745. return PLUGIN_HANDLED
  746.  
  747. length = 0
  748.  
  749. if(is_logged[id])
  750. {
  751. if(is_autolog[id])
  752. {
  753. length += formatex(menu[length], charsmax(menu) - length, "%L", LANG_SERVER, "OPTIONS_MENU_LOG_ON")
  754. }
  755. else
  756. {
  757. length += formatex(menu[length], charsmax(menu) - length, "%L", LANG_SERVER, "OPTIONS_MENU_LOG_OFF")
  758. }
  759. keys = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_0
  760. }
  761. else
  762. {
  763. length += formatex(menu[length], charsmax(menu) - length, "%L", LANG_SERVER, "OPTIONS_MENU_NOT_LOG")
  764. keys = MENU_KEY_3|MENU_KEY_0
  765. }
  766.  
  767. show_menu(id, keys, menu, -1, "Options Menu")
  768.  
  769. return PLUGIN_CONTINUE
  770. }
  771.  
  772. public HandlerOptionsMenu(id, key)
  773. {
  774. switch(key)
  775. {
  776. case 0:
  777. {
  778. if(times[id] >= get_pcvar_num(g_chp_time))
  779. {
  780. client_printcolor(id, "%L", LANG_SERVER, "CHANGE_TIMES", prefix, get_pcvar_num(g_chp_time))
  781. return PLUGIN_HANDLED
  782. }
  783. else
  784. {
  785. client_cmd(id, "messagemode CHANGE_PASS_NEW")
  786. }
  787. OptionsMenu(id)
  788. }
  789. case 1:
  790. {
  791. if(is_autolog[id])
  792. {
  793. AutoLogin(id)
  794. }
  795. else
  796. {
  797. client_cmd(id, "messagemode AUTO_LOGIN_PASS")
  798. }
  799. OptionsMenu(id)
  800. }
  801. case 2:
  802. {
  803. Info(id)
  804. OptionsMenu(id)
  805. }
  806. case 9:
  807. {
  808. Menu(id)
  809. return PLUGIN_HANDLED
  810. }
  811. }
  812. return PLUGIN_HANDLED
  813. }
  814. /*==============================================================================
  815. End of the Options Menu function
  816. ================================================================================*/
  817.  
  818. /*==============================================================================
  819. Start of Client's Auto Login Changer function
  820. ================================================================================*/
  821. public AutoLogin(id)
  822. {
  823. get_user_name(id, name, charsmax(name))
  824.  
  825. if(!is_registered[id] || !is_logged[id])
  826. return PLUGIN_HANDLED
  827.  
  828. if(get_pcvar_num(g_save))
  829. {
  830. formatex(query, charsmax(query), "UPDATE registersystem SET Status = ^"%s^" WHERE Name = ^"%s^";", is_autolog[id] == true ? "" : "LOGGED", name)
  831. SQL_ThreadQuery(g_SQLTuple, "QuerySetData", query)
  832. }
  833. else
  834. {
  835. new line, file = fopen(reg_file, "r");
  836.  
  837. while(!feof(file))
  838. {
  839. fgets(file, namepass, 255)
  840. parse(namepass, namepass, charsmax(namepass))
  841. line++
  842.  
  843. if(equal(namepass, name))
  844. {
  845. formatex(namepass, charsmax(namepass), "^"%s^" ^"%s^" ^"%s^"", name, password[id], is_autolog[id] == true ? "" : "LOGGED")
  846. write_file(reg_file, namepass, line - 1)
  847.  
  848. break
  849. }
  850. }
  851. fclose(file)
  852. }
  853.  
  854. if(is_autolog[id])
  855. {
  856. is_autolog[id] = false
  857. client_printcolor(id, "%L", LANG_SERVER, "AUTO_LOGIN_OFF", prefix)
  858. get_pcvar_string(g_setinfo_pr, pass_prefix, charsmax(pass_prefix))
  859. client_cmd(id, "setinfo %s ^"^"", pass_prefix)
  860.  
  861. if(get_pcvar_num(g_aulog_log))
  862. {
  863. log_to_file(log_file, "%L", LANG_SERVER, "LOGFILE_AUTO_OFF", name)
  864. }
  865. }
  866. else
  867. {
  868. is_autolog[id] = true
  869. client_printcolor(id, "%L", LANG_SERVER, "AUTO_LOGIN_ON", prefix)
  870. if(get_pcvar_num(g_aulog_log))
  871. {
  872. log_to_file(log_file, "%L", LANG_SERVER, "LOGFILE_AUTO_ON", name)
  873. }
  874. }
  875.  
  876. return PLUGIN_CONTINUE
  877. }
  878.  
  879. public AutoLoginPassword(id)
  880. {
  881. if(!get_pcvar_num(g_on))
  882. return PLUGIN_HANDLED
  883.  
  884. read_args(typedpass, charsmax(typedpass))
  885. remove_quotes(typedpass)
  886. formatex(passsalt, charsmax(passsalt), "%s%s", typedpass, SALT)
  887. md5(passsalt, hash)
  888.  
  889. if(!equal(hash, password[id]))
  890. {
  891. client_printcolor(id, "%L", LANG_SERVER, "AUTO_LOGIN_PASS_NOTVALID", prefix)
  892. client_cmd(id, "messagemode AUTO_LOGIN_PASS")
  893. return PLUGIN_HANDLED
  894. }
  895. else
  896. {
  897. get_pcvar_string(g_setinfo_pr, pass_prefix, charsmax(pass_prefix))
  898. client_cmd(id, "setinfo %s %s", pass_prefix, typedpass)
  899. AutoLogin(id)
  900. OptionsMenu(id)
  901. }
  902. return PLUGIN_CONTINUE
  903. }
  904. /*==============================================================================
  905. End of Client's Auto Login Changer function
  906. ================================================================================*/
  907.  
  908. /*==============================================================================
  909. Start of Info/Help MOTD function
  910. ================================================================================*/
  911. public Info(id)
  912. {
  913. show_motd(id, "rshelpmotd.txt", "Regisztracios rendszer Segitseg")
  914. }
  915. /*==============================================================================
  916. End of Info/Help MOTD function
  917. ================================================================================*/
  918.  
  919. /*==============================================================================
  920. Start of Login function
  921. ================================================================================*/
  922. public Login(id)
  923. {
  924. if(!get_pcvar_num(g_on))
  925. return PLUGIN_HANDLED
  926.  
  927. if(!is_registered[id])
  928. {
  929. client_printcolor(id, "%L", LANG_SERVER, "LOG_NOTREG", prefix)
  930. return PLUGIN_HANDLED
  931. }
  932.  
  933. if(is_logged[id])
  934. {
  935. client_printcolor(id, "%L", LANG_SERVER, "LOG_LOGGED", prefix);
  936. return PLUGIN_HANDLED
  937. }
  938.  
  939. read_args(typedpass, charsmax(typedpass))
  940. remove_quotes(typedpass)
  941.  
  942. if(equal(typedpass, ""))
  943. return PLUGIN_HANDLED
  944.  
  945. formatex(passsalt, charsmax(passsalt), "%s%s", typedpass, SALT)
  946. md5(passsalt, hash)
  947.  
  948. if(!equal(hash, password[id]))
  949. {
  950. attempts[id]++
  951. client_printcolor(id, "%L", LANG_SERVER, "LOG_PASS_INVALID", prefix, attempts[id], get_pcvar_num(g_attempts))
  952.  
  953. if(attempts[id] >= get_pcvar_num(g_attempts))
  954. {
  955. params[0] = id
  956. params[1] = 3
  957. set_task(2.0, "KickPlayer", id+TASK_KICK, params, sizeof params)
  958. return PLUGIN_HANDLED
  959. }
  960. else
  961. {
  962. client_cmd(id, "messagemode LOGIN_PASS")
  963. }
  964. return PLUGIN_HANDLED
  965. }
  966. else
  967. {
  968. is_logged[id] = true
  969. attempts[id] = 0
  970. remove_task(id+TASK_KICK)
  971. client_printcolor(id, "%L", LANG_SERVER, "LOG_LOGING", prefix)
  972. Menu(id)
  973. }
  974. return PLUGIN_CONTINUE
  975. }
  976. /*==============================================================================
  977. End of Login function
  978. ================================================================================*/
  979.  
  980. /*==============================================================================
  981. Start of Register function
  982. ================================================================================*/
  983. public Register(id)
  984. {
  985. if(!get_pcvar_num(g_on))
  986. return PLUGIN_HANDLED
  987.  
  988. read_args(typedpass, charsmax(typedpass))
  989. remove_quotes(typedpass)
  990.  
  991. new passlength = strlen(typedpass)
  992.  
  993. if(equal(typedpass, ""))
  994. return PLUGIN_HANDLED
  995.  
  996. if(is_registered[id])
  997. {
  998. client_printcolor(id, "%L", LANG_SERVER, "REG_EXISTS", prefix)
  999. return PLUGIN_HANDLED
  1000. }
  1001.  
  1002. if(passlength < get_pcvar_num(g_pass_length))
  1003. {
  1004. client_printcolor(id, "%L", LANG_SERVER, "REG_LEN", prefix, get_pcvar_num(g_pass_length))
  1005. client_cmd(id, "messagemode REGISTER_PASS")
  1006. return PLUGIN_HANDLED
  1007. }
  1008.  
  1009. new_pass[id] = typedpass
  1010. ConfirmPassword(id)
  1011. return PLUGIN_CONTINUE
  1012. }
  1013. /*==============================================================================
  1014. End of Register function
  1015. ================================================================================*/
  1016.  
  1017. /*==============================================================================
  1018. Start of Change Password function
  1019. ================================================================================*/
  1020. public ChangePasswordNew(id)
  1021. {
  1022. if(!get_pcvar_num(g_on) || !is_registered[id] || !is_logged[id])
  1023. return PLUGIN_HANDLED
  1024.  
  1025. read_args(typedpass, charsmax(typedpass))
  1026. remove_quotes(typedpass)
  1027.  
  1028. new passlenght = strlen(typedpass)
  1029.  
  1030. if(equal(typedpass, ""))
  1031. return PLUGIN_HANDLED
  1032.  
  1033. if(passlenght < get_pcvar_num(g_pass_length))
  1034. {
  1035. client_printcolor(id, "%L", LANG_SERVER, "REG_LEN", prefix, get_pcvar_num(g_pass_length))
  1036. client_cmd(id, "messagemode CHANGE_PASS_NEW")
  1037. return PLUGIN_HANDLED
  1038. }
  1039.  
  1040. new_pass[id] = typedpass
  1041. client_cmd(id, "messagemode CHANGE_PASS_OLD")
  1042. return PLUGIN_CONTINUE
  1043. }
  1044.  
  1045. public ChangePasswordOld(id)
  1046. {
  1047. if(!get_pcvar_num(g_on) || !is_registered[id] || !is_logged[id])
  1048. return PLUGIN_HANDLED
  1049.  
  1050. read_args(typedpass, charsmax(typedpass))
  1051. remove_quotes(typedpass)
  1052. formatex(passsalt, charsmax(passsalt), "%s%s", typedpass, SALT)
  1053. md5(passsalt, hash)
  1054.  
  1055. if(equal(typedpass, "") || equal(new_pass[id], ""))
  1056. return PLUGIN_HANDLED
  1057.  
  1058. if(!equali(hash, password[id]))
  1059. {
  1060. client_printcolor(id, "%L", LANG_SERVER, "CHANGE_NO", prefix)
  1061. return PLUGIN_HANDLED
  1062. }
  1063.  
  1064. ConfirmPassword(id)
  1065. return PLUGIN_CONTINUE
  1066. }
  1067. /*==============================================================================
  1068. End of Change Password function
  1069. ================================================================================*/
  1070.  
  1071. /*==============================================================================
  1072. Start of Confirming Register's or Change Password's password function
  1073. ================================================================================*/
  1074. public ConfirmPassword(id)
  1075. {
  1076. if(!get_pcvar_num(g_on) || !is_user_connected(id))
  1077. return PLUGIN_HANDLED
  1078.  
  1079. length = 0
  1080.  
  1081. formatex(menu, charsmax(menu) - length, "%L", LANG_SERVER, "MENU_PASS", new_pass[id])
  1082. keys = MENU_KEY_1|MENU_KEY_2|MENU_KEY_0
  1083.  
  1084. show_menu(id, keys, menu, -1, "Password Menu")
  1085. return PLUGIN_CONTINUE
  1086. }
  1087.  
  1088. public HandlerConfirmPasswordMenu(id, key)
  1089. {
  1090. switch(key)
  1091. {
  1092. case 0:
  1093. {
  1094. get_user_name(id, name, charsmax(name))
  1095. formatex(passsalt, charsmax(passsalt), "%s%s", new_pass[id], SALT)
  1096. md5(passsalt, hash)
  1097.  
  1098. if(is_registered[id])
  1099. {
  1100. if(get_pcvar_num(g_save))
  1101. {
  1102. formatex(namepass, charsmax(namepass), "UPDATE `registersystem` SET Password = ^"%s^", Status = ^"%s^" WHERE Name = ^"%s^";", hash, is_autolog[id] == true ? "LOGGED" : "", name)
  1103. SQL_ThreadQuery(g_SQLTuple, "QuerySetData", namepass)
  1104. }
  1105. else
  1106. {
  1107. new line, file = fopen(reg_file, "r")
  1108.  
  1109. while(!feof(file))
  1110. {
  1111. fgets(file, namepass, 255)
  1112. line++
  1113. parse(namepass, namepass, charsmax(namepass))
  1114.  
  1115. if(equal(namepass, name))
  1116. {
  1117. formatex(namepass, charsmax(namepass), "^"%s^" ^"%s^" ^"%s^"", name, hash, is_autolog[id] == true ? "LOGGED" : "")
  1118. write_file(reg_file, namepass, line - 1)
  1119.  
  1120. break
  1121. }
  1122. }
  1123. fclose(file)
  1124. }
  1125. get_pcvar_string(g_setinfo_pr, pass_prefix, charsmax(pass_prefix))
  1126. client_cmd(id, "setinfo %s %s",pass_prefix, new_pass[id])
  1127. client_printcolor(id, "%L", LANG_SERVER, "CHANGE_NEW", prefix, new_pass[id])
  1128. password[id] = hash
  1129. times[id]++
  1130.  
  1131. if(get_pcvar_num(g_chp_log))
  1132. {
  1133. log_to_file(log_file, "%L", LANG_SERVER, "LOGFILE_CHNG_PASS", name)
  1134. }
  1135. }
  1136. else
  1137. {
  1138. if(get_pcvar_num(g_save))
  1139. {
  1140. formatex(namepass, charsmax(namepass), "INSERT INTO `registersystem` (`Name`, `Password`, `Status`) VALUES (^"%s^", ^"%s^", ^"^");", name, hash)
  1141. SQL_ThreadQuery(g_SQLTuple, "QuerySetData", namepass)
  1142. }
  1143. else
  1144. {
  1145. new file = fopen(reg_file, "a")
  1146. format(namepass, charsmax(namepass), "^n^"%s^" ^"%s^" ^"^"", name, hash)
  1147. fprintf(file, namepass)
  1148. fclose(file)
  1149. }
  1150. remove_task(id+TASK_KICK)
  1151. params[1] = 2
  1152. set_task(get_pcvar_float(g_logtime), "KickPlayer", id+TASK_KICK, params, sizeof params)
  1153. client_printcolor(id, "%L", LANG_SERVER, "REG_REGIS", prefix, new_pass[id], get_pcvar_num(g_logtime))
  1154. is_registered[id] = true
  1155. password[id] = hash
  1156. new_pass[id] = ""
  1157.  
  1158. if(get_pcvar_num(g_reg_log))
  1159. {
  1160. log_to_file(log_file, "%L", LANG_SERVER, "LOGFILE_REG", name)
  1161. }
  1162. }
  1163. Menu(id)
  1164. }
  1165. case 1:
  1166. {
  1167. if(is_registered[id])
  1168. {
  1169. client_cmd(id, "messagemode CHANGE_PASS_NEW")
  1170. }
  1171. else
  1172. {
  1173. client_cmd(id, "messagemode REGISTER_PASS")
  1174. }
  1175. }
  1176. case 9:
  1177. {
  1178. Menu(id)
  1179. return PLUGIN_HANDLED
  1180. }
  1181. }
  1182. return PLUGIN_HANDLED
  1183. }
  1184.  
  1185. public QuerySetData(FailState, Handle:Query, error[],errcode, data[], datasize)
  1186. {
  1187. if(FailState == TQUERY_CONNECT_FAILED || FailState == TQUERY_QUERY_FAILED)
  1188. {
  1189. log_amx("%s", error)
  1190. return
  1191. }
  1192. }
  1193. /*==============================================================================
  1194. End of Confirming Register's or Change Password's password function
  1195. ================================================================================*/
  1196.  
  1197. /*==============================================================================
  1198. Start of Player PreThink function for the blind function
  1199. ================================================================================*/
  1200. public PlayerPreThink(id)
  1201. {
  1202. if(!get_pcvar_num(g_on) || !get_pcvar_num(g_blind) || !is_user_connected(id))
  1203. return PLUGIN_HANDLED
  1204.  
  1205. if((!is_registered[id] && get_pcvar_float(g_regtime)) || (is_registered[id] && !is_logged[id]))
  1206. {
  1207. message_begin(MSG_ONE_UNRELIABLE, g_screenfade, {0,0,0}, id)
  1208. write_short(1<<12)
  1209. write_short(1<<12)
  1210. write_short(0x0000)
  1211. write_byte(0)
  1212. write_byte(0)
  1213. write_byte(0)
  1214. write_byte(255)
  1215. message_end()
  1216. }
  1217.  
  1218. return PLUGIN_CONTINUE
  1219. }
  1220. /*==============================================================================
  1221. End of Player PreThink function for the blind function
  1222. ================================================================================*/
  1223.  
  1224. /*==============================================================================
  1225. Start of Client Info Change function for hooking name change of clients
  1226. ================================================================================*/
  1227. public ClientInfoChanged(id)
  1228. {
  1229. if(!get_pcvar_num(g_on) || !is_user_connected(id))
  1230. return FMRES_IGNORED
  1231.  
  1232. new g_oldname[32], g_newname[32];
  1233.  
  1234. pev(id, pev_netname, g_oldname, charsmax(g_oldname))
  1235.  
  1236. if(g_oldname[0])
  1237. {
  1238. get_user_info(id, "name", g_newname, charsmax(g_newname))
  1239. replace_all(g_newname, charsmax(g_newname), "%", " ")
  1240.  
  1241. if(!equal(g_oldname, g_newname))
  1242. {
  1243.  
  1244. switch(get_pcvar_num(g_name))
  1245. {
  1246. case 0:
  1247. {
  1248. set_pev(id, pev_netname, g_newname)
  1249. create_name_change_msg(id, g_oldname, g_newname)
  1250. set_task(1.0, "CheckClient", id)
  1251. return FMRES_HANDLED
  1252. }
  1253. case 1:
  1254. {
  1255. if(is_logged[id])
  1256. {
  1257. set_user_info(id, "name", g_oldname)
  1258. client_printcolor(id, "%L", LANG_SERVER, "NAME_CHANGE_LOG", prefix)
  1259. return FMRES_HANDLED
  1260. }
  1261. else
  1262. {
  1263. set_pev(id, pev_netname, g_newname)
  1264. create_name_change_msg(id, g_oldname, g_newname)
  1265. set_task(1.0, "CheckClient", id)
  1266. return FMRES_HANDLED
  1267. }
  1268. }
  1269. case 2:
  1270. {
  1271. set_user_info(id, "name", g_oldname)
  1272. client_printcolor(id, "%L", LANG_SERVER, "NAME_CHANGE_ALL", prefix)
  1273. return FMRES_HANDLED
  1274. }
  1275. }
  1276. }
  1277. }
  1278. return FMRES_IGNORED
  1279. }
  1280. /*==============================================================================
  1281. End of Client Info Change function for hooking name change of clients
  1282. ================================================================================*/
  1283.  
  1284. /*==============================================================================
  1285. Start of Kick Player function
  1286. ================================================================================*/
  1287. public KickPlayer(parameter[])
  1288. {
  1289. new id = parameter[0]
  1290. new reason = parameter[1]
  1291.  
  1292. if(is_user_connected(id))
  1293. {
  1294. new userid = get_user_userid(id)
  1295.  
  1296. switch(reason)
  1297. {
  1298. case 1:
  1299. {
  1300. if(is_registered[id])
  1301. return PLUGIN_HANDLED
  1302.  
  1303. server_cmd("kick #%i ^"%L^"", userid, LANG_PLAYER, "KICK_REG")
  1304. console_print(id, "%L", LANG_SERVER, "KICK_INFO")
  1305. return PLUGIN_CONTINUE
  1306. }
  1307. case 2:
  1308. {
  1309. if(is_logged[id])
  1310. return PLUGIN_HANDLED
  1311.  
  1312. server_cmd("kick #%i ^"%L^"", userid, LANG_PLAYER, "KICK_LOGIN")
  1313. console_print(id, "%L", LANG_SERVER, "KICK_INFO")
  1314. return PLUGIN_CONTINUE
  1315. }
  1316. case 3:
  1317. {
  1318. server_cmd("kick #%i ^"%L^"", userid, LANG_PLAYER, "KICK_ATMP", get_pcvar_num(g_attempts))
  1319. console_print(id, "%L", LANG_SERVER, "KICK_INFO")
  1320. return PLUGIN_CONTINUE
  1321. }
  1322. case 4:
  1323. {
  1324. server_cmd("kick #%i ^"%L^"", userid, LANG_SERVER, "KICK_LOGOUT")
  1325. console_print(id, "%L", LANG_SERVER, "KICK_INFO")
  1326. return PLUGIN_CONTINUE
  1327. }
  1328. }
  1329. }
  1330. return PLUGIN_CONTINUE
  1331. }
  1332. /*==============================================================================
  1333. End of Kick Player function
  1334. ================================================================================*/
  1335.  
  1336. /*==============================================================================
  1337. Start of Plugin's stocks
  1338. ================================================================================*/
  1339. stock create_name_change_msg(const id, const g_oldname[], const g_newname[])
  1340. {
  1341. message_begin(MSG_BROADCAST, g_saytxt)
  1342. write_byte(id)
  1343. write_string(NAME_CHANGE_MSG)
  1344. write_string(g_oldname)
  1345. write_string(g_newname)
  1346. message_end()
  1347. }
  1348.  
  1349. stock client_printcolor(const id, const input[], any:...)
  1350. {
  1351. new count = 1, players[32];
  1352. static msg[191];
  1353. vformat(msg, 190, input, 3)
  1354. replace_all(msg,190,"!g","^4")
  1355. replace_all(msg,190,"!n","^1")
  1356. replace_all(msg,190,"!t","^3")
  1357. replace_all(msg,190,"!w","^0")
  1358. if(id) players[0] = id
  1359. else get_players(players , count , "ch")
  1360. {
  1361. for(new i = 0; i < count; i++)
  1362. {
  1363. if(is_user_connected(players[i]))
  1364. {
  1365. message_begin(MSG_ONE_UNRELIABLE, g_saytxt,_, players[i])
  1366. write_byte(players[i])
  1367. write_string(msg)
  1368. message_end()
  1369. }
  1370. }
  1371. }
  1372. }
  1373. /*==============================================================================
  1374. End of Plugin's stocks
  1375. ================================================================================*/
  1376. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
  1377. *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1038\\ f0\\ fs16 \n\\ par }
  1378. */
  1379.