Jump to content
  • 0

Server Maintenance


Valcars

Question


  • Group:  Members
  • Topic Count:  24
  • Topics Per Day:  0.01
  • Content Count:  60
  • Reputation:   0
  • Joined:  01/03/16
  • Last Seen:  

Hello everyone, I created this script for server maintenance, you can explain to me how I could improve it? The script works, but I wanted your advice.
In practice, when the server is undergoing maintenance, only the gm can access it.
Here's the script:

 

 

Server_Maintenance.txt

prontera,150,150,4	script	Server Maintenance	73,{
	
	/***********************************/
	/**/.npc$ = "[Server Maintenance]";
	/**/.gm = 99; //Level GM
	/**/.user$ = "root"; //root
	/**/.password = 12345; //Password
	/**********************************/

	
	if(getgmlevel() >= .gm){ 
	
		mes .npc$;
		mes "Hello"+ strcharinfo(0) +".";
		mes "Please enter the username:";
		next;
		input .@usr$;
		if(.@usr$ == .user$){
			mes "Please enter password";
			next;
			input .@psw;
			if(.@psw == .password){
				
				mes .npc$;
				mes "Do you want to activate the server in maintenance mode?";
				switch(select("Yes:No:Reset Server")){
					case 1: 
						initnpctimer;
						mes "Server in maintenance mode ^00ff7fenabled^000000";
						announce "The server will be temporarily closed for maintenance -- from 5 minutes",bc_all|bc_npc;
						close;
						break;
						
						
						
					OnTimer60000: // 1min.
						announce "The server will be temporarily closed for maintenance -- from 4 minutes",bc_all|bc_npc;
						end;
						
						
					OnTimer120000: // 2min.
						announce "The server will be temporarily closed for maintenance -- from 3 minutes",bc_all|bc_npc;
						end;
						
					OnTimer180000: // 3min.
						announce "The server will be temporarily closed for maintenance -- from 2 minutes",bc_all|bc_npc;
						end;
						
					OnTimer240000: // 4min.
						announce "The server will be temporarily closed for maintenance -- from 1 minutes",bc_all|bc_npc;
						end;
						
						
					OnTimer330000:
						announce "-- Server Shutdown in 30 seconds --",bc_all|bc_npc;
						end;

					OnTimer430000:
						announce "-- Server Shutdown in 20 seconds --",bc_all|bc_npc;
						end;

					OnTimer540000:
						announce "-- Server Shutdown in 10 seconds --",bc_all|bc_npc;
						end;

					OnTimer655000:
						announce "-- We will be back soon. Bye bye --",bc_all|bc_npc;
						set $srv_mnt$,"ON";
						stopnpctimer;
						sleep2 5000;
						atcommand "@kickall";
						end;
						

	
						
						
						
					case 2:
						mes .npc$;
						mes "Bye";
						close;
					case 3:
						set $srv_mnt$,"OFF";
						mes "Reset";
						close;
				}
			}
		}
		
	}
	
	
	mes .npc$;
	mes "Sorry but you don't have a permission";
	close;
	
	
	
}

 

 

OnPc_srv.txt

-	script	ServerMaintenance	-1,{
	OnPCLoginEvent:
		
		if($srv_mnt$ == "ON"){
			
			if(getgmlevel() >= 99){
				mes "Hello "+ strcharinfo(0) +".";
				mes "The server is "+ $srv_mnt$ +" mode";
				close;
				
			}
			
			mes "[^55aaffLeoRO Server^000000]";
			mes "Sorry but the server is temporarily out of service,";
			mes "for maintenance.";
			mes "Please try again later!";
			
			next;
			atcommand "@kick " + strcharinfo(0);
			end;
			
		}
		else if($srv_mnt$ == "OFF"){
			
			
			end;
		}
		else if($srv_mnt$ == "DEFAULT"){
			
			end;
		}
		end;
		
}
Edited by Valcars
Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  40
  • Topics Per Day:  0.02
  • Content Count:  242
  • Reputation:   37
  • Joined:  02/25/18
  • Last Seen:  

...do not work! The npc is mute!!!

 

EDIT: I entered the password with quotes " " and now it works... but how can I stop the countdown?

Edited by CyberDevil
Link to comment
Share on other sites

  • 0

  • Group:  Forum Moderator
  • Topic Count:  33
  • Topics Per Day:  0.01
  • Content Count:  1268
  • Reputation:   382
  • Joined:  02/03/12
  • Last Seen:  

On 3/23/2016 at 5:40 PM, Valcars said:

Hello everyone, I created this script for server maintenance, you can explain to me how I could improve it? The script works, but I wanted your advice.
In practice, when the server is undergoing maintenance, only the gm can access it.
Here's the script:

Most of it looks good to me I changed the way some things were formatted but honestly that's probably just my preference.

Other than that when you have next; in the message you sent to the player about the server being in maintenance mode actually allows them to bypass the @kick command by having @go or something mapped to and alt+[1-0] key. I've found plenty of scripts with this flaw. I believe sleep2 will persist even if they warp. If that doesn't work use addtimer <ticks>,"NPC::OnLabel";

prontera,150,150,4	script	Server Maintenance	73,{
	
	/***********************************/
	/**/.npc$ = "[Server Maintenance]";
	/**/.gm = 99; //Level GM
	/**/.user$ = "root"; //root
	/**/.password = 12345; //Password
	/**********************************/

	
	mes .npc$;
	if(getgmlevel() >= .gm) {
		mes "Hello"+ strcharinfo(0) +".";
		mes "Please enter the username:";
		next;
		input .@usr$;
		mes .npc$;
		mes "Please enter password";
		next;
		input .@psw;
		mes .npc$;
		if( .@usr$ == .user$ && .@psw == .password ) {
			mes "Do you want to activate the server in maintenance mode?";
			next;
			switch(select("Yes:No:Reset Server")) {
				mes .npc$;
				case 1: 
					initnpctimer;
					mes "Server in maintenance mode ^00ff7fenabled^000000";
					announce "The server will be temporarily closed for maintenance -- from 5 minutes",bc_all|bc_npc;
					break;
			
				case 2:
					mes "Bye";
					break;

				case 3:
					set $srv_mnt$,"OFF";
					mes "Reset";
					break;
			}
		} else
			mes "There was a problem with your login information!";
			
	} else
		mes "Sorry but you don't have a permission";
		
	close;
	
	OnTimer60000: // 1min.
		announce "The server will be temporarily closed for maintenance -- from 4 minutes",bc_all|bc_npc;
		end;
		
		
	OnTimer120000: // 2min.
		announce "The server will be temporarily closed for maintenance -- from 3 minutes",bc_all|bc_npc;
		end;
		
	OnTimer180000: // 3min.
		announce "The server will be temporarily closed for maintenance -- from 2 minutes",bc_all|bc_npc;
		end;
		
	OnTimer240000: // 4min.
		announce "The server will be temporarily closed for maintenance -- from 1 minutes",bc_all|bc_npc;
		end;
		
	OnTimer330000:
		announce "-- Server Shutdown in 30 seconds --",bc_all|bc_npc;
		end;

	OnTimer430000:
		announce "-- Server Shutdown in 20 seconds --",bc_all|bc_npc;
		end;

	OnTimer540000:
		announce "-- Server Shutdown in 10 seconds --",bc_all|bc_npc;
		end;

	OnTimer655000:
		announce "-- We will be back soon. Bye bye --",bc_all|bc_npc;
		set $srv_mnt$,"ON";
		stopnpctimer;
		sleep2 5000;
		atcommand "@kickall";
		end;
}

-	script	ServerMaintenance	-1,{
	OnPCLoginEvent:
		
		if($srv_mnt$ == "ON") {
			
			if(getgmlevel() >= 99) {
				mes "Hello "+ strcharinfo(0) +".";
				mes "The server is "+ $srv_mnt$ +" mode";
				close;
				
			}
			
			mes "[^55aaffLeoRO Server^000000]";
			mes "Sorry but the server is temporarily out of service,";
			mes "for maintenance.";
			mes "Please try again later!";
			
			sleep2(5000);
			atcommand "@kick " + strcharinfo(0);
		}
		end;
}

You can look through what I've changed and maybe someone else has some ideas. In terms of improvements to the overall script. You could add multiple logins or something.

  • Love 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

hmm ... I believe this kind of stuff should be done with source edits ....

this is my plugin -> http://herc.ws/board/topic/7127-maintenance-mode/

and napster converted into rathena -> .... wait where is the topic gone ? ... oh wait I seriously thought he already converted into rathena

if anyone still interested into converting, the 1.3 patch can still be found in my hercules topic, the patch is still there ( I did the patch just for him ... )

the reason why do source edit is, once the client start, input username and password, will immediately get kick, didn't even get into character selection

 

so hmm ... you guys are interested in making it into script version too ... let's see ...

http://upaste.me/45e349607e335125c

I don't think there's a way to stop the countdown once it started ...

  • Upvote 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...