Permalink
Cannot retrieve contributors at this time
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
434 lines (403 sloc)
14 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //===== rAthena Script ======================================= | |
| //= Virtual Security Password System | |
| //===== By =================================================== | |
| //= llchrisll | |
| //===== Version & Changelog ============================================== | |
| //= 1.0 - Initial Version | |
| //= Made some improvements (Function Changes,..) | |
| //= Added Password Recovery Feature | |
| //= 1.1 - Fixed a minor Bug about the Password Check | |
| // - My fix didn't work so I changed it into a "while()", let's see.. | |
| //= 1.2 - Optimized and Shortend, as well fixed that "Unknown NPC" after | |
| // pressing "Cancel"/"Try again please" to start over again, | |
| // which resulted in that error. | |
| //=1.2.1- Got an "npc_checknear" error on Login, so ... | |
| // - Modifications for Password Recovery Feature | |
| // - Added prevention to use "ALT+M" shortcuts and dying via | |
| // Attacks like Mob or PvP Maps after Login until the security password has been put | |
| //= 1.3 - Usage of 1 function now > VSP_FUNC | |
| // - Changed the Layout of the Function | |
| // - Changed the OnPCLoginEvent | |
| // - Removed the option choose the Password type | |
| // - Replaced prompt() with select() duo the Unknown PC by using "Cancel" | |
| // - Added an automatic kick "addtimer" after 1 minute | |
| // when the player didn't create/check the password successfully | |
| // - Added an IP Check | |
| // - Removed unnecessary comments | |
| //===== Tested With ========================================= | |
| //= rAthena SQL 07/16-2017 Revision | |
| //===== Description ========================================== | |
| //= This System allows you to put your 2nd Account | |
| // Password via a "Virtual Keyboard" in Menu Style | |
| // Possible Characters: | |
| // Letters (Array: .@m_letter$) | |
| // Numbers (Array: .@m_numbers$) | |
| // Specials (Array: .@m_specials$) > {,},(,) aren't possible? | |
| //======================= Comments =========================== | |
| //= None | |
| //============================================================ | |
| prontera,164,175,4 script VSP Manager 110,{ | |
| if(#vsp_pw$ == "") set #vsp_pw_set,0; // Bug Prevention o,o | |
| mes .n$; | |
| if(getgmlevel() >= 80) { | |
| if(#vsp_pw_set) { | |
| mes "Wanna see your VSP Details?"; | |
| if(select("- Nope:- Yes, please") - 1) { | |
| next; | |
| mes .n$; | |
| mes "Your Password is:"; | |
| mes #vsp_pw$; | |
| mes " "; | |
| mes "Security Answer:"; | |
| mes #sec_answer$; | |
| } | |
| next; | |
| mes .n$; | |
| } | |
| } | |
| if(!$vsp_sys) { | |
| mes "This System is currently offline."; | |
| close; | |
| } | |
| mes "Hello, "+strcharinfo(0)+"!"; | |
| mes "How can I help you?"; | |
| next; | |
| if(#vsp_pw_set) { | |
| switch(select("- Password Change:- Password Recovery:- Nothing, thanks.")) { | |
| case 1: | |
| mes .n$; | |
| mes "Are you sure that you want to change your password?!"; | |
| if(select("- Let's do it:- Better not") - 1) close; | |
| set .@vsp_old$,#vsp_pw$; | |
| while( .@temp_pw$ == "") | |
| set .@temp_pw$,""+callfunc("VSP_FUNC",1,2); | |
| next; | |
| mes .n$; | |
| mes "The password you have chosen is: " + .@temp_pw$; | |
| next; | |
| mes .n$; | |
| mes "Is that correct?"; | |
| if(select("- Yes:- No") - 1) close; | |
| next; | |
| mes .n$; | |
| if(.@temp_pw$ != .@vsp_old$) { | |
| mes "Before I can change your password I need the old one for your own security."; | |
| while( .@pw_change$ == "") | |
| set .@pw_change$,""+callfunc("VSP_FUNC",1,1); | |
| next; | |
| mes .n$; | |
| if(.@pw_change$ == .@vsp_old$) { | |
| mes "Okay, your old password has been confirmed."; | |
| mes "Your new Password will be used now."; | |
| set #vsp_pw$,.@temp_pw$; | |
| } else { | |
| mes "Wrong Password."; | |
| mes "The old one will be re-used."; | |
| set #vsp_pw$,.@vsp_old$; | |
| } | |
| set #vsp_pw_set,1; | |
| } else | |
| mes "I'm sorry, but you have chosen the same password again."; | |
| break; | |
| case 2: | |
| mes .n$; | |
| if(#sec_que > 0) { | |
| mes "What do you want to do?"; | |
| next; | |
| if(select("- Retrieve my old Password:- Change Security Question/Answer") == 1) | |
| callfunc("VSP_FUNC",2,1); | |
| else { | |
| mes .n$; | |
| mes "First, I'll have to check your Password."; | |
| while( .@temp_pw$ == "") | |
| set .@temp_pw$,""+callfunc("VSP_FUNC",1,1); | |
| next; | |
| // ======= Finish of the Password Check ========= | |
| if(.@temp_pw$ == #vsp_pw$) { | |
| mes .n$; | |
| mes "Thank you for confirming your identity."; | |
| } else { | |
| mes .n$; | |
| mes "The 'clicked' Password isn't valid."; | |
| close; | |
| } | |
| set #sec_que,0; | |
| while( !#sec_que ) | |
| callfunc("VSP_FUNC",2,2); | |
| next; | |
| mes .n$; | |
| mes "You Security Question has been changed successfully."; | |
| } | |
| } else { | |
| mes "You'll have to put an Security Question and Answer first before you can recover your password."; | |
| while( !#sec_que ) | |
| callfunc("VSP_FUNC",2,2); | |
| next; | |
| mes .n$; | |
| mes "You Security Question has been set successfully."; | |
| } | |
| break; | |
| case 3: | |
| break; | |
| } | |
| } else if(!#vsp_pw_set) { | |
| while( .@temp_pw$ == "" ) | |
| set .@temp_pw$,""+callfunc("VSP_FUNC",1,2); | |
| next; | |
| //========== Confirming Password ================= | |
| mes .n$; | |
| mes "The password you have chosen is: \""+.@temp_pw$+"\""; | |
| set #vsp_pw$,.@temp_pw$; | |
| set #vsp_pw_set,1; | |
| while( !#sec_que ) | |
| callfunc("VSP_FUNC",2,2); | |
| next; | |
| mes .n$; | |
| mes "Your password and Security Question has been set successfully."; | |
| } | |
| end; | |
| OnInit: | |
| set .n$,"[VSP Manager]"; | |
| // System Status: | |
| // 1 = Online | |
| // 0 = Offline | |
| set $vsp_sys,1; | |
| end; | |
| } | |
| //?=============================* START of VSP Login Checks *============================?// | |
| - script VSPLogin -1,{ | |
| OnPCLoginEvent: | |
| //=================== System On? ==================== | |
| if(!$vsp_sys && !#vsp_pw_set) | |
| end; | |
| //======== System temporarily down and Variable Set ======== | |
| else if(!$vsp_sys && #vsp_pw_set == 1) { | |
| announce "The VSP System is offline for the moment.",bc_self; | |
| set #vsp_pw_set,2; | |
| end; | |
| //======== System back online and Variable Set ======== | |
| } else if($vsp_sys && #vsp_pw_set == 2) { | |
| announce "The VSP System is back online.",bc_self; | |
| set #vsp_pw_set,1; | |
| end; | |
| } | |
| set .@n$,getvariableofnpc(.n$,"VSP Manager"); | |
| sc_start 112,999999,1; //Berserk State, not able to talk/using commands | |
| pcblockmove getcharid(3),1; // Preventing from moving | |
| atcommand "@battleignore"; // Preventing the player from dying from attacks | |
| //============ Password has been set ============ | |
| if(#vsp_pw_set) { | |
| query_sql "SELECT `last_ip` FROM `login` WHERE `account_id` = '"+getcharid(3)+"'",.@l_ip$; | |
| if(.@l_ip$ != #vsp_lastip$) { | |
| mes .@n$; | |
| mes "Hello, player."; | |
| mes "Before you are able to play on the Server I must confirm your password."; | |
| while( .@temp_pw$ == "") | |
| set .@temp_pw$,""+callfunc("VSP_FUNC",1,1); | |
| next; | |
| mes .@n$; | |
| if(.@temp_pw$ != #vsp_pw$) { | |
| mes "The 'clicked' Password isn't valid."; | |
| mes "You will now be kicked."; | |
| sleep2 2000; | |
| atcommand "@kick "+strcharinfo(0); | |
| end; | |
| } | |
| set #vsp_lastip$,.@l_ip$; | |
| } | |
| //======== Password Creation ======== | |
| } else if(!#vsp_pw_set) { | |
| mes .@n$; | |
| mes "Hello, "+strcharinfo(0)+"."; | |
| mes "For your own safety, I would like to ask you to set an second password for your account."; | |
| mes "If you don't follow these steps, you will be kicked."; | |
| next; | |
| mes .@n$; | |
| mes "This System has the feature to type your password via an 'Virtual Keyboard'."; | |
| while( .@temp_pw$ == "" ) | |
| set .@temp_pw$,""+callfunc("VSP_FUNC",1,2); | |
| next; | |
| //========== Confirming Password ================= | |
| mes .@n$; | |
| mes "The password you have chosen is: \""+.@temp_pw$+"\""; | |
| set #vsp_pw$,.@temp_pw$; | |
| set #vsp_pw_set,1; | |
| while( !#sec_que ) | |
| callfunc("VSP_FUNC",2,2); | |
| next; | |
| mes .@n$; | |
| mes "Your password and Security Question has been set successfully."; | |
| query_sql "SELECT `last_ip` FROM `login` WHERE `account_id` = '"+getcharid(3)+"'",#vsp_lastip$; | |
| } | |
| mes "Thank you for confirming your identity."; | |
| sc_end 112; | |
| pcblockmove getcharid(3),0; | |
| atcommand "@battleignore"; | |
| percentheal 100,100; | |
| end; | |
| OnTimer60000: | |
| message strcharinfo(0),"[VSP Manager]: Because you did take too long for the password creation/check, I will kick you now."; | |
| sleep2 2000; | |
| atcommand "@kick "+strcharinfo(0); | |
| end; | |
| } | |
| //?===================================* VPS Function *===================================?// | |
| // getarg(0): | |
| // 1 = Password | |
| // 2 = Security Question/Answer | |
| // getarg(1): | |
| // 1 = Check | |
| // 2 = Create | |
| //?======================================================================================?// | |
| function script VSP_FUNC { | |
| set .@n$,getvariableofnpc(.n$,"VSP Manager"); | |
| next; | |
| mes .@n$; | |
| if(getarg(0) == 1) { | |
| // Automatic Kick after 1 Minute if Password Check/Creation was not done by that time | |
| attachnpctimer; | |
| initnpctimer "VSPLogin"; | |
| setarray .@m_letter$[0],"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"; | |
| setarray .@m_numbers$[0],"0","1","2","3","4","5","6","7","8","9"; | |
| setarray .@m_specials$[0],"`","´","'","§","%","&","[","]","!","=","?"; | |
| set .@pw_max_len,10; // Maximum Length of an Password | |
| if(getarg(1) == 1) { | |
| mes "In case you forgot your password:"; | |
| mes "Type \"FFFF\"/\"ffff\" or \"1111\", for the rest anything."; | |
| next; | |
| } else if(getarg(1) == 2) { | |
| mes "Now tell me the lenght of your password."; | |
| mes "But the max lenght is "+.@pw_max_len+" characters."; | |
| if(input(#pw_lenght,0,.@pw_max_len) != 0) return; | |
| next; | |
| mes .@n$; | |
| mes "So your password is "+#pw_lenght+" characters long?"; | |
| next; | |
| } | |
| mes .@n$; | |
| mes "Now click on the characters you want shown below here."; | |
| mes "Note: You have 1 minute to do this, or you will be kicked!"; | |
| // =========== Menu Creation ===== | |
| set .@pw_counter,0; | |
| set .@m_choice,1; | |
| for(set .@p,0; .@p < getarraysize(.@m_letter$); set .@p,.@p + 1) | |
| set .@menu_pw$,.@menu_pw$ + "- "+.@m_letter$[.@p]+ ( (.@m_letter$[.@p+1] == "")?"":":"); | |
| while(.@pw_counter != #pw_lenght) { | |
| // ======== Setting Menu Display Options ======== | |
| if(.@m_choice == 1) { | |
| set .@m_option$,":- Number's:- Special's"; | |
| set .@sel_m,getarraysize(.@m_letter$); | |
| } else if(.@m_choice == 2) { | |
| set .@m_option$,":- Letter's:- Special's"; | |
| set .@sel_m,getarraysize(.@m_numbers$); | |
| } else if(.@m_choice == 3) { | |
| set .@m_option$,":- Letter's:- Number's"; | |
| set .@sel_m,getarraysize(.@m_specials$); | |
| } | |
| set .@menu$, .@menu_pw$ + .@m_option$ + ":- Try again please"; | |
| // ======= Menu Display + Choosing ====== | |
| set .@vsp_m,select(.@menu$); | |
| // ======================== "Cancel" Button or "Try again please" - Option ======== | |
| if(.@vsp_m > (.@sel_m + 2)) | |
| return ""; | |
| else if(.@vsp_m <= .@sel_m) { | |
| set .@pw_c,.@vsp_m-1; | |
| if(.@m_choice == 1) | |
| set .@temp_pw$,.@temp_pw$ + .@m_letter$[.@pw_c]; | |
| else if(.@m_choice == 2) | |
| set .@temp_pw$,.@temp_pw$ + .@m_numbers$[.@pw_c]; | |
| else if(.@m_choice == 3) | |
| set .@temp_pw$,.@temp_pw$ + .@m_specials$[.@pw_c]; | |
| set .@pw_counter,.@pw_counter + 1; | |
| } else if(.@vsp_m > .@sel_m && (.@vsp_m < (.@sel_m + 3))) { | |
| // ======== Setting new Character menu after choosing the corresponding menu option ======== | |
| set .@menu_pw$,""; | |
| if(.@m_choice == 1) { | |
| if(.@vsp_m == (.@sel_m + 1)) { | |
| for(set .@p,0; .@p < getarraysize(.@m_numbers$); set .@p,.@p + 1) | |
| set .@menu_pw$, .@menu_pw$ + "- "+.@m_numbers$[.@p] + ( (.@m_numbers$[.@p+1] == "")?"":":"); | |
| set .@m_choice,2; | |
| } else if(.@vsp_m == (.@sel_m + 2)) { | |
| for(set .@p,0; .@p < getarraysize(.@m_specials$); set .@p,.@p + 1) | |
| set .@menu_pw$, .@menu_pw$ + "- "+.@m_specials$[.@p] + ( (.@m_specials$[.@p+1] == "")?"":":"); | |
| set .@m_choice,3; | |
| } | |
| } else if(.@m_choice == 2) { | |
| if(.@vsp_m == (.@sel_m + 1)) { | |
| for(set .@p,0; .@p < getarraysize(.@m_letter$); set .@p,.@p + 1) | |
| set .@menu_pw$, .@menu_pw$ + "- "+.@m_letter$[.@p] + ( (.@m_letter$[.@p+1] == "")?"":":"); | |
| set .@m_choice,1; | |
| } else if(.@vsp_m == (.@sel_m + 2)) { | |
| for(set .@p,0; .@p < getarraysize(.@m_specials$); set .@p,.@p + 1) | |
| set .@menu_pw$, .@menu_pw$ + "- "+.@m_specials$[.@p] + ( (.@m_specials$[.@p+1] == "")?"":":"); | |
| set .@m_choice,3; | |
| } | |
| } else if(.@m_choice == 3) { | |
| if(.@vsp_m == (.@sel_m + 1)) { | |
| for(set .@p,0; .@p < getarraysize(.@m_letter$); set .@p,.@p + 1) | |
| set .@menu_pw$, .@menu_pw$ + "- "+.@m_letter$[.@p] + ( (.@m_letter$[.@p+1] == "")?"":":"); | |
| set .@m_choice,1; | |
| } else if(.@vsp_m == (.@sel_m + 2)) { | |
| for(set .@p,0; .@p < getarraysize(.@m_numbers$); set .@p,.@p + 1) | |
| set .@menu_pw$, .@menu_pw$ + "- "+.@m_numbers$[.@p] + ( (.@m_numbers$[.@p+1] == "")?"":":"); | |
| set .@m_choice,2; | |
| } | |
| } | |
| } | |
| // ======= Finish of the Password Input ========= | |
| } | |
| if(getarg(1) == 2 && (compare(.@temp_pw$,"FFFF") == 1 || compare(.@temp_pw$,"ffff") == 1 || compare(.@temp_pw$,"1111") == 1) ) { | |
| mes .@n$; | |
| mes "I'm sorry, but this password can't be used, since it holds keywords for the \"Password Forgot\" option."; | |
| mes "Please choose something different."; | |
| return ""; | |
| } else if(getarg(1) == 1 && (compare(.@temp_pw$,"FFFF") == 1 || compare(.@temp_pw$,"ffff") == 1 || compare(.@temp_pw$,"1111") == 1) ) { | |
| callfunc("VSP_FUNC",2,1); | |
| return ""; | |
| } | |
| stopnpctimer "VSPLogin"; | |
| return .@temp_pw$; | |
| // ====== Security Question/Answer ========= // | |
| } else if(getarg(0) == 2) { | |
| setarray .@s_quest$[1],"Birthplace","Mother's Maiden Name","First Pet's Name"; | |
| if(getarg(1) == 1) { // Check | |
| mes "I would like to ask you to tell me your Security Answer you put."; | |
| if(!#sec_que) { | |
| mes " "; | |
| mes "Hmm.. it seems you didn't set it yet."; | |
| end; | |
| } | |
| next; | |
| mes .@n$; | |
| mes "What is/was your "+.@s_quest$[#sec_que]+"?"; | |
| next; | |
| input .@s_ans$; | |
| mes .@n$; | |
| if(.@s_ans$ == #sec_answer$) { | |
| mes "The answer is correct."; | |
| mes "Your password is:"; | |
| mes #vsp_pw$; | |
| return; | |
| } | |
| } else if(getarg(1) == 2) { // Create | |
| mes "Now I would like you choose a question below and type the answer next:"; | |
| for( set .@s,1; .@s < getarraysize(.@s_quest$); set .@s,.@s + 1) | |
| set .@s_menu$,.@s_menu$ + "- " + .@s_quest$[.@s] + ( (.@s_quest$[.@s+1] == "")?"":":"); | |
| if(prompt(.@s_menu$) == 255) return; | |
| next; | |
| input .@s_ans$; | |
| mes .@n$; | |
| mes "Question:"; | |
| mes .@s_quest$[@menu]; | |
| mes "Answer:"; | |
| mes .@s_ans$; | |
| mes " "; | |
| mes "Is that correct?"; | |
| if(select("- Yes:- No") - 1) return; | |
| set #sec_answer$,.@s_ans$; | |
| set #sec_que,@menu; | |
| return; | |
| } | |
| return; | |
| } | |
| } |