HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /* Plugin generated by AMXX-Studio */
  2.  
  3. #include <amxmodx>
  4. #include <fakemeta>
  5. #include <fvault>
  6.  
  7. #define PLUGIN "Registration System"
  8. #define VERSION "2022 v3.0"
  9. #define AUTHOR "Biel-oGrande" //
  10.  
  11. new const g_fvault[ ] = "accounts"
  12.  
  13. enum _:TOTAL_FORWARDS {
  14.  
  15. FW_USER_REGISTER,
  16. FW_USER_LOGGED,
  17. FW_USER_LOGGED_INVITED,
  18. FW_USER_ACCOUNT_DELETED
  19. }
  20.  
  21. new g_Forwards[TOTAL_FORWARDS]
  22. new g_ForwardResult
  23.  
  24. new g_logged[33], g_registered[33], g_invited[33]
  25.  
  26. new g_password[33], g_password_again[33]
  27.  
  28. new g_attempts[33], g_unlock[33], g_deleted_account[33]
  29.  
  30. new cvar_attempts, cvar_bantime, cvar_logintime, cvar_screenfade, cvar_mim_characters, cvar_max_characters
  31.  
  32. new g_screenfade
  33.  
  34. public plugin_init() {
  35.  
  36. register_plugin(PLUGIN, VERSION, AUTHOR)
  37.  
  38. register_cvar("registration_system", VERSION, FCVAR_SPONLY | FCVAR_SERVER )
  39.  
  40. register_clcmd("chooseteam", "message_team")
  41. register_clcmd("jointeam", "message_team")
  42. register_clcmd("joinclass", "message_team")
  43.  
  44. register_forward(FM_ClientUserInfoChanged, "ClientUserInfoChanged")
  45. register_forward(FM_PlayerPreThink, "PlayerPreThink")
  46.  
  47. register_clcmd("ENTER_YOUR_PASSWORD","cmd_password")
  48. register_clcmd("ENTER_YOUR_PASSWORD_AGAIN","cmd_password_again")
  49. register_clcmd("ENTER_YOUR_PASSWORD_CURRENT","cmd_password_current")
  50.  
  51. register_clcmd("say", "commands")
  52. register_clcmd("say_team", "commands")
  53.  
  54. register_dictionary("registration_system.txt")
  55.  
  56. cvar_mim_characters = register_cvar("reg_mim_characters", "5")
  57. cvar_max_characters = register_cvar("reg_max_characters", "20")
  58.  
  59. cvar_attempts = register_cvar("reg_wrong_passowrd_limit", "3")
  60. cvar_bantime = register_cvar("reg_wrong_passowrd_time_ban", "5")
  61. cvar_logintime = register_cvar("reg_time_to_log", "60")
  62. cvar_screenfade = register_cvar("reg_screenfade", "1")
  63.  
  64. g_screenfade = get_user_msgid("ScreenFade")
  65.  
  66. g_Forwards[FW_USER_REGISTER] = CreateMultiForward("reg_user_register", ET_IGNORE, FP_CELL)
  67. g_Forwards[FW_USER_LOGGED] = CreateMultiForward("reg_user_logged", ET_IGNORE, FP_CELL)
  68. g_Forwards[FW_USER_LOGGED_INVITED] = CreateMultiForward("reg_user_logged_invited", ET_IGNORE, FP_CELL)
  69. g_Forwards[FW_USER_ACCOUNT_DELETED] = CreateMultiForward("reg_user_account_deleted", ET_IGNORE, FP_CELL)
  70. }
  71.  
  72. public plugin_natives() {
  73.  
  74. register_native("reg_is_user_logged", "native_is_user_logged", 1)
  75. register_native("reg_is_user_registered", "native_is_user_registered", 1)
  76. register_native("reg_is_user_invited", "native_is_user_invited", 1)
  77. }
  78.  
  79. public client_connect(id) {
  80.  
  81. client_cmd(id, "setinfo ^"_vgui_menus^" ^"1^"")
  82. }
  83.  
  84. public client_putinserver(id) {
  85.  
  86. static szName[32], szData[64]
  87. get_user_name(id, szName, charsmax(szName))
  88. set_task(get_pcvar_float(cvar_logintime), "login_time", id )
  89.  
  90. g_unlock[id] = true
  91.  
  92. if(fvault_get_data(g_fvault, szName, szData, charsmax(szData)))
  93. g_registered[id] = true
  94. else
  95. g_registered[id] = false
  96. }
  97.  
  98. public client_disconnect(id) {
  99.  
  100. remove_task(id)
  101. g_logged[id] = false
  102. g_invited[id] = false
  103. g_unlock[id] = false
  104. }
  105.  
  106. public message_team(id) {
  107.  
  108. if(!g_logged[id] && !g_invited[id] && !is_user_bot(id) && !is_user_hltv(id)) {
  109.  
  110. menu_account(id)
  111. return PLUGIN_HANDLED
  112. }
  113. return PLUGIN_CONTINUE
  114. }
  115.  
  116. public ClientUserInfoChanged(id) {
  117.  
  118. static szOldName[32]
  119. pev(id, pev_netname, szOldName, charsmax(szOldName))
  120.  
  121. if(szOldName[0]) {
  122.  
  123. static const name[] = "name"
  124. static szNewName[32]
  125. get_user_info(id, name, szNewName, charsmax(szNewName))
  126.  
  127. if(!equal(szOldName, szNewName)) {
  128.  
  129. set_user_info(id, name, szOldName)
  130. return FMRES_HANDLED
  131. }
  132. }
  133. return FMRES_IGNORED
  134. }
  135.  
  136. public menu_account(id) {
  137.  
  138. new szMenu[128], szName[32]
  139. get_user_name(id, szName, charsmax(szName))
  140.  
  141. formatex(szMenu, 127, "\r%L^n^n\r\r%L\d: \w[\y%s\w]^n\r%L\d: \w[\y%L\w]", LANG_PLAYER, "MENU_ACCOUNT_TITLE", LANG_PLAYER, "MENU_ACCOUNT_NICK", szName, LANG_PLAYER, "MENU_ACCOUNT_STATUS",
  142. LANG_PLAYER, g_invited[id] ? "MENU_ACCOUNT_INVITED" : g_logged[id] ? "MENU_ACCOUNT_LOGGED" : g_registered[id] ? "MENU_ACCOUNT_REGISTERED" : "MENU_ACCOUNT_NOT_REGISTERED")
  143.  
  144. new Menu = menu_create(szMenu, "handler_menu_account")
  145.  
  146. formatex(szMenu, 63, "%s%L", g_logged[id] ? "\d" : g_registered[id] ? "\y" : "\d", LANG_PLAYER, "MENU_ACCOUNT_00")
  147. menu_additem(Menu, szMenu, "1", 0)
  148.  
  149. formatex(szMenu, 63, "%s%L^n", g_registered[id] ? "\d":"\r", LANG_PLAYER, "MENU_ACCOUNT_01")
  150. menu_additem(Menu, szMenu, "2", 0)
  151.  
  152. formatex(szMenu, 63, "%s%L", g_logged[id] ? "\w" : "\d", LANG_PLAYER, "MENU_ACCOUNT_02")
  153. menu_additem(Menu, szMenu, "3", 0)
  154.  
  155. formatex(szMenu, 63, "%s%L^n", g_logged[id] ? "\w" : "\d", LANG_PLAYER, "MENU_ACCOUNT_03")
  156. menu_additem(Menu, szMenu, "4", 0)
  157.  
  158. formatex(szMenu, 63, "%s%L", g_registered[id] ? "\d" : g_invited[id] ? "\d" : "\y", LANG_PLAYER, "MENU_ACCOUNT_04")
  159. menu_additem(Menu, szMenu, "5", 0)
  160.  
  161. formatex(szMenu, 63, "%L", LANG_PLAYER, "MENU_ACCOUNT_EXIT")
  162. menu_setprop(Menu, MPROP_EXITNAME, szMenu)
  163. menu_display(id, Menu, 0)
  164. }
  165.  
  166. public handler_menu_account(id, menu, item) {
  167.  
  168. if(item == MENU_EXIT) {
  169.  
  170. menu_destroy(menu)
  171. return PLUGIN_HANDLED
  172. }
  173. switch(item) {
  174.  
  175. case 0: login(id)
  176. case 1: register(id)
  177. case 2: change(id)
  178. case 3: delete_account(id)
  179. case 4: invited(id)
  180. }
  181. menu_destroy(menu)
  182. return PLUGIN_HANDLED
  183. }
  184.  
  185. public login(id) {
  186.  
  187. if(g_logged[id]) {
  188.  
  189. menu_account(id)
  190. set_hudmessage(255, 0, 0, 0.02, 0.17, 0, 6.0, 12.0)
  191. show_hudmessage(id, "%L", LANG_PLAYER, "MENU_ACCOUNT_CASE_00_A")
  192. client_print_color(id, "!g%L !t%L", LANG_PLAYER, "REG_PREFIX", LANG_PLAYER, "MENU_ACCOUNT_CASE_00_A")
  193. }
  194. else if(!g_registered[id]) {
  195.  
  196. menu_account(id)
  197. set_hudmessage(255, 0, 0, 0.02, 0.17, 0, 6.0, 12.0)
  198. show_hudmessage(id, "%L", LANG_PLAYER, "MENU_ACCOUNT_CASE_00_B")
  199. client_print_color(id, "!g%L !t%L", LANG_PLAYER, "REG_PREFIX", LANG_PLAYER, "MENU_ACCOUNT_CASE_00_B")
  200. }
  201. else {
  202.  
  203. client_cmd(id,"messagemode ENTER_YOUR_PASSWORD")
  204. set_hudmessage(0, 255, 0, 0.02, 0.17, 0, 6.0, 12.0)
  205. show_hudmessage(id, "%L", LANG_PLAYER, "MENU_ACCOUNT_CASE_00_C")
  206. client_print_color(id, "!g%L !t%L", LANG_PLAYER, "REG_PREFIX", LANG_PLAYER, "MENU_ACCOUNT_CASE_00_C")
  207. g_unlock[id] = false
  208. }
  209. return PLUGIN_HANDLED
  210. }
  211.  
  212. public register(id) {
  213.  
  214. if(g_registered[id]) {
  215.  
  216. menu_account(id)
  217. set_hudmessage(255, 0, 0, 0.02, 0.17, 0, 6.0, 12.0)
  218. show_hudmessage(id, "%L", LANG_PLAYER, "MENU_ACCOUNT_CASE_01_A")
  219. client_print_color(id, "!g%L !t%L", LANG_PLAYER, "REG_PREFIX", LANG_PLAYER, "MENU_ACCOUNT_CASE_01_A")
  220. }
  221. else {
  222.  
  223. client_cmd(id,"messagemode ENTER_YOUR_PASSWORD")
  224. set_hudmessage(0, 255, 0, 0.02, 0.17, 0, 6.0, 12.0)
  225. show_hudmessage(id, "%L", LANG_PLAYER, "MENU_ACCOUNT_CASE_01_B")
  226. client_print_color(id, "!g%L !t%L", LANG_PLAYER, "REG_PREFIX", LANG_PLAYER, "MENU_ACCOUNT_CASE_01_B")
  227. g_unlock[id] = false
  228. }
  229. return PLUGIN_HANDLED
  230. }
  231.  
  232. public change(id) {
  233.  
  234. if(!g_logged[id]) {
  235.  
  236. menu_account(id)
  237. set_hudmessage(255, 0, 0, 0.02, 0.17, 0, 6.0, 12.0)
  238. show_hudmessage(id, "%L", LANG_PLAYER, "MENU_ACCOUNT_CASE_02_A")
  239. client_print_color(id, "!g%L !t%L", LANG_PLAYER, "REG_PREFIX", LANG_PLAYER, "MENU_ACCOUNT_CASE_02_A")
  240. }
  241. else {
  242.  
  243. client_cmd(id,"messagemode ENTER_YOUR_PASSWORD_CURRENT")
  244. set_hudmessage(0, 255, 0, 0.02, 0.17, 0, 6.0, 12.0)
  245. show_hudmessage(id, "%L", LANG_PLAYER, "MENU_ACCOUNT_CASE_02_B")
  246. client_print_color(id, "!g%L !t%L", LANG_PLAYER, "REG_PREFIX", LANG_PLAYER, "MENU_ACCOUNT_CASE_02_B")
  247. g_unlock[id] = false
  248. }
  249. return PLUGIN_HANDLED
  250. }
  251.  
  252. public delete_account(id) {
  253.  
  254. if(!g_logged[id]) {
  255.  
  256. menu_account(id)
  257. set_hudmessage(255, 0, 0, 0.02, 0.17, 0, 6.0, 12.0)
  258. show_hudmessage(id, "%L", LANG_PLAYER, "MENU_ACCOUNT_CASE_03_A")
  259. client_print_color(id, "!g%L !t%L", LANG_PLAYER, "REG_PREFIX", LANG_PLAYER, "MENU_ACCOUNT_CASE_03_A")
  260. }
  261. else {
  262.  
  263. client_cmd(id,"messagemode ENTER_YOUR_PASSWORD_CURRENT")
  264. set_hudmessage(0, 255, 0, 0.02, 0.17, 0, 6.0, 12.0)
  265. show_hudmessage(id, "%L", LANG_PLAYER, "MENU_ACCOUNT_CASE_03_B")
  266. client_print_color(id, "!g%L !t%L", LANG_PLAYER, "REG_PREFIX", LANG_PLAYER, "MENU_ACCOUNT_CASE_03_B")
  267. g_unlock[id] = false
  268. g_deleted_account[id] = true
  269. }
  270. return PLUGIN_HANDLED
  271. }
  272.  
  273. public invited(id) {
  274.  
  275. new szName[32]
  276. get_user_name(id, szName, charsmax(szName))
  277.  
  278. if(g_registered[id]) {
  279.  
  280. set_hudmessage(255, 0, 0, 0.02, 0.17, 0, 6.0, 12.0)
  281. show_hudmessage(id, "%L", LANG_PLAYER, "MENU_ACCOUNT_CASE_04_A")
  282. client_print_color(id, "!g%L !t%L", LANG_PLAYER, "REG_PREFIX", LANG_PLAYER, "MENU_ACCOUNT_CASE_04_A")
  283. menu_account(id)
  284. }
  285. else if(g_invited[id]) {
  286.  
  287. menu_account(id)
  288. set_hudmessage(255, 0, 0, 0.02, 0.17, 0, 6.0, 12.0)
  289. show_hudmessage(id, "%L", LANG_PLAYER, "MENU_ACCOUNT_CASE_04_B")
  290. client_print_color(id, "!g%L !t%L", LANG_PLAYER, "REG_PREFIX", LANG_PLAYER, "MENU_ACCOUNT_CASE_04_B")
  291. }
  292. else {
  293.  
  294. client_cmd(id, "jointeam")
  295. set_hudmessage(255, 0, 0, 0.02, 0.17, 0, 6.0, 12.0)
  296. show_hudmessage(id, "%L", LANG_PLAYER, "MENU_ACCOUNT_CASE_04_C")
  297. client_print_color(id, "!g%L !t%L", LANG_PLAYER, "REG_PREFIX", LANG_PLAYER, "MENU_ACCOUNT_CASE_04_C")
  298. ExecuteForward(g_Forwards[FW_USER_LOGGED_INVITED], g_ForwardResult, id)
  299. g_invited[id] = true
  300. }
  301. return PLUGIN_HANDLED
  302. }
  303.  
  304. public cmd_password(id) {
  305.  
  306. if(g_unlock[id]) return PLUGIN_HANDLED
  307.  
  308. new szName[32], szData[64]
  309. get_user_name(id, szName, charsmax(szName))
  310. fvault_get_data(g_fvault, szName, szData, charsmax(szData))
  311.  
  312. read_args(g_password[id], 50)
  313. remove_quotes(g_password[id])
  314. trim(g_password[id])
  315.  
  316. g_unlock[id] = true
  317.  
  318. if(!characters(g_password[id], strlen(g_password[id]))) {
  319.  
  320. set_hudmessage(255, 0, 0, 0.02, 0.17, 0, 6.0, 12.0)
  321. show_hudmessage(id, "%L", LANG_PLAYER, "CMD_PASSWORD_00")
  322. client_print_color(id, "!g%L !t%L", LANG_PLAYER, "REG_PREFIX", LANG_PLAYER, "CMD_PASSWORD_00")
  323. menu_account(id)
  324. }
  325. else if(strlen(g_password[id]) < get_pcvar_num(cvar_mim_characters)) {
  326.  
  327. menu_account(id)
  328. set_hudmessage(255, 0, 0, 0.02, 0.17, 0, 6.0, 12.0)
  329. show_hudmessage(id, "%L", LANG_PLAYER, "CMD_PASSWORD_01", get_pcvar_num(cvar_mim_characters))
  330. client_print_color(id, "!g%L !t%L", LANG_PLAYER, "REG_PREFIX", LANG_PLAYER, "CMD_PASSWORD_01", get_pcvar_num(cvar_mim_characters))
  331. }
  332. else if(strlen(g_password[id]) > get_pcvar_num(cvar_max_characters)) {
  333.  
  334. menu_account(id)
  335. set_hudmessage(255, 0, 0, 0.02, 0.17, 0, 6.0, 10.0)
  336. show_hudmessage(id, "%L", LANG_PLAYER, "CMD_PASSWORD_02",get_pcvar_num( cvar_max_characters))
  337. client_print_color(id, "!g%L !t%L", LANG_PLAYER, "REG_PREFIX", LANG_PLAYER, "CMD_PASSWORD_02",get_pcvar_num( cvar_max_characters))
  338. }
  339. else if(equal(g_password[id], szName[id])) {
  340.  
  341. menu_account(id)
  342. set_hudmessage(255, 0, 0, 0.02, 0.17, 0, 6.0, 10.0)
  343. show_hudmessage(id, "%L", LANG_PLAYER, "CMD_PASSWORD_03")
  344. client_print_color(id, "!g%L !t%L", LANG_PLAYER, "REG_PREFIX", LANG_PLAYER, "CMD_PASSWORD_03")
  345. }
  346. else if(g_logged[id]) {
  347.  
  348. if(!equal(szData, g_password[id])) {
  349.  
  350. client_cmd(id,"messagemode ENTER_YOUR_PASSWORD_AGAIN")
  351. set_hudmessage(0, 255, 0, 0.02, 0.17, 0, 6.0, 12.0)
  352. show_hudmessage(id, "%L", LANG_PLAYER, "CMD_PASSWORD_04")
  353. client_print_color(id, "!g%L !t%L", LANG_PLAYER, "REG_PREFIX", LANG_PLAYER, "CMD_PASSWORD_04")
  354. g_unlock[id] = false
  355. }
  356. else {
  357.  
  358. menu_account(id)
  359. set_hudmessage(255, 0, 0, 0.02, 0.17, 0, 6.0, 10.0)
  360. show_hudmessage(id, "%L", LANG_PLAYER, "CMD_PASSWORD_05")
  361. client_print_color(id, "!g%L !t%L", LANG_PLAYER, "REG_PREFIX", LANG_PLAYER, "CMD_PASSWORD_05")
  362. }
  363. }
  364. else if(!g_registered[id]) {
  365.  
  366. client_cmd(id,"messagemode ENTER_YOUR_PASSWORD_AGAIN")
  367. set_hudmessage(0, 255, 0, 0.02, 0.17, 0, 6.0, 12.0)
  368. show_hudmessage(id, "%L", LANG_PLAYER, "CMD_PASSWORD_06")
  369. client_print_color(id, "!g%L !t%L", LANG_PLAYER, "REG_PREFIX", LANG_PLAYER, "CMD_PASSWORD_06")
  370. g_unlock[id] = false
  371. }
  372. else {
  373.  
  374. if(equal(szData, g_password[id])) {
  375.  
  376. remove_task(id)
  377. client_cmd(id, "jointeam")
  378. set_hudmessage(255, 0, 0, 0.02, 0.17, 0, 6.0, 12.0)
  379. show_hudmessage(id, "%L", LANG_PLAYER, "CMD_PASSWORD_07")
  380. client_print_color(id, "!g%L !t%L", LANG_PLAYER, "REG_PREFIX", LANG_PLAYER, "CMD_PASSWORD_07")
  381. ExecuteForward(g_Forwards[FW_USER_LOGGED], g_ForwardResult, id)
  382.  
  383. g_logged[id] = true
  384. g_attempts[id] = 0
  385. }
  386. else {
  387.  
  388. wrong_password(id)
  389. }
  390. }
  391. return PLUGIN_HANDLED
  392. }
  393.  
  394. public cmd_password_again(id) {
  395.  
  396. if(g_unlock[id]) return PLUGIN_HANDLED
  397.  
  398. read_args(g_password_again[id], 50)
  399. remove_quotes(g_password_again[id])
  400. trim(g_password_again[id])
  401.  
  402. g_unlock[id] = true
  403.  
  404. if(!equal(g_password[id], g_password_again[id])) {
  405.  
  406. menu_account(id)
  407. set_hudmessage(255, 0, 0, 0.02, 0.17, 0, 6.0, 12.0)
  408. show_hudmessage(id, "%L", LANG_PLAYER, "CMD_PASSOWORD_AGAIN_00")
  409. client_print_color(id, "!g%L !t%L", LANG_PLAYER, "REG_PREFIX", LANG_PLAYER, "CMD_PASSOWORD_AGAIN_00")
  410. }
  411. else if(!g_registered[id]) {
  412.  
  413. menu_end_register(id)
  414. set_hudmessage(0, 255, 0, 0.02, 0.17, 0, 6.0, 12.0)
  415. show_hudmessage(id, "%L", LANG_PLAYER, "CMD_PASSOWORD_AGAIN_01")
  416. client_print_color(id, "!g%L !t%L", LANG_PLAYER, "REG_PREFIX", LANG_PLAYER, "CMD_PASSOWORD_AGAIN_01")
  417. }
  418. else {
  419.  
  420. menu_change_password(id)
  421. set_hudmessage(255, 0, 0, 0.02, 0.17, 0, 6.0, 12.0)
  422. show_hudmessage(id, "%L", LANG_PLAYER, "CMD_PASSOWORD_AGAIN_02")
  423. client_print_color(id, "!g%L !t%L", LANG_PLAYER, "REG_PREFIX", LANG_PLAYER, "CMD_PASSOWORD_AGAIN_02")
  424. }
  425. return PLUGIN_HANDLED
  426. }
  427.  
  428. public cmd_password_current(id) {
  429.  
  430. if(g_unlock[id]) return PLUGIN_HANDLED
  431.  
  432. new szName[32], szData[64]
  433. get_user_name(id, szName, charsmax(szName))
  434. fvault_get_data(g_fvault, szName, szData, charsmax(szData))
  435.  
  436. read_args(g_password[id], 50)
  437. remove_quotes(g_password[id])
  438. trim(g_password[id])
  439.  
  440. g_unlock[id] = true
  441.  
  442. if(equal(szData, g_password[id])) {
  443.  
  444. if(g_deleted_account[id]) {
  445.  
  446. menu_delete_account(id)
  447. g_unlock[id] = false
  448. g_deleted_account[id] = false
  449. }
  450. else {
  451.  
  452. client_cmd(id,"messagemode ENTER_YOUR_PASSWORD")
  453. set_hudmessage(0, 255, 0, 0.02, 0.17, 0, 6.0, 12.0)
  454. show_hudmessage(id, "%L", LANG_PLAYER, "CMD_PASSWORD_CURRENT_00")
  455. client_print_color(id, "!g%L !t%L", LANG_PLAYER, "REG_PREFIX", LANG_PLAYER, "CMD_PASSWORD_CURRENT_00")
  456. g_unlock[id] = false
  457. }
  458. }
  459. else {
  460.  
  461. wrong_password(id)
  462. }
  463. return PLUGIN_HANDLED
  464. }
  465.  
  466. public menu_end_register(id) {
  467.  
  468. new szMenu[128], szName[32]
  469. get_user_name(id, szName, charsmax(szName))
  470.  
  471. formatex(szMenu,127, "\r%L^n^n\y%L: \r[\d%s\r]^n\y%L: \r[\d%s\r]", LANG_PLAYER, "MENU_END_REGISTER_TITLE", LANG_PLAYER, "MENU_END_REGISTER_NICK", szName, LANG_PLAYER, "MENU_END_REGISTER_PASSWORD", g_password_again[id])
  472.  
  473. new Menu = menu_create(szMenu, "handler_menu_end_register")
  474.  
  475. formatex(szMenu, 63, "%L", LANG_PLAYER, "MENU_END_REGISTER_00")
  476. menu_additem(Menu, szMenu, "1", 0)
  477.  
  478. formatex(szMenu, 63, "\r%L^n", LANG_PLAYER, "MENU_END_REGISTER_01")
  479. menu_additem(Menu, szMenu, "2", 0)
  480.  
  481. formatex(szMenu, 63, "\y%L", LANG_PLAYER, "MENU_END_REGISTER_02")
  482. menu_additem(Menu, szMenu, "3", 0)
  483.  
  484. menu_setprop(Menu, MPROP_EXIT, MEXIT_NEVER)
  485. menu_display(id, Menu, 0)
  486. }
  487.  
  488. public handler_menu_end_register(id, menu, item) {
  489.  
  490. if(item == MENU_EXIT) {
  491.  
  492. menu_destroy(menu)
  493. return PLUGIN_HANDLED
  494. }
  495. switch(item) {
  496.  
  497. case 0: end_register(id)
  498. case 1: register(id)
  499. case 2: menu_account(id)
  500. }
  501. menu_destroy(menu)
  502. return PLUGIN_HANDLED
  503. }
  504.  
  505. public end_register(id) {
  506.  
  507. new szName[32]
  508. get_user_name(id, szName, charsmax(szName))
  509.  
  510. fvault_set_data(g_fvault, szName, g_password_again[id])
  511.  
  512. set_hudmessage(0, 0, 255, 0.02, 0.25, 0, 6.0, 15.0)
  513. show_hudmessage(id, "%L", LANG_PLAYER, "MENU_END_REGISTER_CASE_00_A")
  514. client_print_color(id, "!g%L !t%L", LANG_PLAYER, "REG_PREFIX", LANG_PLAYER, "MENU_END_REGISTER_CASE_00_A")
  515. client_print_color(id, "!g%L !t%L: !y[!g %s !y] !t%L: !y[!g %s !y]", LANG_PLAYER, "REG_PREFIX", LANG_PLAYER, "MENU_END_REGISTER_CASE_00_B_NICK", szName, LANG_PLAYER, "MENU_END_REGISTER_CASE_00_B_PASSOWORD", g_password_again[id])
  516.  
  517. remove_task(id)
  518.  
  519. ExecuteForward(g_Forwards[FW_USER_REGISTER], g_ForwardResult, id)
  520. g_registered[id] = true
  521. g_logged[id] = true
  522.  
  523. if(g_invited[id]) {
  524.  
  525. menu_account(id)
  526. g_invited[id] = false
  527. }
  528. else {
  529.  
  530. client_cmd(id, "jointeam")
  531. }
  532. }
  533.  
  534. public menu_change_password(id) {
  535.  
  536. new szMenu[128], szName[32]
  537. get_user_name(id, szName, charsmax(szName))
  538.  
  539. formatex(szMenu, 127, "\r%L^n^n\y%L: \r[\d%s\r]^n\y%L: \r[\d%s\r]", LANG_PLAYER, "MENU_CHANGE_PASSWORD_TITLE", LANG_PLAYER, "MENU_CHANGE_PASSWORD_NICK", szName, LANG_PLAYER, "MENU_CHANGE_PASSWORD_PASSWORD", g_password_again[id])
  540.  
  541. new Menu = menu_create(szMenu,"handler_menu_change_password")
  542.  
  543. formatex(szMenu, 63, "%L", LANG_PLAYER, "MENU_CHANGE_PASSWORD_00")
  544. menu_additem(Menu, szMenu, "1", 0)
  545.  
  546. formatex(szMenu, 63, "\r%L^n", LANG_PLAYER, "MENU_CHANGE_PASSWORD_01")
  547. menu_additem(Menu, szMenu, "2", 0)
  548.  
  549. formatex(szMenu, 63, "\y%L", LANG_PLAYER, "MENU_CHANGE_PASSWORD_02")
  550. menu_additem(Menu, szMenu, "3", 0)
  551.  
  552. menu_setprop(Menu, MPROP_EXIT, MEXIT_NEVER)
  553. menu_display(id, Menu, 0)
  554. }
  555.  
  556. public handler_menu_change_password(id, menu, item) {
  557.  
  558. if(item == MENU_EXIT) {
  559.  
  560. menu_destroy(menu)
  561. return PLUGIN_HANDLED
  562. }
  563. switch(item) {
  564.  
  565. case 0: replaced_password(id)
  566. case 1: change(id)
  567. case 2: menu_account(id)
  568. }
  569. menu_destroy(menu)
  570. return PLUGIN_HANDLED
  571. }
  572.  
  573. public replaced_password(id) {
  574.  
  575. new szName[32]
  576. get_user_name(id, szName, charsmax(szName))
  577. fvault_set_data(g_fvault, szName, g_password_again[id])
  578.  
  579. set_hudmessage(0, 0, 255, 0.02, 0.25, 0, 6.0, 15.0)
  580. show_hudmessage(id, "%L", LANG_PLAYER, "MENU_CHANGE_PASSWORD_CASE_00_A")
  581. client_print_color(id, "!g%L !t%L", LANG_PLAYER, "REG_PREFIX", LANG_PLAYER, "MENU_CHANGE_PASSWORD_CASE_00_A")
  582. client_print_color(id, "!g%L !t%L: !y[!g %s !y]", LANG_PLAYER, "REG_PREFIX", LANG_PLAYER, "MENU_CHANGE_PASSWORD_CASE_00_B_PASSWORD", g_password_again[id])
  583.  
  584. g_attempts[id] = 0
  585. }
  586.  
  587. public menu_delete_account(id) {
  588.  
  589. new szMenu[128]
  590.  
  591. formatex(szMenu, 127, "\r%L", LANG_PLAYER, "MENU_DELETED_ACCOUNT_TITLE")
  592.  
  593. new Menu = menu_create(szMenu,"handler_menu_delete_account")
  594.  
  595. formatex(szMenu, 63, "%L", LANG_PLAYER, "MENU_DELETED_ACCOUNT_00")
  596. menu_additem(Menu, szMenu, "1", 0)
  597.  
  598. formatex(szMenu, 63, "\r%L", LANG_PLAYER, "MENU_DELETED_ACCOUNT_01")
  599. menu_additem(Menu, szMenu, "2",0)
  600.  
  601. menu_setprop(Menu, MPROP_EXIT, MEXIT_NEVER)
  602. menu_display(id, Menu, 0)
  603. }
  604.  
  605. public handler_menu_delete_account(id, menu, item) {
  606.  
  607. if(item == MENU_EXIT) {
  608.  
  609. menu_destroy(menu)
  610. return PLUGIN_HANDLED
  611. }
  612. switch(item) {
  613.  
  614. case 0: account_deleted(id)
  615. case 1: menu_account(id)
  616. }
  617. menu_destroy(menu)
  618. return PLUGIN_HANDLED
  619. }
  620.  
  621. public account_deleted(id) {
  622.  
  623. new szName[32]
  624. get_user_name(id, szName, charsmax(szName))
  625.  
  626. fvault_remove_key(g_fvault, szName)
  627.  
  628. ExecuteForward(g_Forwards[FW_USER_ACCOUNT_DELETED], g_ForwardResult, id)
  629.  
  630. client_print(id, print_console, "----------------------------------------")
  631. client_print(id, print_console, "----- %L -------", LANG_PLAYER, "MENU_DELETED_ACCOUNT_CASE_00")
  632. client_print(id, print_console, "----------------------------------------")
  633. client_cmd(id, "disconnect")
  634. client_cmd(id, "toggleconsole")
  635. }
  636.  
  637. public wrong_password(id) {
  638.  
  639. g_attempts[id]++
  640. if(g_attempts[id] >= get_pcvar_num(cvar_attempts)) {
  641.  
  642. server_cmd("amx_banip #%i %i ^"%L^"", get_user_userid(id), get_pcvar_num(cvar_bantime), LANG_PLAYER, "WRONG_PASSWORD_00", get_pcvar_num(cvar_bantime))
  643. remove_task(id)
  644. g_attempts[id] = 0
  645. }
  646. else {
  647.  
  648. menu_account(id)
  649. set_hudmessage(255, 255, 255, 0.02, 0.25, 0, 6.0, 15.0)
  650. show_hudmessage(id,"%L [ %d / %d ]", LANG_PLAYER, "WRONG_PASSWORD_01", g_attempts[id], get_pcvar_num(cvar_attempts))
  651. client_print_color(id, "!g%L !t%L !y[!g %d !y/!g %d !y]", LANG_PLAYER, "REG_PREFIX", LANG_PLAYER, "WRONG_PASSWORD_01", g_attempts[id], get_pcvar_num(cvar_attempts))
  652. }
  653. }
  654.  
  655. public login_time(id) {
  656.  
  657. new szName[32]
  658. get_user_name(id, szName, charsmax(szName))
  659.  
  660. if(!g_logged[id] && !g_invited[id] && !is_user_hltv(id) && !is_user_bot(id) ) {
  661.  
  662. client_print(id, print_console, "----------------------------------------")
  663. client_print(id, print_console, "%L",LANG_PLAYER, "LOGIN_TIME_00", szName)
  664. client_print(id, print_console, "%L", LANG_PLAYER, "LOGIN_TIME_01")
  665. client_print(id, print_console, "%L", LANG_PLAYER, "LOGIN_TIME_02")
  666. client_print(id, print_console, "%L", LANG_PLAYER, "LOGIN_TIME_04", get_pcvar_num(cvar_logintime))
  667. client_print(id, print_console, "----------------------------------------")
  668. client_print_color(0, "!g%L !y%s !t%L !t", LANG_PLAYER, "REG_PREFIX", szName, LANG_PLAYER, "LOGIN_TIME_04")
  669. client_cmd(id, "disconnect")
  670. client_cmd(id, "toggleconsole")
  671. }
  672. }
  673.  
  674. public PlayerPreThink(id) {
  675.  
  676. if(!g_logged[id] && !g_invited[id] && !is_user_bot(id) && !is_user_hltv(id) && get_pcvar_num(cvar_screenfade)) {
  677.  
  678. message_begin(MSG_ONE_UNRELIABLE, g_screenfade, {0,0,0}, id)
  679. write_short(1<<12)
  680. write_short(1<<12)
  681. write_short(0x0000)
  682. write_byte(0)
  683. write_byte(0)
  684. write_byte(0)
  685. write_byte(255)
  686. message_end()
  687. }
  688. }
  689.  
  690. public commands(id) {
  691.  
  692. new text[70], arg1[32], arg2[32], arg3[6]
  693. read_args(text, sizeof(text) - 1)
  694. remove_quotes(text)
  695. arg1[0] = '^0'; arg2[0] = '^0'; arg3[0] = '^0'
  696. parse(text, arg1, sizeof(arg1) - 1, arg2, sizeof(arg2) - 1, arg3, sizeof(arg3) - 1)
  697.  
  698. if(equali(arg1, "/", 1) || equali(arg1, ".", 1)) format(arg1, 31, arg1[1])
  699.  
  700. if(arg3[0]) return PLUGIN_CONTINUE
  701.  
  702. if(equali(arg1, "registro") || equali(arg1, "register") || equali(arg1, "conta") || equali(arg1, "account")) {
  703.  
  704. menu_account(id)
  705. }
  706. return PLUGIN_CONTINUE
  707. }
  708.  
  709. public native_is_user_logged(id) {
  710.  
  711. if(!is_user_connected(id))
  712. return 0
  713.  
  714. return g_logged[id]
  715. }
  716.  
  717. public native_is_user_registered(id) {
  718.  
  719. if(!is_user_connected(id))
  720. return 0
  721.  
  722. return g_registered[id]
  723. }
  724.  
  725. public native_is_user_invited(id) {
  726.  
  727. if(!is_user_connected(id))
  728. return 0
  729.  
  730. return g_invited[id]
  731. }
  732.  
  733. bool:characters(const symbol[], len) {
  734.  
  735. new const valid_chars[][] = {
  736.  
  737. "0" ,"1" ,"2" ,"3" ,"4" ,"5" ,"6" ,"7" ,"8" ,"9",
  738. "a", "b", "c", "d", "e", "f", "g", "h", "i", "j",
  739. "k", "l", "m", "n", "o", "p", "q", "r", "s", "t",
  740. "u", "v", "w", "x", "y", "z"
  741. }
  742. static i, a, valids;
  743. valids = 0
  744.  
  745. for(i = 0; i < len; i++) {
  746.  
  747. for(a = 0; a < sizeof(valid_chars); a++) {
  748.  
  749. if(symbol[i] == valid_chars[a][0]) {
  750.  
  751. valids++
  752. break
  753. }
  754. }
  755. }
  756. if(valids != len)
  757. return false
  758. return true
  759. }
  760.  
  761. stock client_print_color(const id, const input[], any:...) {
  762.  
  763. new count = 1, players[32]
  764. static msg[191]
  765. vformat(msg, 190, input, 3)
  766.  
  767. replace_all(msg, 190, "!g", "^4")
  768. replace_all(msg, 190, "!y", "^1")
  769. replace_all(msg, 190, "!t", "^3")
  770. replace_all(msg, 190, "!team2", "^0")
  771.  
  772. if (id)
  773. players[0] = id;
  774. else
  775. get_players(players, count, "ch")
  776.  
  777. for (new i = 0; i < count; i++) {
  778.  
  779. if (is_user_connected(players[i])) {
  780.  
  781. message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i])
  782. write_byte(players[i]);
  783. write_string(msg);
  784. message_end();
  785. }
  786. }
  787. }
  788.