Jump to content
  • 0

Dome access log script


Randomness

Question

16 answers to this question

Recommended Posts

  • 0

something like that should work yeah, you could also send a "private message" to the owner if he is online. :)

btw there are many errors in that script, but I think you know that since you didn't even test it yet :D

 

Yeah, I am still "studying" the sqf syntax, the foreach syntax and the if statement are merely for writing down what to   :P. I usually tend learn a language by reading example code, so i guess i'll be reading a lot first :) And I wouldnt private message the owner, that would take the fun out of it xD This is more to moderate attacks on bases to enforce a PvP only on bases rule :)

 

Edit: http://community.bistudio.com/wiki/goto

Cannot use goto in sqf unfortunately

 

Edit2: i got a testable concept atm, just going to wait until i have the time and resources to do this unless someone feels like testing (or can point at some errors without testing). Also, what kind of info does PlayableUnits return, i was hoping for puids but I'm guessing this is a bit too optimistic again?

 

Anyways, here's my current updated code:

// Below, put the UID of player(s) where it says pasteUIDhere that you want to give access to the dome
_owners = ["0", "0", "0"];

// Check if the player IS one of the owners
if ((getPlayerUID player) in _owners) exitWith { 
	titleText ["Welcome home", "PLAIN DOWN", 3]; //or,\\ titleText [format ["Welcome, %1", name player], "PLAIN DOWN"]; // welcomes you with your name
};
_ownerOnline = false;

// Check if one of the owners is online
while (_ownerOnline = false) {
		{ 
		if (_x in PlayableUnits) {
			_ownerOnline = true;
		} foreach _owners;
	};
};

// If none of the owners are online, warn the trespasser and write to the log so we know who we're dealing with	
if (_ownerOnline = false) {
	// What happens if unauthorized players get into the dome
	titleText ["This base is currently sleeping, do not destroy.", "PLAIN DOWN", 3];
	diag_log format ["[DOME] Player %1 has approached the NN base at %2", name player, time];
	sleep 60;
	
	titleText ["This is your second warning.", "PLAIN DOWN", 3];
	diag_log format ["[DOME] Player %1 was still at the NN base at %2", name player, time];
	sleep 60;	
	
	titleText ["This is your third warning. You're playing with fire!", "PLAIN DOWN", 3];
	diag_log format ["[DOME] Player %1 was still at the NN base at %2", name player, time];
};



Link to comment
Share on other sites

  • 0

Quick tip, you can use exitWith instead of goto in your example, thats better anyways (I still miss the proper "break" from other programming languages but yeah in your case it shoudl work like this):

{
	if (_x in PlayableUnits) exitWith {
		_ownerOnline = true;
	};
} forEach _owners;

_x is a magic variable, a owner of your array _owners in this case, exitWith will exit the forEach loop

Btw the "in" operator might not work in that case because "PlayableUnits" is a list ob units and not their players ID or whatever so you can't look up the unit with a search for the ID.. so you might have to iterate that list yourself with another loop (and then you can't use exitWith anymore, thats why I hate exitWith lol, but there is still breakOut and breakTo commands, similar to "goto")

Link to comment
Share on other sites

  • 0

It actually sort of worked, but a different issue im running into is that this script is run client-side, so would diag_log even write to the server rpt file? Was figuring a bit of the syntax out so i got this so far (bistudio wiki really has weird explanations in some places):

// Check if the player IS one of the owners
if ((getPlayerUID player) in _owners) exitWith { 
	titleText [format ["Welcome, %1", name player], "PLAIN DOWN"]; // welcomes you with your name
};


// Check if one of the owners is online
{ 
	if (_x in PlayableUnits) exitWith {
         diag_log(format["[DOME] Found %1 in PlayableUnits", name _x]);
         titleText [format ["Welcome to the NN base, %1, make sure you're unarmed if you seek no trouble.", name player], "PLAIN DOWN"];
   	};
} foreach _owners;

	// What happens if unauthorized players get into the dome
	titleText ["The owners of this base are not online, please turn around.", "PLAIN DOWN", 3];
	diag_log(format["[DOME] Player %1 has approached the NN base at %2", name player, time]);
	sleep 60;
	
	titleText ["This is the second warning, attacking a base is only allowed when there is an active defense.", "PLAIN DOWN", 3];
	diag_log(format["[DOME] Player %1 was still at the NN base at %2", name player, time]);
	sleep 180;	
	
	titleText ["This is your third warning. Breaking the rules can result in tempbans!", "PLAIN DOWN", 3];
	diag_log(format["[DOME] Player %1 was still at the NN base at %2", name player, time]);

(NN is the name of our clan)

Link to comment
Share on other sites

  • 0

diag_log logs in the RPT file where the script is executed, so if the script is executed on teh client it will write to the client log,

but you can send the message to the server and log there, look here: http://dayzepoch.com/forum/index.php?/topic/3850-client-side-player-logging-to-server-log/

 

And as I've said before the server can send private messages to a client (like the owner(s) of the base) to inform them, but only the server can do that not client to client. see here http://community.bistudio.com/wiki/publicVariableClient

Link to comment
Share on other sites

  • 0

Thanks, I couldnt fin this info anywhere :P (for dayz_players)

 

so this should work:

// Check if one of the owners is online
{ 
	if (getPlayerUID(_x) in dayz_players) exitWith {
         diag_log(format["[DOME] Found %1 in PlayableUnits", name _x]);
         titleText [format ["Welcome to the NN base, %1, make sure you're unarmed if you seek no trouble.", name player], "PLAIN DOWN"];
   	};
} foreach _owners;
Link to comment
Share on other sites

  • 0

locality is more about if the process is run on the server or client. not where the file is.

The advantage of moving files to dayz server pbo is to reduce the size of the mission download.

Have seen some weird issues with server files with some stuff. currently running a client based ai unit and storing the eventhandler files on the server. Causes a file not found error, for all players, when it is fired. Yet the code still runs ok.. Moving to mission, and possibly precompiling from server, fixes it..

I assumed dayz_players was an array of all player objects, got the idea from sarge's AI code. May have to do a forEach on it, worth a test..

Let us know your results..

Link to comment
Share on other sites

  • 0

The script is almost finished except for a minor bug with checking the online list. I'll post the full script when it's fully finished (and if anyone is interested, there is some bug in the following code apparantly):

theere are no errors (unfortunately) but it just seems to not find any owner there is one online

//Function to check if a puid is in the onlinelist
_fnc_isPlayerOnline = {
	_uid = _this;
	_isOnline = false;
	{
		if (_uid == getPlayerUID _x) exitWith {
            _isOnline = true;
		};
	} foreach dayz_players;
	_isOnline
};



    // Check if one of the owners is online
    { 
		if (_x call _fnc_isPlayerOnline) exitWith {
			_ownerOnline = true;
		};
    } foreach _owners;


Link to comment
Share on other sites

  • 0
private ["_owners","_onlineUIDs","_currentUIDs"];
_owners = ["000000000"];
_currentUIDs = PlayableUnits;
_onlineUIDs = [];

{
	_onlineUIDs = _onlineUIDs + [(getPlayerUID _x)];
} forEach _currentUIDs;


{
	if (_x in _onlineUIDs) exitWith {
		diag_log format["Owner is online!"];
	};
} forEach _owners;

Hope you can use it :)

 

And here it is as a function

private ["_owners","_onlineUIDs","_currentUIDs","_ownerIsOnline"];
diag_log format["%1",playableUnits];
_owners = ["0000000000"];


_fnc_tesfForOnline = {
	_currentUIDs = PlayableUnits;
	_onlineUIDs = [];
	{
		_onlineUIDs = _onlineUIDs + [(getPlayerUID _x)];
		diag_log format["Online UID's: %1", _onlineUIDs];
	} forEach _currentUIDs;
	_onlineUIDs
};

{
	if (_x in (call _fnc_tesfForOnline)) exitWith {
		diag_log format["Owner Is Online!"];			
	};
} forEach _owners;
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Discord

×
×
  • Create New...