Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //===== rAthena Script =======================================
- //= IP Ban NPC
- //===== By ===================================================
- //= llchrisll
- //===== Version ==============================================
- //= 1.0 - Remake of a older version
- // - Re-making the time calculation
- //= 1.1 - Script Optimization
- //===== Tested With =========================================
- //= rAthena SQL 07/16-2017 Revision
- //===== Description ==========================================
- //= Allows you the IP Ban someone.
- //===== Comments =============================================
- //= None...
- //============================================================
- sec_in02.gat,131,144,2 script IP Ban 457,{
- if(getgmlevel() < .gm_access) {
- mes .n$;
- mes "Sorry, but I can't help you.";
- close;
- }
- set .@time$,gettimestr("%Y-%m/%d %H:%M:%S",21);
- set .@day,gettimestr("%d",10);
- set .@month,gettimestr("%m",10);
- set .@year,gettimestr("%Y",10);
- set .@day_calc,.@day + 7;
- if(.@day_calc > 31 && (.@month == 1 || .@month == 3 || .@month == 5 || .@month == 7 || .@month == 8 || .@month == 10 || .@month == 12)) {
- set .@day_calc,.@day_calc - 31;
- if(.@month != 12)
- set .@month,.@month + 1;
- else if(.@month == 12)
- set .@month,1;
- } else if(.@day_calc > .@day_feb && (.@month == 2))
- set .@day_calc,.@day_calc - .@day_feb;
- else if(.@day_calc > 30 && (.@month == 4 || .@month == 6 || .@month == 9 || .@month == 11))
- set .@day_calc,.@day_calc - 30;
- set .@month_calc,.@month + 1;
- if(.@month_calc > 12)
- set .@month_calc,.@month_calc - 12; set .@year,.@year + 1;
- set .@year_calc1,.@year + 1;
- set .@year_calc2,.@year + 2;
- setarray .@ban_time$[0],gettimestr(""+.@year+"-"+.@month+"/"+.@day_calc+" %H:%M:%S",21),
- gettimestr(""+.@year+"-"+.@month_calc+"/"+.@day+" %H:%M:%S",21),
- gettimestr(""+.@year_calc1+"-"+.@month+"/"+.@day+" %H:%M:%S",21),
- gettimestr(""+.@year_calc2+"-"+.@month+"/"+.@day+" %H:%M:%S",21);
- if(getgmlevel() == 99) {
- mes "Actual Time:";
- mes .@time$;
- mes " ";
- mes "(Test Time for 1 Week:)";
- mes .@ban_time$[0];
- mes " ";
- mes "(Test Time for 1 Month:)";
- mes .@ban_time$[1];
- mes " ";
- mes "(Test Time for 1 Year:)";
- mes .@ban_time$[2];
- mes " ";
- mes "(Test Time for 2 Years:)";
- mes .@ban_time$[3];
- next;
- }
- mes .n$;
- mes "Hello, "+strcharinfo(0)+"!";
- mes "I can make an IP Ban for you.";
- mes "As well, I can display the current IP Ban's and delete them.";
- mes "Valid duration's are:";
- mes "1 Week, 1 Month, 1 Year, 2 Year's";
- mes " ";
- mes "What do you like to do next?";
- next;
- switch(select("- Show IP List:- Add an Ban:- Delete an Ban")) {
- case 1:
- mes .n$;
- mes "I will list now the current IP Ban's in your Chat Box.";
- query_sql "SELECT `list` , `rtime` , `reason` FROM `ipbanlist` ORDER BY `list` DESC",.@list$,.@rtime$,.@reason$;
- if(.@list$ == "") {
- mes " ";
- mes "There are no entrys in the IP Ban List.";
- close;
- }
- dispbottom "IP / Ban Expire / Reason";
- for(set .@e,0; .@e < getarraysize(.@list$); set .@e,.@e + 1)
- dispbottom .@list$[.@e]+" / "+.@rtime$[.@e]+" / "+.@reason$[.@e]+"";
- end;
- case 2:
- mes .n$;
- 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.";
- next;
- // ToDO: Use Character Name and look it up!!!
- if(select("- Account Name:- Account ID") == 1) {
- input .@acc_n$;
- next;
- mes .n$;
- if(.@acc_n$ == "") {
- mes "Invalid Name, try again.";
- close;
- }
- mes "The inserted name is: "+.@acc_n$+".";
- mes "Is that correct?";
- if(select("- Yes:- No") - 1) close;
- next;
- query_sql "SELECT `userid` FROM `login` WHERE `userid` = '"+.@acc_n$+"'", @check_id$;
- if(.@acc_n$ != @check_id$ || @check_id$ == "") { mes "Invalid Name, try again."; goto t_again;}
- } else {
- input .@acc_id;
- if(.@acc_id < 2000000) {
- mes "Invalid Value, try again.";
- close;
- }
- mes .n$;
- mes "The inserted id is: "+.@acc_id+".";
- mes "Is that correct?";
- if(select("- Yes, it is.:- No, again please.") - 1) close;
- next;
- if(query_sql("SELECT `account_id` FROM `login` WHERE `account_id` = '"+.@acc_id+"'",.@check_aid) != 0) {
- mes "Invalid Account ID, try again.";
- close;
- }
- query_sql "SELECT `userid` FROM `login` WHERE `account_id` = '"+.@acc_id+"'",.@acc_n$;
- }
- next;
- mes .n$;
- mes "Alright, so how long do you want to ban him/her?";
- next;
- set .@rtime$,.@ban_time$[select("- 1 Week Ban:- 1 Month Ban:- 1 Year Ban:- 2 Year's Ban") - 1];
- mes .n$;
- mes "Now I need a reason, why do you want to ban that Account.";
- mes "Note: Maximum 50 letters.";
- next;
- if(input(.@reason$,1,50) != 0) {
- mes .n$;
- mes "Invalid Reason, try again.";
- close;
- }
- mes .n$;
- mes "The Account \""+.@acc_n$+"\" will be banned until "+.@rtime$+" duo the reason \""+.@reason$+"\".";
- if(select("- Correct:- Stop") - 1) close;
- next;
- mes .n$;
- mes "Your IP Ban has been added.";
- query_sql "SELECT `last_ip` FROM `login` WHERE `userid` = '"+.@acc_n$+"'",.@last_ip$;
- query_sql "INSERT INTO `ipbanlist` ( `list` , `btime` , `rtime` , `reason`) VALUES ('"+.@last_ip$+"' ,'"+.@time$+"' , '"+.@rtime$+"' , '"+.@reason$+"')";
- end;
- case 3:
- mes .n$;
- mes "Please choose, which one you want to delete:";
- mes " ";
- if(query_sql("SELECT `list` , `rtime` , `reason` FROM `ipbanlist`", .@list$, .@rtime$, .@reason$) == 0) {
- mes "There are no entrys in the IP Ban List.";
- close;
- }
- for( set .@i,0; .@i < getarraysize(.@list$); set .@i,.@i + 1) {
- mes "Banned IP Nr. ^FF0000"+(.@i+1)+"^000000";
- mes .@list$[.@i];
- mes "----Ban Expire:-----";
- mes .@rtime$[.@i];
- mes "-----Reason:------";
- mes .@reason$[.@i];
- mes "================";
- set .@ban_menu$,.@ban_menu$ + "- "+ .@list$[.@i]+":";
- }
- set .@ban_menu$,.@ban_menu$ + "- Nothing";
- if(select(.@ban_menu$) > getarraysize(.@list$))
- break;
- next;
- set .@ip,@menu - 1;
- mes .n$;
- mes "You have choosen:";
- mes " ";
- mes "Banned IP Nr. ^FF0000"+(.@ip+1)+"^000000";
- mes .@list$[.@ip];
- mes "----Ban Expire:-----";
- mes .@rtime$[.@ip];
- mes "-----Reason:------";
- mes .@reason$[.@ip];
- mes "================";
- mes " ";
- mes "Wanna delete this Entry?";
- if(select("- Yes, please:- No, don't") - 1) close;
- next;
- mes .n$;
- mes "The IP Ban Entry has been deleted.";
- query_sql "DELETE FROM `ipbanlist` WHERE `list` = '"+.@list$[.@ip]+"'";
- close;
- }
- end;
- OnInit:
- set .n$,"[Mike]";
- set .gm_access,60;
- set .day_feb,28;
- end;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement