Advertisement
johnlol

IP Ban NPC v1.1

May 22nd, 2019
316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //===== rAthena Script =======================================
  2. //= IP Ban NPC
  3. //===== By ===================================================
  4. //= llchrisll
  5. //===== Version ==============================================
  6. //= 1.0 - Remake of a older version
  7. //      - Re-making the time calculation
  8. //= 1.1 - Script Optimization
  9. //===== Tested With =========================================
  10. //= rAthena SQL 07/16-2017 Revision
  11. //===== Description ==========================================
  12. //= Allows you the IP Ban someone.
  13. //===== Comments =============================================
  14. //= None...
  15. //============================================================
  16. sec_in02.gat,131,144,2  script  IP Ban  457,{
  17.    
  18. if(getgmlevel() < .gm_access) {
  19.     mes .n$;
  20.     mes "Sorry, but I can't help you.";
  21.     close;
  22.    
  23. }
  24.     set .@time$,gettimestr("%Y-%m/%d %H:%M:%S",21);
  25.     set .@day,gettimestr("%d",10);
  26.     set .@month,gettimestr("%m",10);
  27.     set .@year,gettimestr("%Y",10);
  28.     set .@day_calc,.@day + 7;
  29.     if(.@day_calc > 31 && (.@month == 1 || .@month == 3 || .@month == 5 || .@month == 7 || .@month == 8 || .@month == 10 || .@month == 12)) {
  30.         set .@day_calc,.@day_calc - 31;
  31.         if(.@month != 12)
  32.             set .@month,.@month + 1;
  33.         else if(.@month == 12)
  34.             set .@month,1;
  35.        
  36.     } else if(.@day_calc > .@day_feb && (.@month == 2))
  37.         set .@day_calc,.@day_calc - .@day_feb;
  38.        
  39.     else if(.@day_calc > 30 && (.@month == 4 || .@month == 6 || .@month == 9 || .@month == 11))
  40.         set .@day_calc,.@day_calc - 30;
  41.        
  42.     set .@month_calc,.@month + 1;
  43.    
  44.     if(.@month_calc > 12)
  45.         set .@month_calc,.@month_calc - 12; set .@year,.@year + 1;
  46.  
  47.     set .@year_calc1,.@year + 1;
  48.     set .@year_calc2,.@year + 2;
  49.     setarray .@ban_time$[0],gettimestr(""+.@year+"-"+.@month+"/"+.@day_calc+" %H:%M:%S",21),
  50.                            gettimestr(""+.@year+"-"+.@month_calc+"/"+.@day+" %H:%M:%S",21),
  51.                            gettimestr(""+.@year_calc1+"-"+.@month+"/"+.@day+" %H:%M:%S",21),
  52.                            gettimestr(""+.@year_calc2+"-"+.@month+"/"+.@day+" %H:%M:%S",21);
  53. if(getgmlevel() == 99) {
  54.     mes "Actual Time:";
  55.     mes .@time$;
  56.     mes " ";
  57.     mes "(Test Time for 1 Week:)";
  58.     mes .@ban_time$[0];
  59.     mes " ";
  60.     mes "(Test Time for 1 Month:)";
  61.     mes .@ban_time$[1];
  62.     mes " ";
  63.     mes "(Test Time for 1 Year:)";
  64.     mes .@ban_time$[2];
  65.     mes " ";
  66.     mes "(Test Time for 2 Years:)";
  67.     mes .@ban_time$[3];
  68.     next;
  69. }
  70. mes .n$;
  71. mes "Hello, "+strcharinfo(0)+"!";
  72. mes "I can make an IP Ban for you.";
  73. mes "As well, I can display the current IP Ban's and delete them.";
  74. mes "Valid duration's are:";
  75. mes "1 Week, 1 Month, 1 Year, 2 Year's";
  76. mes " ";
  77. mes "What do you like to do next?";
  78. next;
  79. switch(select("- Show IP List:- Add an Ban:- Delete an Ban")) {
  80.    
  81.     case 1:
  82.     mes .n$;
  83.     mes "I will list now the current IP Ban's in your Chat Box.";
  84.     query_sql "SELECT `list`  , `rtime` , `reason` FROM `ipbanlist` ORDER BY `list` DESC",.@list$,.@rtime$,.@reason$;
  85.     if(.@list$ == "") {
  86.         mes " ";
  87.         mes "There are no entrys in the IP Ban List.";
  88.         close;
  89.     }
  90.     dispbottom "IP  / Ban Expire  /  Reason";
  91.     for(set .@e,0; .@e < getarraysize(.@list$); set .@e,.@e + 1)
  92.         dispbottom .@list$[.@e]+" / "+.@rtime$[.@e]+" / "+.@reason$[.@e]+"";
  93.    
  94.     end;
  95.  
  96.     case 2:
  97.     mes .n$;
  98.     mes "Now type the Account Name or Account ID of the Account you want to ban and I will search the IP logged to it.";
  99.     next;
  100.     // ToDO: Use Character Name and look it up!!!
  101.     if(select("- Account Name:- Account ID") == 1) {
  102.         input .@acc_n$;
  103.         next;
  104.         mes .n$;
  105.         if(.@acc_n$ == "") {
  106.             mes "Invalid Name, try again.";
  107.             close;
  108.         }
  109.         mes "The inserted name is: "+.@acc_n$+".";
  110.         mes "Is that correct?";
  111.         if(select("- Yes:- No") - 1) close;
  112.         next;
  113.         query_sql "SELECT `userid` FROM `login` WHERE `userid` = '"+.@acc_n$+"'", @check_id$;
  114.         if(.@acc_n$ != @check_id$ || @check_id$ == "") { mes "Invalid Name, try again."; goto t_again;}
  115.  
  116.     } else {
  117.         input .@acc_id;
  118.         if(.@acc_id < 2000000) {
  119.             mes "Invalid Value, try again.";
  120.             close;
  121.         }
  122.         mes .n$;
  123.         mes "The inserted id is: "+.@acc_id+".";
  124.         mes "Is that correct?";
  125.         if(select("- Yes, it is.:- No, again please.") - 1) close;
  126.         next;
  127.         if(query_sql("SELECT `account_id` FROM `login` WHERE `account_id` = '"+.@acc_id+"'",.@check_aid) != 0) {
  128.             mes "Invalid Account ID, try again.";
  129.             close;
  130.         }
  131.         query_sql "SELECT `userid` FROM `login` WHERE `account_id` = '"+.@acc_id+"'",.@acc_n$;
  132.     }
  133.     next;
  134.     mes .n$;
  135.     mes "Alright, so how long do you want to ban him/her?";
  136.     next;
  137.     set .@rtime$,.@ban_time$[select("- 1 Week Ban:- 1 Month Ban:- 1 Year Ban:- 2 Year's Ban") - 1];
  138.     mes .n$;
  139.     mes "Now I need a reason, why do you want to ban that Account.";
  140.     mes "Note: Maximum 50 letters.";
  141.     next;
  142.     if(input(.@reason$,1,50) != 0) {
  143.         mes .n$;
  144.         mes "Invalid Reason, try again.";
  145.         close;
  146.     }
  147.     mes .n$;
  148.     mes "The Account \""+.@acc_n$+"\" will be banned until "+.@rtime$+" duo the reason \""+.@reason$+"\".";
  149.     if(select("- Correct:- Stop") - 1) close;
  150.     next;
  151.     mes .n$;
  152.     mes "Your IP Ban has been added.";
  153.     query_sql "SELECT `last_ip` FROM `login` WHERE `userid` = '"+.@acc_n$+"'",.@last_ip$;
  154.     query_sql "INSERT INTO `ipbanlist` ( `list` , `btime` , `rtime` , `reason`) VALUES ('"+.@last_ip$+"' ,'"+.@time$+"' , '"+.@rtime$+"' , '"+.@reason$+"')";
  155.     end;
  156.  
  157.     case 3:
  158.     mes .n$;
  159.     mes "Please choose, which one you want to delete:";
  160.     mes " ";
  161.     if(query_sql("SELECT `list`  , `rtime` , `reason` FROM `ipbanlist`", .@list$, .@rtime$, .@reason$) == 0) {
  162.         mes "There are no entrys in the IP Ban List.";
  163.         close;
  164.     }
  165.     for( set .@i,0; .@i < getarraysize(.@list$); set .@i,.@i + 1) {
  166.         mes "Banned IP Nr. ^FF0000"+(.@i+1)+"^000000";
  167.         mes .@list$[.@i];
  168.         mes "----Ban Expire:-----";
  169.         mes .@rtime$[.@i];
  170.         mes "-----Reason:------";
  171.         mes .@reason$[.@i];
  172.         mes "================";
  173.         set .@ban_menu$,.@ban_menu$ + "- "+ .@list$[.@i]+":";
  174.     }
  175.     set .@ban_menu$,.@ban_menu$ + "- Nothing";
  176.     if(select(.@ban_menu$) > getarraysize(.@list$))
  177.         break;
  178.        
  179.     next;
  180.     set .@ip,@menu - 1;
  181.    
  182.     mes .n$;
  183.     mes "You have choosen:";
  184.     mes " ";
  185.     mes "Banned IP Nr. ^FF0000"+(.@ip+1)+"^000000";
  186.     mes .@list$[.@ip];
  187.     mes "----Ban Expire:-----";
  188.     mes .@rtime$[.@ip];
  189.     mes "-----Reason:------";
  190.     mes .@reason$[.@ip];
  191.     mes "================";
  192.     mes " ";
  193.     mes "Wanna delete this Entry?";
  194.     if(select("- Yes, please:- No, don't") - 1) close;
  195.     next;
  196.     mes .n$;
  197.     mes "The IP Ban Entry has been deleted.";
  198.     query_sql "DELETE FROM `ipbanlist` WHERE `list` = '"+.@list$[.@ip]+"'";
  199.     close;
  200. }
  201. end;
  202.  
  203. OnInit:
  204. set .n$,"[Mike]";
  205. set .gm_access,60;
  206. set .day_feb,28;
  207. end;
  208. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement