Jump to content
  • 0

Combat mode if AI or zombies nearby


rss_adm

Question

Players reconnect to the server if nearby AI or zombies.

I came up with the following code, but I don't know what to do next. Help

if (nearestObjects [player, AI_BanditTypes, 1200]) then {

player setVariable['startcombattimer', 1, true];

} else {

player setVariable['startcombattimer', 0, true];

};

P.S. Sorry for my bad english :)

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

There already is somewhere a script which triggered on ESC and does not allow players to disconnect when someone is near them.

Just search for it, even some Mods have this installed.

it will be executed in description.ext under 

onPauseScript = "";
Link to comment
Share on other sites

  • 0

 

There already is somewhere a script which triggered on ESC and does not allow players to disconnect when someone is near them.

Just search for it, even some Mods have this installed.

it will be executed in description.ext under 

onPauseScript = "";

 

I did a little differently. do you think it right?

while {true} do {
  sleep 2;

  _playerPos = getPos player;
  _nearzed = nearestObject [_playerPos, ["zZombie_Base"], 50];
  _nearbot = nearestObject [_playerPos, ["AI_BanditTypes"], 800];
  _escMenu = findDisplay 49;
  if (!(isNull _nearzed || _nearbot) exitWith
   {
      titleText ["You can not leave the battle!", "PLAIN DOWN", 3];
      systemchat "You can not leave the battle!";
	  _escMenu closedisplay 0;
      player setVariable['startcombattimer', 1, true];	  
   };
   };

Or editing player_onPause.sqf :

 

private ["_display","_btnRespawn","_btnAbort","_timeOut","_timeMax","_btnAbortText"];
disableSerialization;
waitUntil {
	_display = findDisplay 49;
	!isNull _display;
};
_btnRespawn = _display displayCtrl 1010;
_btnAbort = _display displayCtrl 104;
_btnRespawn ctrlEnable false;
_btnAbort ctrlEnable false;
_btnAbortText = ctrlText _btnAbort;
_timeOut = 0;
_timeMax = diag_tickTime+10;
dayz_lastCheckBit = time;
		
// if(r_player_dead) exitWith {_btnAbort ctrlEnable true;};
if(r_fracture_legs && !r_player_dead) then {_btnRespawn ctrlEnable true;};
		
//force gear save
if (!r_player_dead && time - dayz_lastCheckBit > 10) then {
	call dayz_forceSave;
};			

if (r_player_dead || (!alive player)) exitWith {_btnAbort ctrlEnable true; _btnAbort ctrlSetText _btnAbortText;};		
_sleep = 1;

while {!isNull _display} do {
	switch true do {
		case (!r_player_dead && {isPlayer _x} count (player nearEntities ["AllVehicles", 12]) > 1) : {
			_btnAbort ctrlEnable false;
			cutText [localize "str_abort_playerclose", "PLAIN DOWN"];
			_sleep = 1;
		};
		case (!r_player_dead && !canbuild) : {
			_btnAbort ctrlEnable false;
			cutText [(localize "str_epoch_player_12"), "PLAIN DOWN"];
			_sleep = 1;
		};
		case (!r_player_dead && player getVariable["combattimeout", 0] >= time) : {
			_btnAbort ctrlEnable false;
			//cutText ["Cannot Abort while in combat!", "PLAIN DOWN"];
			cutText [localize "str_abort_playerincombat", "PLAIN DOWN"];
			_sleep = 1;
		};
		case (_timeOut < _timeMax) : {
			_btnAbort ctrlEnable false;
			_btnAbort ctrlSetText format["%1 (in %2)", _btnAbortText, (ceil ((_timeMax - diag_tickTime)*10)/10)];
			cutText ["", "PLAIN DOWN"];	
			_sleep = 0.1;
		};
// ##################################################################
		case (nearestObject [player, ["AI_BanditTypes"], 800];) : {
			_btnAbort ctrlEnable false;
			cutText ["You can not leave if bandits mission nearby ", "PLAIN DOWN"];	
			_sleep = 0.1;
		};
		case (nearestObject [player, ["zZombie_Base"], 50];) : {
			_btnAbort ctrlEnable false;
			cutText ["You can not leave if zombie nearby", "PLAIN DOWN"];	
			_sleep = 0.1;
		};
// ##################################################################
		default {
			_btnAbort ctrlEnable true;
			_btnAbort ctrlSetText _btnAbortText;
			cutText ["", "PLAIN DOWN"];	
			_sleep = 1;
		};
	};
	sleep _sleep;
	_timeOut = diag_tickTime;
};
cutText ["", "PLAIN DOWN"];
 

 

I'm confused.. :blink:  player_onPause.sqf unknown how to initialize..

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
  • Advertisement
  • Discord

×
×
  • Create New...