hlmod.hu

Magyar Half-Life Mód közösség!
Pontos idő: 2025.06.16. 21:46



Jelenlévő felhasználók

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

A legtöbb felhasználó (2761 fő) 2025.01.09. 20:06-kor tartózkodott itt.

Regisztrált felhasználók: Google [Bot]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 - Menüvel
HozzászólásElküldve:2012.06.15. 17:34 
Offline
Minden6ó
Avatar

Csatlakozott:2011.01.19. 12:14
Hozzászólások:4294
Megköszönt másnak: 219 alkalommal
Megköszönték neki: 289 alkalommal
Valaki ki javítaná nekem mert van benne valami hiba. "FONTOS!"
[spoiler]*
Kód:
  1. Copyright 2011 - 2012, m0skVi4a ;]

  2. Plugin created in Rousse, Bulgaria

  3.  

  4.  

  5. Plugin thread 1:

  6. https://forums.alliedmods.net/showthread.php?t=171460

  7.  

  8. Plugin thread 2:

  9. http://amxmodxbg.org/forum/viewtopic.php?t=37116

  10.  

  11. Original posted by m0skVi4a ;]

  12.  

  13.  

  14.  

  15. Description:

  16.  

  17. 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.

  18.  

  19.  

  20. Commands:

  21.  

  22. say /reg

  23. say_team /reg

  24. Open the register system menu

  25.  

  26.  

  27. CVARS:

  28.  

  29. "rs_on"                  -      Is the plugin on(1) or off(0).   Default: 1

  30. "rs_save_type"           -      Where to seve the information: to file(0) or to MySQL(1).   Default: 0

  31. "rs_host"                -      The host for the database.   Default: 127.0.0.1

  32. "rs_user"                        -      The username for the database login.   Default: root

  33. "rs_pass"                        -      The password for the database login.   Default:

  34. "rs_db"                          -      The database name.   Default: registersystem

  35. "rs_password_prefix"     -      The prefix of the setinfo for the Auto Login function.   Default: _rspass

  36. "rs_register_time"               -      How much time has the client to register. If is set to 0 registration is not mandatory.   Default: 0

  37. "rs_login_time"                  -      How much time has the client to login if is registered.   Default: 60.0

  38. "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

  39. "rs_password_len"                -      What is minimum length of the password.   Default: 6

  40. "rs_attempts"            -      How much attempts has the client to login if he type wrong password.   Default: 3

  41. "rs_chngpass_times"      -      How much times can the client change his password per map.   Default: 3

  42. "rs_register_log"                -      Is it allowed the plugin to log in file when the client is registered.   Default: 1

  43. "rs_chngpass_log"                -      Is it allowed the plugin to log in file when the client has change his password.   Default: 1

  44. "rs_autologin_log"               -      Is it allowed the plugin to log in file when the client has change his Auto Login function.   Default: 1

  45. "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

  46. "rs_blind"                       -      Whether clients who have not Logged or who must Register be blinded.   Default: 1

  47. "rs_chat"                        -      Whether clients who have not Logged or who must Register chat's be blocked.   Default: 1

  48. "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

  49.  

  50.  

  51. All CVARS are without quotes

  52.  

  53.  

  54. Credits:

  55.  

  56. m0skVi4a ;]     -       for the idea and make the plugin

  57. ConnorMcLeod    -       for his help to block the name change for logged clients

  58. Sylwester               -       for the idea for the encrypt

  59. dark_style      -       for ideas in the plugin

  60.  

  61.  

  62. Changelog:

  63.  

  64. November 6, 2011   -  V1.0 BETA:

  65.         -  First Release

  66.  

  67. November 20, 2011   -  V1.1 FINAL

  68.         -  Fixed some bugs

  69.         -  Added hange Password function

  70.         -  Added Info/Help

  71.         -  Added cvars to show when the client is registered and change his password

  72.         -  Password are now encrypted for more safety

  73.  

  74. November 23, 2011   -  V1.1 FINAL FIX 1

  75.         -  Fixed bug if the client type more than CVAR setted attempts passwords

  76.  

  77. November 28, 2011   -  V1.1 FINAL FIX 2

  78.         -  Fixed bug if that the menu does not pop up when user connect

  79.  

  80. December 26, 2011   -  V2.0

  81.         -  Fixed bug if player change his name and the system does not check the new name

  82.         -  Added block chooseteam if the client is registered but not logged

  83.         -  Added MySQL support

  84.         -  Added .cfg file to manually set the settings of the system

  85.         -  Added CVAR for to set which clients can change their names

  86.         -  Added auto login on changevel or client retry

  87.  

  88. December 27, 2011   -  V2.0 FIX 1

  89.         -  Fixed bug with the kick function

  90.  

  91. January 3, 2012   -  V2.0 FIX 2

  92.         -  Fixed bug with the auto login function that does not work on steam clients

  93.  

  94. January 24, 2012   -  V3.0

  95.         -  Fixed bug with the MYSQL Connection

  96.         -  Added new style of the Change Password function

  97.         -  Removed some CVARs and added new

  98.         -  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

  99.  

  100. February 17, 2012   -  V4.0

  101.         -  Fixed some little bugs

  102.         -  Added new style of the main menu

  103.         -  Removed the possibility of SQL Injection

  104.         -  The whole name change function is rewritten

  105.         -  Added option for the not registered and not logged clients to be blinded

  106.         -  Added option for the not registered and not logged clients chat's to be blocked

  107.         -  Added showing information in the consoles of the clients about why they are kicked

  108.  

  109. February 19, 2012   -  V4.0 FIX 1

  110.         -  Fixed bug with the join in the Spectator team

  111.         -  Added the Auto Assign option in the main menu

  112.         -  Small rewrite of the Auto Login function

  113.  

  114. March 10, 2012   -  V5.0

  115.         -  Fixed bug with % that replace the space in the name of the client

  116.         -  Fixed the bug with the menu that stands when client choose team

  117.         -  Fixed some little bugs

  118.         -  Added new style of the main menu

  119.  

  120.  

  121. Visit http://www.forums.alliedmods.net

  122. Visit http://www.amxmodxbg.org

  123.  

  124.  

  125. Contact me on:


  126. SKYPE: pa7ohin

  127. */

  128.  

  129.  

  130. #include <amxmodx>

  131. #include <amxmisc>

  132. #include <cstrike>

  133. #include <fakemeta>

  134. #include <sqlx>

  135.  

  136. #define TASK_MESS 2133

  137. #define TASK_KICK 3312

  138. #define SALT "8c4f4370c53e0c1e1ae9acd577dddbed" //The SALT for the password encryption. It can be edited!

  139.  

  140. 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

  141. 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

  142. new bool:is_logged[33], bool:is_registered[33], bool:is_autolog[33], attempts[33], times[33]; //Booleans and other arrays

  143. new menu[512], keys, length; //variables and array for the menus

  144. new Handle:g_SQLTuple, g_error[512]; //SQL array and handle

  145. new g_saytxt, g_screenfade; //other variables

  146. new const prefix[] = "[Regisztracios Rendszer]"; //The prefix in the chat messages. It can be edited!

  147. new const log_file[] = "register_system_log.txt"; //The name of the log file. It can be edited!

  148. new const JOIN_TEAM_MENU_FIRST[] = "#Team_Select"; //The text of the Team Select menu. DO NOT CHANGE!

  149. new const JOIN_TEAM_MENU_FIRST_SPEC[] = "#Team_Select_Spect"; //The text of the Spectator Team Select menu. DO NOT CHANGE!

  150. new const JOIN_TEAM_MENU_INGAME[] = "#IG_Team_Select"; //The text of the Ingame Team Select menu. DO NOT CHANGE!

  151. new const JOIN_TEAM_MENU_INGAME_SPEC[] = "#IG_Team_Select_Spect"; //The text of the Ingame Spectator Team Select menu. DO NOT CHANGE!

  152. new const JOIN_TEAM_VGUI_MENU = 2; //The number of the VGUI menu for Team Select. DO NOT CHANGE!

  153. new const NAME_CHANGE_MSG[] = "#Cstrike_Name_Change"; ////The text of the Name Change Message. DO NOT CHANGE!

  154.  

  155. /*==============================================================================

  156.         Start of Plugin Init

  157. ================================================================================*/

  158. public plugin_init()

  159. {

  160.         register_plugin("Register System", "5.0", "m0skVi4a ;]")

  161.  

  162.         g_on = register_cvar("rs_on", "1") //Is the plugin on(1) or off(0)

  163.         g_save = register_cvar("rs_save_type", "0") //Where to seve the information: to file(0) or to MySQL(1).

  164.         g_host = register_cvar("rs_host", "127.0.0.1") //The host for the database.

  165.         g_user = register_cvar("rs_user", "root") //The username for the database login.

  166.         g_pass = register_cvar("rs_pass", "") //The password for the database login.

  167.         g_db = register_cvar("rs_db", "registersystem") //The database name.

  168.         g_setinfo_pr = register_cvar("rs_password_prefix", "_rspass") //The prefix of the setinfo for the auto login.

  169.         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.

  170.         g_logtime = register_cvar("rs_login_time", "60.0") //How much time has the client to login if is registered.

  171.         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).

  172.         g_pass_length = register_cvar("rs_password_length", "6") //What is minimum length of the password.

  173.         g_attempts = register_cvar("rs_attempts", "3") //How much attempts has the client to login if he type wrong password.

  174.         g_chp_time = register_cvar("rs_chngpass_times", "3") //How much times can the client change his password per map.

  175.         g_reg_log = register_cvar("rs_register_log", "1") //Is it allowed the plugin to log in file when the client is registered.

  176.         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.

  177.         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.

  178.         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).

  179.         g_blind = register_cvar("rs_blind", "1") //Whether clients who have not Logged or who must Register be blinded.

  180.         g_chat = register_cvar("rs_chat", "1") //Whether clients who have not Logged or who must Register chat's be blocked.

  181.         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).

  182.  

  183.         register_message(get_user_msgid("ShowMenu"), "ShowMenu")

  184.         register_message(get_user_msgid("VGUIMenu"), "VGUIMenu")

  185.         register_menucmd(register_menuid("Main Menu"), 1023, "HandlerMainMenu")

  186.         register_menucmd(register_menuid("Options Menu"), 1023, "HandlerOptionsMenu")

  187.         register_menucmd(register_menuid("Password Menu"), 1023, "HandlerConfirmPasswordMenu")

  188.         register_clcmd("jointeam", "HookJoinCommands")

  189.         register_clcmd("chooseteam", "HookJoinCommands")

  190.         register_clcmd("say", "HookSayCommands")

  191.         register_clcmd("say_team", "HookSayCommands")

  192.         register_clcmd("LOGIN_PASS", "Login")

  193.         register_clcmd("REGISTER_PASS", "Register")

  194.         register_clcmd("CHANGE_PASS_NEW", "ChangePasswordNew")

  195.         register_clcmd("CHANGE_PASS_OLD", "ChangePasswordOld")

  196.         register_clcmd("AUTO_LOGIN_PASS", "AutoLoginPassword")

  197.  

  198.         register_forward(FM_PlayerPreThink, "PlayerPreThink")

  199.         register_forward(FM_ClientUserInfoChanged, "ClientInfoChanged")

  200.  

  201.         register_dictionary("register_system.txt")

  202.         g_saytxt = get_user_msgid("SayText")

  203.         g_screenfade = get_user_msgid("ScreenFade")

  204. }

  205. /*==============================================================================

  206.         End of Plugin Init

  207. ================================================================================*/

  208.  

  209. /*==============================================================================

  210.         Start of Executing plugin's config and choose the save mode

  211. ================================================================================*/

  212. public plugin_cfg()

  213. {

  214.         if(!get_pcvar_num(g_on))

  215.                 return PLUGIN_HANDLED

  216.  

  217.         get_configsdir(configs_dir, charsmax(configs_dir))

  218.         formatex(file, charsmax(file), "%s/registersystem.cfg", configs_dir)

  219.  

  220.         if(!file_exists(file))

  221.         {

  222.                 server_print("%L", LANG_SERVER, "ERROR_CFG", file)

  223.         }

  224.         else

  225.         {

  226.                 server_cmd("exec %s", file)

  227.                 server_print("%L", LANG_SERVER, "CFG_EXEC", file)

  228.         }

  229.  

  230.         if(get_pcvar_num(g_save))

  231.         {

  232.                 new Host[64], User[32], Pass[32], DB[128];

  233.  

  234.                 get_pcvar_string(g_host, Host, charsmax(Host))

  235.                 get_pcvar_string(g_user, User, charsmax(User))

  236.                 get_pcvar_string(g_pass, Pass, charsmax(Pass))

  237.                 get_pcvar_string(g_db, DB, charsmax(DB))

  238.  

  239.                 g_SQLTuple = SQL_MakeDbTuple(Host, User, Pass, DB)

  240.  

  241.                 new errorcode, Handle:SqlConnection = SQL_Connect(g_SQLTuple, errorcode, g_error, charsmax(g_error))

  242.  

  243.                 if(SqlConnection == Empty_Handle)

  244.                 {

  245.                         server_print("%L", LANG_SERVER, "ERROR_MYSQL")

  246.                         set_fail_state(g_error)

  247.                 }

  248.                 else

  249.                 {

  250.                         server_print("%L", LANG_SERVER, "MYSQL_CONNECT")

  251.                 }

  252.  

  253.                 new Handle:Query

  254.  

  255.                 Query = SQL_PrepareQuery(SqlConnection, "CREATE TABLE IF NOT EXISTS registersystem (Name VARCHAR(32), Password VARCHAR(34), Status VARCHAR(10))")

  256.  

  257.                 if(!SQL_Execute(Query))

  258.                 {

  259.                         SQL_QueryError(Query, g_error, charsmax(g_error))

  260.                         set_fail_state(g_error)

  261.                 }

  262.  

  263.                 SQL_FreeHandle(Query)

  264.                 SQL_FreeHandle(SqlConnection)

  265.         }

  266.         else

  267.         {

  268.                 get_configsdir(configs_dir, charsmax(configs_dir))

  269.                 formatex(reg_file, charsmax(reg_file), "%s/regusers.ini", configs_dir)

  270.  

  271.                 if(!file_exists(reg_file))

  272.                 {

  273.                         write_file(reg_file,";Register System file^n;Modifying may cause the clients to can not Login!^n^n")

  274.                         server_print("%L", LANG_SERVER, "ERROR_FILE", reg_file)

  275.                 }

  276.         }

  277.         return PLUGIN_CONTINUE

  278. }

  279. /*==============================================================================

  280.         End of Executing plugin's config and choose the save mode

  281. ================================================================================*/

  282.  

  283. /*==============================================================================

  284.         Start of Client's connect and disconenct functions

  285. ================================================================================*/

  286. public client_connect(id)

  287. {

  288.         is_logged[id] = false

  289.         is_registered[id] = false

  290.         is_autolog[id] = false

  291.         attempts[id] = 0

  292.         times[id] = 0

  293.         remove_task(id+TASK_MESS)

  294.         CheckClient(id)

  295. }

  296.  

  297. public client_putinserver(id)

  298. {

  299.         ShowMsg(id)

  300. }

  301.  

  302. public client_disconnect(id)

  303. {

  304.         is_logged[id] = false

  305.         is_registered[id] = false

  306.         is_autolog[id] = false

  307.         attempts[id] = 0

  308.         times[id] = 0

  309.         remove_task(id+TASK_MESS)

  310.         remove_task(id+TASK_KICK)

  311. }

  312. /*==============================================================================

  313.         End of Client's connect and disconenct functions

  314. ================================================================================*/

  315.  

  316. /*==============================================================================

  317.         Start of Show Menu functions

  318. ================================================================================*/

  319. public ShowMenu(msgid, dest, id)

  320. {

  321.         if(get_pcvar_num(g_on))

  322.         {

  323.                 new menu_text[64]

  324.  

  325.                 get_msg_arg_string(4, menu_text, charsmax(menu_text))  

  326.  

  327.                 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))

  328.                 {

  329.                         Menu(id)

  330.  

  331.                         return PLUGIN_HANDLED

  332.                 }

  333.  

  334.                 return PLUGIN_CONTINUE

  335.         }

  336.         return PLUGIN_CONTINUE

  337. }

  338.  

  339. public VGUIMenu(msgid, dest, id)

  340. {

  341.         if(get_pcvar_num(g_on))

  342.         {

  343.                 if(get_msg_arg_int(1) == JOIN_TEAM_VGUI_MENU)

  344.                 {

  345.                         Menu(id)

  346.  

  347.                         return PLUGIN_HANDLED

  348.                 }

  349.  

  350.                 return PLUGIN_CONTINUE

  351.         }

  352.  

  353.         return PLUGIN_CONTINUE

  354. }

  355. /*==============================================================================

  356.         End of Show Menu functions

  357. ================================================================================*/

  358.  

  359. /*==============================================================================

  360.         Start of Check Client functions

  361. ================================================================================*/

  362. public CheckClient(id)

  363. {

  364.         if(!get_pcvar_num(g_on) || is_user_bot(id))

  365.                 return PLUGIN_HANDLED

  366.  

  367.         is_registered[id] = false

  368.         is_autolog[id] = false

  369.         is_logged[id] = false

  370.         remove_task(id+TASK_KICK)

  371.  

  372.         if(get_pcvar_num(g_save))

  373.         {

  374.                 get_user_name(id, name, charsmax(name))

  375.  

  376.                 new data[1]

  377.                 data[0] = id

  378.  

  379.                 formatex(query, charsmax(query), "SELECT `Password`, `Status` FROM `registersystem` WHERE Name = ^"%s^";", name)

  380.  

  381.                 SQL_ThreadQuery(g_SQLTuple, "QuerySelectData", query, data, 1)

  382.         }

  383.         else

  384.         {

  385.                 new file = fopen(reg_file, "r")

  386.  

  387.                 while(!feof(file))

  388.                 {

  389.                         get_user_name(id, name, charsmax(name))

  390.                         fgets(file, namepass, charsmax(namepass))

  391.                         parse(namepass, check_name, charsmax(check_name), check_pass, charsmax(check_pass), check_status, charsmax(check_status))

  392.  

  393.                         if(namepass[0] == ';')

  394.                                 continue

  395.  

  396.                         if(equal(check_name, name))

  397.                         {

  398.                                 is_registered[id] = true

  399.                                 password[id] = check_pass

  400.  

  401.                                 if(is_user_connected(id))

  402.                                 {

  403.                                         user_silentkill(id)

  404.                                         cs_set_user_team(id, CS_TEAM_UNASSIGNED)

  405.                                         ShowMsg(id)

  406.                                         Menu(id)

  407.                                 }

  408.  

  409.                                 if(equal(check_status, "LOGGED"))

  410.                                 {

  411.                                         is_autolog[id] = true

  412.                                         CheckAutoLogin(id)

  413.                                 }

  414.  

  415.                                 break

  416.                         }

  417.                 }

  418.                 fclose(file)

  419.         }

  420.         return PLUGIN_CONTINUE

  421. }

  422.  

  423. public QuerySelectData(FailState, Handle:Query, error[], errorcode, data[], datasize, Float:fQueueTime)

  424. {

  425.         if(FailState == TQUERY_CONNECT_FAILED || FailState == TQUERY_QUERY_FAILED)

  426.         {

  427.                 log_amx("%s", error)

  428.                 return

  429.         }

  430.         else

  431.         {

  432.                 new id = data[0];

  433.                 new col_pass = SQL_FieldNameToNum(Query, "Password")

  434.                 new col_status = SQL_FieldNameToNum(Query, "Status")

  435.  

  436.                 while(SQL_MoreResults(Query))

  437.                 {

  438.                         SQL_ReadResult(Query, col_pass, check_pass, charsmax(check_pass))

  439.                         SQL_ReadResult(Query, col_status, check_status, charsmax(check_status))

  440.                         is_registered[id] = true

  441.                         password[id] = check_pass

  442.  

  443.                         if(is_user_connected(id))

  444.                         {

  445.                                 user_silentkill(id)

  446.                                 cs_set_user_team(id, CS_TEAM_UNASSIGNED)

  447.                                 ShowMsg(id)

  448.                                 Menu(id)

  449.                         }

  450.  

  451.                         if(equal(check_status, "LOGGED"))

  452.                         {

  453.                                 is_autolog[id] = true

  454.                                 CheckAutoLogin(id)

  455.                         }

  456.                         SQL_NextRow(Query)

  457.                 }

  458.         }

  459. }

  460.  

  461. public CheckAutoLogin(id)

  462. {

  463.         new client_password[32];

  464.         get_pcvar_string(g_setinfo_pr, pass_prefix, charsmax(pass_prefix))

  465.         get_user_info(id, pass_prefix, client_password, charsmax(client_password))

  466.         formatex(passsalt, charsmax(passsalt), "%s%s", client_password, SALT)

  467.         md5(passsalt, hash)

  468.  

  469.         if(equal(hash, password[id]))

  470.         {

  471.                 is_logged[id] = true

  472.         }

  473. }

  474. /*==============================================================================

  475.         End of Check Client functions

  476. ================================================================================*/

  477.  

  478. /*==============================================================================

  479.         Start of Show Client's informative messages

  480. ================================================================================*/

  481. public ShowMsg(id)

  482. {

  483.         if(!get_pcvar_num(g_on))

  484.                 return PLUGIN_HANDLED

  485.  

  486.         set_task(5.0, "Messages", id+TASK_MESS)

  487.  

  488.         params[0] = id

  489.  

  490.         if(!is_registered[id])

  491.         {

  492.                 if(get_pcvar_float(g_regtime) != 0)

  493.                 {

  494.                         params[1] = 1

  495.                         set_task(get_pcvar_float(g_regtime), "KickPlayer", id+TASK_KICK, params, sizeof params)

  496.                         return PLUGIN_HANDLED

  497.                 }

  498.         }

  499.         else

  500.         {

  501.                 params[1] = 2

  502.                 set_task(get_pcvar_float(g_logtime), "KickPlayer", id+TASK_KICK, params, sizeof params)

  503.                 return PLUGIN_HANDLED

  504.         }

  505.         return PLUGIN_CONTINUE

  506. }

  507.  

  508. public Messages(id)

  509. {

  510.         id -= TASK_MESS

  511.  

  512.         if(get_pcvar_num(g_msg) == 1 || get_pcvar_num(g_msg) == 3)

  513.         {

  514.                 if(!is_registered[id])

  515.                 {

  516.                         if(get_pcvar_float(g_regtime) != 0)

  517.                         {

  518.                                 set_hudmessage(255, 0, 0, -1.0, -1.0, 0, 0.5, 5.0, 2.0, 2.0, -1)

  519.                                 show_hudmessage(id, "%L", LANG_SERVER, "REGISTER_HUD", get_pcvar_num(g_regtime))

  520.                         }

  521.                         else

  522.                         {

  523.                                 set_hudmessage(0, 255, 0, -1.0, -1.0, 0, 0.5, 5.0, 2.0, 2.0, -1)

  524.                                 show_hudmessage(id, "%L", LANG_SERVER, "YOUCANREG_HUD", get_pcvar_num(g_regtime))

  525.                         }

  526.                 }

  527.                 else if(!is_logged[id])

  528.                 {

  529.                         set_hudmessage(255, 0, 0, -1.0, -1.0, 0, 0.5, 5.0, 2.0, 2.0, -1)

  530.                         show_hudmessage(id, "%L", LANG_SERVER, "LOGIN_HUD", get_pcvar_num(g_logtime))

  531.                 }

  532.                 else if(is_autolog[id])

  533.                 {

  534.                         set_hudmessage(0, 255, 0, -1.0, -1.0, 0, 0.5, 5.0, 2.0, 2.0, -1)

  535.                         show_hudmessage(id, "%L", LANG_SERVER, "AUTO_LOGIN_HUD")

  536.                 }

  537.         }

  538.  

  539.         if(get_pcvar_num(g_msg) == 2 || get_pcvar_num(g_msg) == 3)

  540.         {

  541.                 if(!is_registered[id])

  542.                 {

  543.                         if(get_pcvar_float(g_regtime) != 0)

  544.                         {

  545.                                 client_printcolor(id, "%L", LANG_SERVER, "REGISTER_CHAT", prefix, get_pcvar_num(g_regtime))

  546.                         }

  547.                         else

  548.                         {

  549.                                 client_printcolor(id, "%L", LANG_SERVER, "YOUCANREG_CHAT", prefix, get_pcvar_num(g_regtime))

  550.                         }

  551.                 }

  552.                 else if(!is_logged[id])

  553.                 {

  554.                         client_printcolor(id, "%L", LANG_SERVER, "LOGIN_CHAT", prefix, get_pcvar_num(g_logtime))

  555.                 }

  556.                 else if(is_autolog[id])

  557.                 {

  558.                         client_printcolor(id, "%L", LANG_SERVER, "AUTO_LOGIN_CHAT", prefix)

  559.                 }

  560.         }

  561. }

  562. /*==============================================================================

  563.         End of Show Client's informative messages

  564. ================================================================================*/

  565.  

  566. /*==============================================================================

  567.         Start of Hook Client's jointeam commands

  568. ================================================================================*/

  569. public HookJoinCommands(id)

  570. {

  571.         if(get_pcvar_num(g_on))

  572.         {

  573.                 if((!is_registered[id] && get_pcvar_float(g_regtime)) || (is_registered[id] && !is_logged[id]))

  574.                 {

  575.                         Menu(id)

  576.                         return PLUGIN_HANDLED

  577.                 }

  578.  

  579.                 return PLUGIN_CONTINUE

  580.         }

  581.  

  582.         return PLUGIN_CONTINUE

  583. }

  584. /*==============================================================================

  585.         End of Hook Client's jointeam commands

  586. ================================================================================*/

  587.  

  588. /*==============================================================================

  589.         Start of Hook Client's say commands

  590. ================================================================================*/

  591. public HookSayCommands(id)

  592. {

  593.         new g_message[16];

  594.         read_args(g_message, charsmax(g_message))

  595.         remove_quotes(g_message)

  596.  

  597.         if(get_pcvar_num(g_on))

  598.         {

  599.                 if(equal(g_message, "/reg"))

  600.                 {

  601.                         Menu(id)

  602.                 }

  603.                 else if(get_pcvar_num(g_chat))

  604.                 {

  605.                         if(!is_registered[id] && get_pcvar_float(g_regtime))

  606.                         {

  607.                                 client_printcolor(id, "%L", LANG_SERVER, "CHAT_REG", prefix)

  608.                                 return PLUGIN_HANDLED                  

  609.                         }

  610.                         else if(is_registered[id] && !is_logged[id])

  611.                         {

  612.                                 client_printcolor(id, "%L", LANG_SERVER, "CHAT_LOG", prefix)  

  613.                                 return PLUGIN_HANDLED

  614.                         }

  615.                 }

  616.         }

  617.  

  618.         return PLUGIN_CONTINUE

  619. }

  620. /*==============================================================================

  621.         End of Hook Client's say commands

  622. ================================================================================*/

  623.  

  624. /*==============================================================================

  625.         Start of the Main Menu function

  626. ================================================================================*/

  627. public Menu(id)

  628. {

  629.         if(!get_pcvar_num(g_on) || !is_user_connected(id))

  630.                 return PLUGIN_HANDLED

  631.  

  632.         length = 0

  633.  

  634.         if(is_registered[id])

  635.         {

  636.                 if(is_logged[id])

  637.                 {

  638.                         length += formatex(menu[length], charsmax(menu) - length, "%L", LANG_SERVER, "MAIN_MENU_LOG")

  639.                         keys = MENU_KEY_1|MENU_KEY_2|MENU_KEY_5|MENU_KEY_6|MENU_KEY_7|MENU_KEY_9|MENU_KEY_0

  640.                 }

  641.                 else

  642.                 {

  643.                         length += formatex(menu[length], charsmax(menu) - length, "%L", LANG_SERVER, "MAIN_MENU_REG")

  644.                         keys = MENU_KEY_7|MENU_KEY_9

  645.                 }

  646.         }

  647.         else

  648.         {              

  649.                 if(get_pcvar_float(g_regtime) == 0)

  650.                 {

  651.                         length += formatex(menu[length], charsmax(menu) - length, "%L", LANG_SERVER, "MAIN_MENU_NOTREG")

  652.                         keys = MENU_KEY_1|MENU_KEY_2|MENU_KEY_5|MENU_KEY_6|MENU_KEY_8|MENU_KEY_9|MENU_KEY_0

  653.                 }

  654.                 else

  655.                 {

  656.                         length += formatex(menu[length], charsmax(menu) - length, "%L", LANG_SERVER, "MAIN_MENU_NOTREG_FORCE")

  657.                         keys = MENU_KEY_8|MENU_KEY_9

  658.                 }

  659.         }

  660.         show_menu(id, keys, menu, -1, "Main Menu")

  661.  

  662.         return PLUGIN_CONTINUE

  663. }

  664.  

  665. public HandlerMainMenu(id, key)

  666. {

  667.         switch(key)

  668.         {

  669.                 case 0:

  670.                 {

  671.                         client_cmd(id, "jointeam 1")

  672.                 }

  673.                 case 1:

  674.                 {

  675.                         client_cmd(id, "jointeam 2")

  676.                 }

  677.                 case 4:

  678.                 {

  679.                         client_cmd(id, "jointeam 5")

  680.                 }

  681.                 case 5:

  682.                 {

  683.                         client_cmd(id, "jointeam 6")

  684.                 }

  685.                 case 6:

  686.                 {

  687.                         if(!is_logged[id])

  688.                         {

  689.                                 client_cmd(id, "messagemode LOGIN_PASS")

  690.                                 Menu(id)

  691.                         }

  692.                         else

  693.                         {

  694.                                 is_logged[id] = false

  695.  

  696.                                 if(is_autolog[id])

  697.                                 {

  698.                                         AutoLogin(id)

  699.                                 }

  700.                                 get_pcvar_string(g_setinfo_pr, pass_prefix, charsmax(pass_prefix))

  701.                                 client_cmd(id, "setinfo %s ^"^"", pass_prefix)

  702.                                 client_printcolor(id, "%L", LANG_SERVER, "LOG_OUT", prefix)

  703.  

  704.                                 if(get_pcvar_num(g_logout))

  705.                                 {

  706.                                         ShowMsg(id)

  707.                                         Menu(id)

  708.                                 }

  709.                                 else

  710.                                 {

  711.                                         params[0] = id

  712.                                         params[1] = 4

  713.                                         set_task(2.0, "KickPlayer", id+TASK_KICK, params, sizeof params)

  714.                                 }

  715.                         }

  716.                 }

  717.                 case 7:

  718.                 {

  719.                         client_cmd(id, "messagemode REGISTER_PASS")

  720.                         Menu(id)

  721.                 }

  722.                 case 8:

  723.                 {

  724.                         OptionsMenu(id)

  725.                 }

  726.                 case 9:

  727.                 {

  728.                         return PLUGIN_HANDLED

  729.                 }

  730.         }

  731.         return PLUGIN_HANDLED

  732. }

  733. /*==============================================================================

  734.         End of the Main Menu function

  735. ================================================================================*/

  736.  

  737. /*==============================================================================

  738.         Start of the Options Menu function

  739. ================================================================================*/

  740. public OptionsMenu(id)

  741. {

  742.         if(!get_pcvar_num(g_on) || !is_user_connected(id))

  743.                 return PLUGIN_HANDLED

  744.  

  745.         length = 0

  746.  

  747.         if(is_logged[id])

  748.         {

  749.                 if(is_autolog[id])

  750.                 {

  751.                         length += formatex(menu[length], charsmax(menu) - length, "%L", LANG_SERVER, "OPTIONS_MENU_LOG_ON")

  752.                 }

  753.                 else

  754.                 {

  755.                         length += formatex(menu[length], charsmax(menu) - length, "%L", LANG_SERVER, "OPTIONS_MENU_LOG_OFF")

  756.                 }

  757.                 keys = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_0

  758.         }

  759.         else

  760.         {

  761.                 length += formatex(menu[length], charsmax(menu) - length, "%L", LANG_SERVER, "OPTIONS_MENU_NOT_LOG")

  762.                 keys = MENU_KEY_3|MENU_KEY_0

  763.         }

  764.  

  765.         show_menu(id, keys, menu, -1, "Options Menu")

  766.  

  767.         return PLUGIN_CONTINUE

  768. }

  769.  

  770. public HandlerOptionsMenu(id, key)

  771. {

  772.         switch(key)

  773.         {

  774.                 case 0:

  775.                 {

  776.                         if(times[id] >= get_pcvar_num(g_chp_time))

  777.                         {

  778.                                 client_printcolor(id, "%L", LANG_SERVER, "CHANGE_TIMES", prefix, get_pcvar_num(g_chp_time))

  779.                                 return PLUGIN_HANDLED

  780.                         }

  781.                         else

  782.                         {

  783.                                 client_cmd(id, "messagemode CHANGE_PASS_NEW")

  784.                         }

  785.                         OptionsMenu(id)

  786.                 }

  787.                 case 1:

  788.                 {

  789.                         if(is_autolog[id])

  790.                         {

  791.                                 AutoLogin(id)

  792.                         }

  793.                         else

  794.                         {

  795.                                 client_cmd(id, "messagemode AUTO_LOGIN_PASS")

  796.                         }

  797.                         OptionsMenu(id)

  798.                 }

  799.                 case 2:

  800.                 {

  801.                         Info(id)

  802.                         OptionsMenu(id)

  803.                 }

  804.                 case 9:

  805.                 {

  806.                         Menu(id)

  807.                         return PLUGIN_HANDLED

  808.                 }

  809.         }

  810.         return PLUGIN_HANDLED

  811. }

  812. /*==============================================================================

  813.         End of the Options Menu function

  814. ================================================================================*/

  815.  

  816. /*==============================================================================

  817.         Start of Client's Auto Login Changer function

  818. ================================================================================*/

  819. public AutoLogin(id)

  820. {

  821.         get_user_name(id, name, charsmax(name))

  822.  

  823.         if(!is_registered[id] || !is_logged[id])

  824.                 return PLUGIN_HANDLED

  825.  

  826.         if(get_pcvar_num(g_save))

  827.         {

  828.                 formatex(query, charsmax(query), "UPDATE registersystem SET Status = ^"%s^" WHERE Name = ^"%s^";", is_autolog[id] == true ? "" : "LOGGED", name)

  829.                 SQL_ThreadQuery(g_SQLTuple, "QuerySetData", query)

  830.         }

  831.         else

  832.         {

  833.                 new line, file = fopen(reg_file, "r");

  834.  

  835.                 while(!feof(file))

  836.                 {

  837.                         fgets(file, namepass, 255)

  838.                         parse(namepass, namepass, charsmax(namepass))

  839.                         line++

  840.  

  841.                         if(equal(namepass, name))

  842.                         {                                              

  843.                                 formatex(namepass, charsmax(namepass), "^"%s^" ^"%s^" ^"%s^"", name, password[id], is_autolog[id] == true ? "" : "LOGGED")

  844.                                 write_file(reg_file, namepass, line - 1)                                                       

  845.  

  846.                                 break

  847.                         }

  848.                 }

  849.                 fclose(file)

  850.         }

  851.  

  852.         if(is_autolog[id])

  853.         {

  854.                 is_autolog[id] = false

  855.                 client_printcolor(id, "%L", LANG_SERVER, "AUTO_LOGIN_OFF", prefix)

  856.                 get_pcvar_string(g_setinfo_pr, pass_prefix, charsmax(pass_prefix))

  857.                 client_cmd(id, "setinfo %s ^"^"", pass_prefix)

  858.  

  859.                 if(get_pcvar_num(g_aulog_log))

  860.                 {

  861.                         log_to_file(log_file, "%L", LANG_SERVER, "LOGFILE_AUTO_OFF", name)

  862.                 }

  863.         }

  864.         else

  865.         {

  866.                 is_autolog[id] = true

  867.                 client_printcolor(id, "%L", LANG_SERVER, "AUTO_LOGIN_ON", prefix)

  868.                 if(get_pcvar_num(g_aulog_log))

  869.                 {

  870.                         log_to_file(log_file, "%L", LANG_SERVER, "LOGFILE_AUTO_ON", name)

  871.                 }

  872.         }

  873.  

  874.         return PLUGIN_CONTINUE

  875. }

  876.  

  877. public AutoLoginPassword(id)

  878. {

  879.         if(!get_pcvar_num(g_on))

  880.                 return PLUGIN_HANDLED

  881.  

  882.         read_args(typedpass, charsmax(typedpass))

  883.         remove_quotes(typedpass)

  884.         formatex(passsalt, charsmax(passsalt), "%s%s", typedpass, SALT)

  885.         md5(passsalt, hash)

  886.  

  887.         if(!equal(hash, password[id]))

  888.         {

  889.                 client_printcolor(id, "%L", LANG_SERVER, "AUTO_LOGIN_PASS_NOTVALID", prefix)

  890.                 client_cmd(id, "messagemode AUTO_LOGIN_PASS")

  891.                 return PLUGIN_HANDLED

  892.         }

  893.         else

  894.         {

  895.                 get_pcvar_string(g_setinfo_pr, pass_prefix, charsmax(pass_prefix))

  896.                 client_cmd(id, "setinfo %s %s", pass_prefix, typedpass)

  897.                 AutoLogin(id)

  898.                 OptionsMenu(id)

  899.         }

  900.         return PLUGIN_CONTINUE

  901. }

  902. /*==============================================================================

  903.         End of Client's Auto Login Changer function

  904. ================================================================================*/

  905.  

  906. /*==============================================================================

  907.         Start of Info/Help MOTD function

  908. ================================================================================*/

  909. public Info(id)

  910. {

  911.         show_motd(id, "rshelpmotd.txt", "Regisztracios rendszer Segitseg")

  912. }

  913. /*==============================================================================

  914.         End of Info/Help MOTD function

  915. ================================================================================*/

  916.  

  917. /*==============================================================================

  918.         Start of Login function

  919. ================================================================================*/

  920. public Login(id)

  921. {

  922.         if(!get_pcvar_num(g_on))

  923.                 return PLUGIN_HANDLED

  924.  

  925.         if(!is_registered[id])

  926.         {      

  927.                 client_printcolor(id, "%L", LANG_SERVER, "LOG_NOTREG", prefix)

  928.                 return PLUGIN_HANDLED

  929.         }

  930.  

  931.         if(is_logged[id])

  932.         {

  933.                 client_printcolor(id, "%L", LANG_SERVER, "LOG_LOGGED", prefix);

  934.                 return PLUGIN_HANDLED

  935.         }

  936.  

  937.         read_args(typedpass, charsmax(typedpass))

  938.         remove_quotes(typedpass)

  939.  

  940.         if(equal(typedpass, ""))

  941.                 return PLUGIN_HANDLED

  942.  

  943.         formatex(passsalt, charsmax(passsalt), "%s%s", typedpass, SALT)

  944.         md5(passsalt, hash)

  945.  

  946.         if(!equal(hash, password[id]))

  947.         {      

  948.                 attempts[id]++

  949.                 client_printcolor(id, "%L", LANG_SERVER, "LOG_PASS_INVALID", prefix, attempts[id], get_pcvar_num(g_attempts))

  950.  

  951.                 if(attempts[id] >= get_pcvar_num(g_attempts))

  952.                 {

  953.                         params[0] = id

  954.                         params[1] = 3

  955.                         set_task(2.0, "KickPlayer", id+TASK_KICK, params, sizeof params)

  956.                         return PLUGIN_HANDLED

  957.                 }

  958.                 else

  959.                 {

  960.                         client_cmd(id, "messagemode LOGIN_PASS")

  961.                 }

  962.                 return PLUGIN_HANDLED

  963.         }

  964.         else

  965.         {

  966.                 is_logged[id] = true

  967.                 attempts[id] = 0

  968.                 remove_task(id+TASK_KICK)

  969.                 client_printcolor(id, "%L", LANG_SERVER, "LOG_LOGING", prefix)

  970.                 Menu(id)

  971.         }

  972.         return PLUGIN_CONTINUE

  973. }

  974. /*==============================================================================

  975.         End of Login function

  976. ================================================================================*/

  977.  

  978. /*==============================================================================

  979.         Start of Register function

  980. ================================================================================*/

  981. public Register(id)

  982. {

  983.         if(!get_pcvar_num(g_on))

  984.                 return PLUGIN_HANDLED

  985.  

  986.         read_args(typedpass, charsmax(typedpass))

  987.         remove_quotes(typedpass)

  988.  

  989.         new passlength = strlen(typedpass)

  990.  

  991.         if(equal(typedpass, ""))

  992.                 return PLUGIN_HANDLED

  993.  

  994.         if(is_registered[id])

  995.         {

  996.                 client_printcolor(id, "%L", LANG_SERVER, "REG_EXISTS", prefix)

  997.                 return PLUGIN_HANDLED

  998.         }

  999.  

  1000.         if(passlength < get_pcvar_num(g_pass_length))

  1001.         {

  1002.                 client_printcolor(id, "%L", LANG_SERVER, "REG_LEN", prefix, get_pcvar_num(g_pass_length))

  1003.                 client_cmd(id, "messagemode REGISTER_PASS")

  1004.                 return PLUGIN_HANDLED

  1005.         }

  1006.  

  1007.         new_pass[id] = typedpass

  1008.         ConfirmPassword(id)

  1009.         return PLUGIN_CONTINUE

  1010. }

  1011. /*==============================================================================

  1012.         End of Register function

  1013. ================================================================================*/

  1014.  

  1015. /*==============================================================================

  1016.         Start of Change Password function

  1017. ================================================================================*/

  1018. public ChangePasswordNew(id)

  1019. {

  1020.         if(!get_pcvar_num(g_on) || !is_registered[id] || !is_logged[id])

  1021.                 return PLUGIN_HANDLED

  1022.  

  1023.         read_args(typedpass, charsmax(typedpass))

  1024.         remove_quotes(typedpass)

  1025.  

  1026.         new passlenght = strlen(typedpass)

  1027.  

  1028.         if(equal(typedpass, ""))

  1029.                 return PLUGIN_HANDLED

  1030.  

  1031.         if(passlenght < get_pcvar_num(g_pass_length))

  1032.         {

  1033.                 client_printcolor(id, "%L", LANG_SERVER, "REG_LEN", prefix, get_pcvar_num(g_pass_length))

  1034.                 client_cmd(id, "messagemode CHANGE_PASS_NEW")

  1035.                 return PLUGIN_HANDLED

  1036.         }

  1037.  

  1038.         new_pass[id] = typedpass

  1039.         client_cmd(id, "messagemode CHANGE_PASS_OLD")

  1040.         return PLUGIN_CONTINUE

  1041. }

  1042.  

  1043. public ChangePasswordOld(id)

  1044. {

  1045.         if(!get_pcvar_num(g_on) || !is_registered[id] || !is_logged[id])

  1046.                 return PLUGIN_HANDLED

  1047.  

  1048.         read_args(typedpass, charsmax(typedpass))

  1049.         remove_quotes(typedpass)

  1050.         formatex(passsalt, charsmax(passsalt), "%s%s", typedpass, SALT)

  1051.         md5(passsalt, hash)

  1052.  

  1053.         if(equal(typedpass, "") || equal(new_pass[id], ""))

  1054.                 return PLUGIN_HANDLED

  1055.  

  1056.         if(!equali(hash, password[id]))

  1057.         {

  1058.                 client_printcolor(id, "%L", LANG_SERVER, "CHANGE_NO", prefix)

  1059.                 return PLUGIN_HANDLED

  1060.         }

  1061.  

  1062.         ConfirmPassword(id)

  1063.         return PLUGIN_CONTINUE

  1064. }

  1065. /*==============================================================================

  1066.         End of Change Password function

  1067. ================================================================================*/

  1068.  

  1069. /*==============================================================================

  1070.         Start of Confirming Register's or Change Password's password function

  1071. ================================================================================*/

  1072. public ConfirmPassword(id)

  1073. {

  1074.         if(!get_pcvar_num(g_on) || !is_user_connected(id))

  1075.                 return PLUGIN_HANDLED

  1076.  

  1077.         length = 0

  1078.  

  1079.         formatex(menu, charsmax(menu) - length, "%L", LANG_SERVER, "MENU_PASS", new_pass[id])

  1080.         keys = MENU_KEY_1|MENU_KEY_2|MENU_KEY_0

  1081.  

  1082.         show_menu(id, keys, menu, -1, "Password Menu")

  1083.         return PLUGIN_CONTINUE

  1084. }

  1085.  

  1086. public HandlerConfirmPasswordMenu(id, key)

  1087. {

  1088.         switch(key)

  1089.         {

  1090.                 case 0:

  1091.                 {

  1092.                         get_user_name(id, name, charsmax(name))

  1093.                         formatex(passsalt, charsmax(passsalt), "%s%s", new_pass[id],  SALT)

  1094.                         md5(passsalt, hash)

  1095.  

  1096.                         if(is_registered[id])

  1097.                         {

  1098.                                 if(get_pcvar_num(g_save))

  1099.                                 {

  1100.                                         formatex(namepass, charsmax(namepass), "UPDATE `registersystem` SET Password = ^"%s^", Status = ^"%s^" WHERE Name = ^"%s^";", hash, is_autolog[id] == true ? "LOGGED" : "",  name)

  1101.                                         SQL_ThreadQuery(g_SQLTuple, "QuerySetData", namepass)

  1102.                                 }

  1103.                                 else

  1104.                                 {

  1105.                                         new line, file = fopen(reg_file, "r")

  1106.  

  1107.                                         while(!feof(file))

  1108.                                         {

  1109.                                                 fgets(file, namepass, 255)

  1110.                                                 line++

  1111.                                                 parse(namepass, namepass, charsmax(namepass))

  1112.  

  1113.                                                 if(equal(namepass, name))

  1114.                                                 {                                              

  1115.                                                         formatex(namepass, charsmax(namepass), "^"%s^" ^"%s^" ^"%s^"", name, hash, is_autolog[id] == true ? "LOGGED" : "")

  1116.                                                         write_file(reg_file, namepass, line - 1)                                                       

  1117.  

  1118.                                                         break

  1119.                                                 }

  1120.                                         }

  1121.                                         fclose(file)

  1122.                                 }

  1123.                                 get_pcvar_string(g_setinfo_pr, pass_prefix, charsmax(pass_prefix))

  1124.                                 client_cmd(id, "setinfo %s %s",pass_prefix, new_pass[id])

  1125.                                 client_printcolor(id, "%L", LANG_SERVER, "CHANGE_NEW", prefix, new_pass[id])

  1126.                                 password[id] = hash

  1127.                                 times[id]++

  1128.  

  1129.                                 if(get_pcvar_num(g_chp_log))

  1130.                                 {

  1131.                                         log_to_file(log_file, "%L", LANG_SERVER, "LOGFILE_CHNG_PASS", name)

  1132.                                 }

  1133.                         }

  1134.                         else

  1135.                         {

  1136.                                 if(get_pcvar_num(g_save))

  1137.                                 {

  1138.                                         formatex(namepass, charsmax(namepass), "INSERT INTO `registersystem` (`Name`, `Password`, `Status`) VALUES (^"%s^", ^"%s^", ^"^");", name, hash)

  1139.                                         SQL_ThreadQuery(g_SQLTuple, "QuerySetData", namepass)

  1140.                                 }

  1141.                                 else

  1142.                                 {

  1143.                                         new file = fopen(reg_file, "a")

  1144.                                         format(namepass, charsmax(namepass), "^n^"%s^" ^"%s^" ^"^"", name, hash)

  1145.                                         fprintf(file, namepass)

  1146.                                         fclose(file)

  1147.                                 }

  1148.                                 remove_task(id+TASK_KICK)

  1149.                                 params[1] = 2

  1150.                                 set_task(get_pcvar_float(g_logtime), "KickPlayer", id+TASK_KICK, params, sizeof params)

  1151.                                 client_printcolor(id, "%L", LANG_SERVER, "REG_REGIS", prefix, new_pass[id], get_pcvar_num(g_logtime))

  1152.                                 is_registered[id] = true

  1153.                                 password[id] = hash

  1154.                                 new_pass[id] = ""

  1155.  

  1156.                                 if(get_pcvar_num(g_reg_log))

  1157.                                 {

  1158.                                         log_to_file(log_file, "%L", LANG_SERVER, "LOGFILE_REG", name)

  1159.                                 }

  1160.                         }                      

  1161.                         Menu(id)

  1162.                 }

  1163.                 case 1:

  1164.                 {

  1165.                         if(is_registered[id])

  1166.                         {

  1167.                                 client_cmd(id, "messagemode CHANGE_PASS_NEW")

  1168.                         }

  1169.                         else

  1170.                         {

  1171.                                 client_cmd(id, "messagemode REGISTER_PASS")

  1172.                         }

  1173.                 }

  1174.                 case 9:

  1175.                 {

  1176.                         Menu(id)

  1177.                         return PLUGIN_HANDLED

  1178.                 }

  1179.         }

  1180.         return PLUGIN_HANDLED

  1181. }

  1182.  

  1183. public QuerySetData(FailState, Handle:Query, error[],errcode, data[], datasize)

  1184. {

  1185.         if(FailState == TQUERY_CONNECT_FAILED || FailState == TQUERY_QUERY_FAILED)

  1186.         {

  1187.                 log_amx("%s", error)

  1188.                 return

  1189.         }

  1190. }

  1191. /*==============================================================================

  1192.         End of Confirming Register's or Change Password's password function

  1193. ================================================================================*/

  1194.  

  1195. /*==============================================================================

  1196.         Start of Player PreThink function for the blind function

  1197. ================================================================================*/

  1198. public PlayerPreThink(id)

  1199. {

  1200.         if(!get_pcvar_num(g_on) || !get_pcvar_num(g_blind) || !is_user_connected(id))

  1201.                 return PLUGIN_HANDLED

  1202.  

  1203.         if((!is_registered[id] && get_pcvar_float(g_regtime)) || (is_registered[id] && !is_logged[id]))

  1204.         {

  1205.                 message_begin(MSG_ONE_UNRELIABLE, g_screenfade, {0,0,0}, id)

  1206.                 write_short(1<<12)

  1207.                 write_short(1<<12)

  1208.                 write_short(0x0000)

  1209.                 write_byte(0)

  1210.                 write_byte(0)

  1211.                 write_byte(0)

  1212.                 write_byte(255)

  1213.                 message_end()

  1214.         }

  1215.  

  1216.         return PLUGIN_CONTINUE

  1217. }

  1218. /*==============================================================================

  1219.         End of Player PreThink function for the blind function

  1220. ================================================================================*/

  1221.  

  1222. /*==============================================================================

  1223.         Start of Client Info Change function for hooking name change of clients

  1224. ================================================================================*/

  1225. public ClientInfoChanged(id)

  1226. {

  1227.         if(!get_pcvar_num(g_on) || !is_user_connected(id))

  1228.                 return FMRES_IGNORED

  1229.  

  1230.         new g_oldname[32], g_newname[32];

  1231.  

  1232.         pev(id, pev_netname, g_oldname, charsmax(g_oldname))

  1233.  

  1234.         if(g_oldname[0])

  1235.         {

  1236.                 get_user_info(id, "name", g_newname, charsmax(g_newname))

  1237.                 replace_all(g_newname, charsmax(g_newname), "%", " ")

  1238.  

  1239.                 if(!equal(g_oldname, g_newname))

  1240.                 {

  1241.  

  1242.                         switch(get_pcvar_num(g_name))

  1243.                         {

  1244.                                 case 0:

  1245.                                 {

  1246.                                         set_pev(id, pev_netname, g_newname)

  1247.                                         create_name_change_msg(id, g_oldname, g_newname)

  1248.                                         set_task(1.0, "CheckClient", id)

  1249.                                         return FMRES_HANDLED

  1250.                                 }

  1251.                                 case 1:

  1252.                                 {

  1253.                                         if(is_logged[id])

  1254.                                         {

  1255.                                                 set_user_info(id, "name", g_oldname)

  1256.                                                 client_printcolor(id, "%L", LANG_SERVER, "NAME_CHANGE_LOG", prefix)

  1257.                                                 return FMRES_HANDLED

  1258.                                         }

  1259.                                         else

  1260.                                         {

  1261.                                                 set_pev(id, pev_netname, g_newname)

  1262.                                                 create_name_change_msg(id, g_oldname, g_newname)

  1263.                                                 set_task(1.0, "CheckClient", id)

  1264.                                                 return FMRES_HANDLED

  1265.                                         }

  1266.                                 }

  1267.                                 case 2:

  1268.                                 {

  1269.                                         set_user_info(id, "name", g_oldname)

  1270.                                         client_printcolor(id, "%L", LANG_SERVER, "NAME_CHANGE_ALL", prefix)

  1271.                                         return FMRES_HANDLED

  1272.                                 }

  1273.                         }

  1274.                 }

  1275.         }

  1276.         return FMRES_IGNORED

  1277. }

  1278. /*==============================================================================

  1279.         End of Client Info Change function for hooking name change of clients

  1280. ================================================================================*/

  1281.  

  1282. /*==============================================================================

  1283.         Start of Kick Player function

  1284. ================================================================================*/

  1285. public KickPlayer(parameter[])

  1286. {

  1287.         new id = parameter[0]

  1288.         new reason = parameter[1]

  1289.  

  1290.         if(is_user_connected(id))

  1291.         {

  1292.                 new userid = get_user_userid(id)

  1293.  

  1294.                 switch(reason)

  1295.                 {

  1296.                         case 1:

  1297.                         {

  1298.                                 if(is_registered[id])

  1299.                                         return PLUGIN_HANDLED

  1300.  

  1301.                                 server_cmd("kick #%i ^"%L^"", userid, LANG_PLAYER, "KICK_REG")

  1302.                                 console_print(id, "%L", LANG_SERVER, "KICK_INFO")

  1303.                                 return PLUGIN_CONTINUE

  1304.                         }

  1305.                         case 2:

  1306.                         {

  1307.                                 if(is_logged[id])

  1308.                                         return PLUGIN_HANDLED

  1309.  

  1310.                                 server_cmd("kick #%i ^"%L^"", userid, LANG_PLAYER, "KICK_LOGIN")

  1311.                                 console_print(id, "%L", LANG_SERVER, "KICK_INFO")

  1312.                                 return PLUGIN_CONTINUE

  1313.                         }

  1314.                         case 3:

  1315.                         {

  1316.                                 server_cmd("kick #%i ^"%L^"", userid, LANG_PLAYER, "KICK_ATMP", get_pcvar_num(g_attempts))

  1317.                                 console_print(id, "%L", LANG_SERVER, "KICK_INFO")

  1318.                                 return PLUGIN_CONTINUE

  1319.                         }

  1320.                         case 4:

  1321.                         {

  1322.                                 server_cmd("kick #%i ^"%L^"", userid, LANG_SERVER, "KICK_LOGOUT")

  1323.                                 console_print(id, "%L", LANG_SERVER, "KICK_INFO")

  1324.                                 return PLUGIN_CONTINUE

  1325.                         }

  1326.                 }

  1327.         }

  1328.         return PLUGIN_CONTINUE

  1329. }

  1330. /*==============================================================================

  1331.         End of Kick Player function

  1332. ================================================================================*/

  1333.  

  1334. /*==============================================================================

  1335.         Start of Plugin's stocks

  1336. ================================================================================*/

  1337. stock create_name_change_msg(const id, const g_oldname[], const g_newname[])

  1338. {

  1339.         message_begin(MSG_BROADCAST, g_saytxt)

  1340.         write_byte(id)

  1341.         write_string(NAME_CHANGE_MSG)

  1342.         write_string(g_oldname)

  1343.         write_string(g_newname)

  1344.         message_end()

  1345. }

  1346.  

  1347. stock client_printcolor(const id, const input[], any:...)

  1348. {

  1349.         new count = 1, players[32];

  1350.         static msg[191];

  1351.         vformat(msg, 190, input, 3)

  1352.         replace_all(msg,190,"!g","^4")

  1353.         replace_all(msg,190,"!n","^1")

  1354.         replace_all(msg,190,"!t","^3")

  1355.         replace_all(msg,190,"!w","^0")

  1356.         if(id) players[0] = id

  1357.         else get_players(players , count , "ch")

  1358.         {

  1359.                 for(new i = 0; i < count; i++)

  1360.                 {

  1361.                         if(is_user_connected(players[i]))

  1362.                         {

  1363.                                 message_begin(MSG_ONE_UNRELIABLE, g_saytxt,_, players[i])

  1364.                                 write_byte(players[i])

  1365.                                 write_string(msg)

  1366.                                 message_end()

  1367.                         }

  1368.                 }

  1369.         }

  1370. }

  1371. /*==============================================================================

  1372.         End of Plugin's stocks

  1373. ================================================================================*/

  1374. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE

  1375. *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1038\\ f0\\ fs16 \n\\ par }

  1376. */
[/spoiler]

_________________
<<eb@>>Team Website - Közösség
17Buddies - Általam készített pályák.
GameBanana - Általam készített pályák/vágott hangok.

Kép
Kép


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Regisztrációs Rendszer - Menüvel
HozzászólásElküldve:2012.06.15. 18:07 
Offline
Őskövület
Avatar

Csatlakozott:2011.09.17. 17:54
Hozzászólások:2350
Megköszönt másnak: 40 alkalommal
Megköszönték neki: 57 alkalommal
Postolom a fájlt,mert nem tudom becopyzni,mert túl hosszú.
Csatolmány:
RegisterSystem.sma [56.87KiB]
Letöltve 28 alkalommal.


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Regisztrációs Rendszer - Menüvel
HozzászólásElküldve:2012.06.15. 20:29 
Offline
Developer
Avatar

Csatlakozott:2011.06.01. 21:11
Hozzászólások:7966
Megköszönt másnak: 295 alkalommal
Megköszönték neki: 537 alkalommal
VirTuaL ~` írta:
Postolom a fájlt,mert nem tudom becopyzni,mert túl hosszú.
Csatolmány:
RegisterSystem.sma



Kiszeded elején a sok kommentet máris elfér:)

_________________
http://www.easyrankup.eu


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 25 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