hlmod.hu

Magyar Half-Life Mód közösség!
Pontos idő: 2024.04.28. 07:18



Jelenlévő felhasználók

Jelenleg 512 felhasználó van jelen :: 0 regisztrált, 0 rejtett és 512 vendég

A legtöbb felhasználó (1565 fő) 2020.11.21. 11:26-kor tartózkodott itt.

Regisztrált felhasználók: nincs regisztrált felhasználó az elmúlt 5 percben aktív felhasználók alapján

Utoljára aktív
Ahhoz hogy lásd ki volt utoljára aktív, be kell jelentkezned.



Az oldal teljeskörű
használatához regisztrálj.

Regisztráció

Kereső


Új téma nyitása  Hozzászólás a témához  [ 3 hozzászólás ] 
Szerző Üzenet
 Hozzászólás témája: Regisztrációs Rendszer
HozzászólásElküldve: 2013.07.18. 22:27 
Offline
Félisten

Csatlakozott: 2012.06.19. 15:12
Hozzászólások: 926
Megköszönt másnak: 109 alkalommal
Megköszönték neki: 31 alkalommal
Valaki javítaná ezt a plugint.

L 07/18/2013 - 20:05:06: [AMXX] Run time error 25: parameter error
L 07/18/2013 - 20:05:06: [AMXX] [0] RegisterSystem.sma::KickPlayer (line 1313)
L 07/18/2013 - 20:05:24: String formatted incorrectly - parameter 5 (total 4)
L 07/18/2013 - 20:05:24: [AMXX] Displaying debug trace (plugin "RegisterSystem.amxx")

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

_________________
Kép


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Regisztrációs Rendszer
HozzászólásElküldve: 2013.07.18. 22:29 
Offline
Őskövület
Avatar

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


UI: semmi hibája nem volt ami warningot dobot volna.

_________________
****


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Regisztrációs Rendszer
HozzászólásElküldve: 2013.07.19. 17:50 
Offline
Félisten

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


UI: semmi hibája nem volt ami warningot dobot volna.


Még mindig erroroz

L 07/19/2013 - 14:08:57: [AMXX] Run time error 25: parameter error
L 07/19/2013 - 14:08:57: [AMXX] [0] g98jx2e5.sma.p::KickPlayer (line 1313)
L 07/19/2013 - 14:57:48: Start of error session.
L 07/19/2013 - 14:57:48: Info (map "zm_202") (file "addons/amxmodx/logs/error_20130719.log")
L 07/19/2013 - 14:57:48: String formatted incorrectly - parameter 5 (total 4)
L 07/19/2013 - 14:57:48: [AMXX] Displaying debug trace (plugin "RegisterSystem.amxx")

_________________
Kép


Hozzászólás jelentése
Vissza a tetejére
   
Hozzászólások megjelenítése:  Rendezés  
Új téma nyitása  Hozzászólás a témához  [ 3 hozzászólás ] 


Ki van itt

Jelenlévő fórumozók: nincs regisztrált felhasználó valamint 55 vendég


Nyithatsz új témákat ebben a fórumban.
Válaszolhatsz egy témára ebben a fórumban.
Nem szerkesztheted a hozzászólásaidat ebben a fórumban.
Nem törölheted a hozzászólásaidat ebben a fórumban.
Nem küldhetsz csatolmányokat ebben a fórumban.

Keresés:
Ugrás:  
Powered by phpBB® Forum Software © phpBB Limited
Magyar fordítás © Magyar phpBB Közösség
Portal: Kiss Portal Extension © Michael O'Toole