Jump to content
Sign in to follow this  
h0rs

Locking Server via SQF

Recommended Posts

Hey everyone,

This was a post intended for the A3 section but it appears I cannot post there for some reason.

I was looking for a way to lock the server while a mission is in play WITHOUT doing it via manual admin commands. I came across (http://forums.bistudio.com/showthread.php?114773-How-to-prevent-JIP) in my search, however nothing of any real use to me was present.

I was thinking of something in init.sqf, like this:

if (isServer) then {
serverCommand "#lock";
};

However this doesn't work as the command requires being logged in and I do not believe that can be done in a non-dedicated environment anyway.

As I am running this in a non-dedicated environment, and I would like a solution that would prevent players from joining the lobby (if possible).

I know how to code a solution that blacks out a JIP client but that is not very ideal for my game type.

Thanks!

Share this post


Link to post
Share on other sites

I do not think you can send commands over sqf but what you can try is a publicVariable set when someone joins the mission.

For example:

// file: init.sqf
if (isNul "disallowedToJoin") then { hint"put player into game"; } else { hint"you are not allowed ingame"; player setDamage 1; };

The only problem is that the first player that joins will execute the code which means that there will only be one player in the mission xD

You can fixed that by assigning an isServer check to the code I posted above. That will make only the server/host execute the script.

Then, put a sleep at the start of disallowJoin.sqf which will be the time people are allowed to join after the host got into the game.

After the sleep command you should send the disallowedToJoin PVB (publicVariable) so that all players that join after the server/host sent the PVB will be killed or whatever you want to do with them.

I hope this helped.

Share this post


Link to post
Share on other sites

Oh seems like I haven't seen the whole Wiki yet xD

I guess from looking at the page you linked that you can execute a serverCommand using the isServer check or isDedicated check.

Here is an example:

if isServer {
serverCommand "#lock";
};

The c0de above will lock the server but do not run this code in the init.sqf because then it will instantly lock the server after it processes the init.

Maybe you should put some sort of check on it depending on what you want to achieve.

Good luck!

Share this post


Link to post
Share on other sites

I have put the following code in a script which is executed by a player entering an areatrigger.

// Lock the server.
if (isServer) then {
hint "We are the server.";
_canLock = serverCommandAvailable "#lock";
if(_canLock) then {
	hint "We can lock.";
	serverCommand "#lock";
};
};

I get the hint "We can lock.", but the lock isn't actually achieved if someone is viewing the server from the server list (even after waiting and refreshing over an interval of time.)

Edited by h0rs
code tags

Share this post


Link to post
Share on other sites

Have you tried to get someone to join the server after the lock should have been applied?

Share this post


Link to post
Share on other sites

Yeah I have. They are able to join.

Share this post


Link to post
Share on other sites

I read this on the bottom of the serverCommand wiki page:

"disabled in version 1.59"...... is the server running that version?

Share this post


Link to post
Share on other sites

I mentioned in my first post that this was for A3, so sorry for the confusion! I did not have permission to post there, so I posted it here.

Could a mod please move this?

Share this post


Link to post
Share on other sites

you know what you should try? Login with the admin password yourself and then sending the #lock command to see if it works. If not, then it must be the type of the server preventing it from working.

Share this post


Link to post
Share on other sites

The problem is I don't really know how to set that parameter for a listen server. In dedicated you simply set it in the profile. If I was to distribute this mission, the password (if there was one) would be different for every person who hosts it.

Share this post


Link to post
Share on other sites

There is no way to do this on a listen server as far as I know.. .login and other admin features only work on dedicated.

Share this post


Link to post
Share on other sites
There is no way to do this on a listen server as far as I know.. .login and other admin features only work on dedicated.

I was afraid this might be the case :(

Share this post


Link to post
Share on other sites

You can run a dedicated and a client on the same PC however... so that might be an option

Share this post


Link to post
Share on other sites
You can run a dedicated and a client on the same PC however... so that might be an option

Thanks! Looks like I'll be looking at ensuring my mission runs seamlessly under a dedicated environment then :)

Share this post


Link to post
Share on other sites

Just use this in the start of the init.sqf:

if (isDedicated) then { } else { exitWith{} };

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  

×