Jump to content
Sign in to follow this  
raptor2x

Restart the server at the end of a countdown

Recommended Posts

Hello,

With the help of other existing post on the forum, I created a countdown in the init.sqf file of my mission.

It's working good, but I would like to do something when the countdown reach 0.

In fact, I would like to restart the server. Not the mission, the server (it's going to be on my dedicated server).

How can I do that ?


      if(_time < 1) then
      {  
      DO SOMETHING TO RESTART THE SERVER HERE
      };				

Thanks !

Share this post


Link to post
Share on other sites

try something like this :D

endmission "END1";

Kind Regards,

Rawner135

NOTE: When the mission ends, the server should restart the mission, as all of them RESTART if the mission ends.

Share this post


Link to post
Share on other sites

The above will just end the mission, not restart the server. I think the command you are looking for is serverCommand. Combined with a configured password, it should be able to do the trick. Be careful how you do that though, you don't want to give your admin password to anyone who looks inside your mission...

Perhaps you can store the password in a userConfig document on the server and have a script (executed on the server) retrieve it for use by that command.

Share this post


Link to post
Share on other sites

Thank you for you answers.

Yeah, I don't want to restart the mission. I want to restart the server itself.

@Fight9 : What is the server command to restart a server ? #reassign ?

And do you have any explanations how I can do what you said, cause I'm a beginner in scripting.

Thanks.

Share this post


Link to post
Share on other sites

It would be:

"serverPassword" serverCommand "#restart";

But AFAIK this is just a soft restart, it won't actually reset the box, if that's more of what your after?

Share this post


Link to post
Share on other sites

Yup, Jshock has it right.

Make a document in your servers arma 3 root... in the userConfig folder (make one if you dont have it already).

arma 3\userConfig\myPass\myPass.hpp

Then in that file, just put your server.cfg password in quatations

// \userConfig\myPass\myPass.hpp
"mypassword1"

Then, to restart the server... call this code on the server

if isServer then {
_myPass = call compile preprocessFileLineNumbers "\userConfig\myPass\myPass.hpp";
_myPass serverCommand "#restart";
};

This way, if someone looks inside your mission, they wont get your password.

  • Like 1

Share this post


Link to post
Share on other sites
It would be:

"serverPassword" serverCommand "#restart";

But AFAIK this is just a soft restart, it won't actually reset the box, if that's more of what your after?

Thanks for your answer.

I would like to try that on my local server, but what is the admin password on the local server ? How can we configure it ?

EDIT : @Fight9 : Nice, thank you very much. I would like to try that on my own local server before.

But the command #restart only restart the mission, not the server itself, right ?

Share this post


Link to post
Share on other sites

I thought it restarted the server by I am probably wrong.

Share this post


Link to post
Share on other sites
But the command #restart only restart the mission, not the server itself, right ?

Yes, AFAIK, that's what I call a soft restart, that's why I don't think it's possible to restart the server box itself via script unless you use an extension (which still may not work).

Share this post


Link to post
Share on other sites

I think that I will do something different.

My dedicated server restarts every 12 hours (it's an option on the hoster website).

In my mission script I will just set the countdown to 12 hours (43200 seconds), and normally it should be sync with the delay of restart of the server.

But maybe there is a difference between the starting time of the countdown of the server and the one of the mission ? Like some seconds, idk.

Share this post


Link to post
Share on other sites

There is #shutdown I think, but you need another program to monitor if server is down and bring it up. Alternatively you can make an extension to restart server.

Share this post


Link to post
Share on other sites
Yup, Jshock has it right.

Make a document in your servers arma 3 root... in the userConfig folder (make one if you dont have it already).

arma 3\userConfig\myPass\myPass.hpp

Then in that file, just put your server.cfg password in quatations

// \userConfig\myPass\myPass.hpp
"mypassword1"

Then, to restart the server... call this code on the server

if isServer then {
_myPass = call compile preprocessFileLineNumbers "\userConfig\myPass\myPass.hpp";
_myPass serverCommand "#restart";
};

This way, if someone looks inside your mission, they wont get your password.

Hello, thanks for the help but it doesn't work.

When the countdown reach 0 and when it's supposed to do

_myPass = call compile preprocessFileLineNumbers "\userConfig\myPass\myPass.hpp";

_myPass serverCommand "#restart";

I got this :

44eb62416c.png

myPass.hpp is right here, in the server root :

764a4dbde4.png

Any idea of what is the problem ?

Share this post


Link to post
Share on other sites

It says it right on the popup: The game is unable to find the file in that path.

Check here how to properly address files in various locations.

Are you absolutely 100% sure you have it in the right folder and correctly named? Because your script works just fine, so the file being in the wrong path is the only possible remaining issue, aside some VERY restrictive file read permissions on your server (which is also very unlikely).

Also, "#restart" might not be what you want. The wiki gives valuable insight. The only way to truly restart the server is by shutting it down using #shutdown and having an external program monitor the process termination, triggering a new start of the server. Easy on Linux, much harder on Windows.

EDIT: Ninjas...

Another very unlikely cause for not finding external scripts would be if your server runs ArmA3 with the "-noFilePatching" startup parameter for some obscure reason.

Edited by Senshi

Share this post


Link to post
Share on other sites

Thanks for the answer.

Yes, the folders and the file are in the main folder of the server, right here :

http://i.gyazo.com/5a39ef65e7f9adc4a4fb2cb0a4e4f8f9.gif

Then in my script :

   	     if(_time < 2) then
           {  
        _myPass = call compile preprocessFileLineNumbers "\userConfig\myPass\myPass.hpp";
        _myPass serverCommand "#restart";
	    };

And in the myPass.hpp file :

1bdaa91e26.png

(I will change it so doesn't matter if you see it right now)

I know about the #restart command, this is finally what I want.

Another very unlikely cause for not finding external scripts would be if your server runs ArmA3 with the "-noFilePatching" startup parameter for some obscure reason.

How can I check that ? server.cfg ?

Edited by Raptor2x

Share this post


Link to post
Share on other sites

The script is inside init.sqf

---------- Post added at 13:41 ---------- Previous post was at 12:02 ----------

Even with that script it doesn't works.

But the test message works.

67a7d7da2a.png

---------- Post added at 14:42 ---------- Previous post was at 13:41 ----------

Well it's working great with this script :

db2b547995.png

But the problem is that after the mission restart, the countdown does not restart.

I want the countdown to restart again and again after the mission restart, do you know what I mean ?

Share this post


Link to post
Share on other sites
The script is inside init.sqf

---------- Post added at 13:41 ---------- Previous post was at 12:02 ----------

Even with that script it doesn't works.

But the test message works.

http://www.puu.sh/hh5dl/67a7d7da2a.png

---------- Post added at 14:42 ---------- Previous post was at 13:41 ----------

Well it's working great with this script :

http://www.puu.sh/hh7Yr/db2b547995.png

But the problem is that after the mission restart, the countdown does not restart.

I want the countdown to restart again and again after the mission restart, do you know what I mean ?

So am I correct to assume you want this to work on dedicated server? Because it looks like you run this on client at the moment as you can see systemChat, which you wouldn't be able to see on dedicated.

Share this post


Link to post
Share on other sites

Yes it's on a dedicated server (gtxgaming). But the systemChat works good.

Share this post


Link to post
Share on other sites
Yes it's on a dedicated server (gtxgaming). But the systemChat works good.

You don't understand, systemChat doesn't work on dedicated server, period. If it works then you are running it on client.

Share this post


Link to post
Share on other sites
You don't understand, systemChat doesn't work on dedicated server, period. If it works then you are running it on client.

Do you mean client side and server side ? So it means that the file where I put my script is client side ?

And do you have any idea how I can fix that :

Well it's working great with this script :

http://www.puu.sh/hh7Yr/db2b547995.png

But the problem is that after the mission restart, the countdown does not restart.

I want the countdown to restart again and again after the mission restart, do you know what I mean ?

Anyway, thank you for your help.

Share this post


Link to post
Share on other sites

You really have to read up on the separation between client and serverside. It's one of the key concepts you have to understand to be able to make proper MP scripts.

Regarding your script:

Give details on how and where you set up the "countdown" to trigger your mission restart. And as KK said, if you can read systemchat, your script is running on your client. It might also run on the server, but you won't know. If you want the server to monitor the countdown and trigger the mission end, make sure it runs there and not the client. If you have this code in the init.sqf, currently it probably runs BOTH on the server and client independently. However, the server will launch it when the server starts the mission, and your client will start it when you load in to the mission.

Also take note that the "failmission"/"endmission" commands are NOT global, so executing it once locally will just end the mission for your client, not the server.

Share this post


Link to post
Share on other sites

Yes I need to read about the clientside & serverside, do you have any link of tutorial which can help me ?

How can I make a server side file with a script that get launch when the mission start (and restart).

Here is my init.sqf for you can see how I did the script.

https://mega.co.nz/#!58k0WYRb!fSrSbxA_cZftWd8XFL8in1rOfZ0j8w1DcZaZjvPNYMs

Also take note that the "failmission"/"endmission" commands are NOT global, so executing it once locally will just end the mission for your client, not the server.

Yes, so I need to use "_myPass serverCommand "#restart";" but I have the other problem with the file that is not found.

Maybe it's because of init.sqf.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×