Jump to content

Lnwnel

Member
  • Content Count

    2
  • Joined

  • Last visited

  • Medals

Posts posted by Lnwnel


  1. On 3/24/2017 at 7:27 AM, Belbo said:

    One problem with that is findNearestEnemy though. It only returns an enemy if the player actually knows something about the enemy unit. That's quite stupid, but we can write a function that looks for the closest enemy at hand:

     

    
    private _weapon = currentWeapon player;
    if (_weapon isEqualTo "" || _weapon isEqualTo (binocular player)) then {
    	player setCaptive true;
    };
    
    //our function to find the nearest enemy reliably:
    fnc_findNearestEnemy = {
    	params [
    		["_unit", objNull, [objNull]]
    		,["_radius", 600, [0]]
    		,"_closest"
    	];
    	//maybe there already is one?
    	_closest = (_unit findNearestEnemy _unit);
    	if ( !isNull _closest ) exitWith {
    		_closest;
    	};
    	//who are our enemies?
        private _enemySides = [side _unit] call BIS_fnc_enemySides;
      	//are there any enemies within the radius?
    	private _nearEnemies = allUnits select { (_x distance _unit) < _radius && (side _x) in _enemySides};
    	//let's loop through the enemies to find the closest one:
    	private _closestdist = _radius+1;
    	{
    		if (_x distance _unit < _closestdist) then {
    			_closest = _x;
    			_closestdist = _x distance _unit;
    		};
    	} forEach _nearEnemies;
    	//return the closest at the end of the function:
    	_closest;
    };
    //the next part is what happens if the player changes his weapon (on foot):
    undercover_scriptfnc_switch_onfoot = {
    	params [
    		["_unit", player, [objNull]]
    		,["_weapon", currentWeapon player, [""]]
    	];
      	//if the player changed to binoculars, there will be no change (if he was undercover, he will remain undercover - if not, then not)
    	if (_weapon isEqualTo (binocular _unit)) exitWith {};
      	//if the player changes to no weapon AND the next enemy is further away then 50 meters AND no enemy knows something about the player within 600 meters he will go undercover:
    	if ( _weapon isEqualTo "" && ([_unit,60] call fnc_findNearestEnemy) distance _unit > 50 && ([_unit,600] call fnc_findNearestEnemy) knowsAbout _unit < 1.5 ) exitWith {
          	//he should know about it, if it worked, but not if he already was undercover:
    		if !(captive _unit) then {
    			systemChat "You are now undercover.";
    		};
          	//the "hear" of our code:
    		_unit setCaptive true;
    	};
      	//the stuff below here is being executed, if none of the above applied:
    	//if player was undercover, he should know that he is not anymore:
      	if (captive _unit) then {
    		systemChat "You are no longer undercover.";
    	};
      	//and this switches him back to his regular self:
    	_unit setCaptive false;
    };
    //the following is what appens if the player jumps into a vehicle:
    undercover_scriptfnc_switch_inVeh = {
    	params [
    		["_unit", player, [objNull]]
    		,["_veh", vehicle player, [objNull]]
    	];
      	//if the vehicle has no weapons, nothing will change:
    	if ( (_veh currentWeaponTurret [-1]) isEqualTo "" && (_veh currentWeaponTurret [0]) isEqualTo "" ) exitWith {};
    	//but if it did, this will happen:
      	if (captive _unit) then {
    		systemChat "You are no longer undercover.";
    	};
      	//the player is no longer undercover:
    	_unit setCaptive false;
    };
    
    //and here we add the cba-playerEventHandler: They trigger everytime something happens and will execute some code:
    //this one executes the code within {} (which is our undercover_scriptfnc_switch_onfoot from above) if the player changes his weapon:
    undercover_scriptevh_onFoot = ["weapon", {[_this select 0, _this select 1] call undercover_scriptfnc_switch_onfoot}] call CBA_fnc_addPlayerEventHandler;
    //this one executes the code within {} (which is our undercover_scriptfnc_switch_inVeh from above) if the player changes his vehicle:
    undercover_scriptevh_inVeh = ["vehicle", {[_this select 0, _this select 1] call undercover_scriptfnc_switch_inveh}] call CBA_fnc_addPlayerEventHandler;
    //and done.

    Now it'll check reliably for the next enemy. If it finds an enemy within 50 meters or if any enemy in a radius of 600 meters knows about the player while the player tries to go undercover, the player will not go into undercover mode.


    Need help

    i created a initPlayerLocal.sqf file with this script inside, i wrote it down line by line, but the way it works in the game right now is whenever i equip gun, it always make me go uncaptive, and i can’t go back undercover even though there isn’t any enemy around me. How can i fix it?


  2. 12 hours ago, RZNUNKWN said:


    Add and try Halkes's m3mory, see if it helps - https://steamcommunity.com/sharedfiles/filedetails/?id=2648482641

    I know Arma is doing these things, but I just don't know the way around it... It's just Arma clogging itself up to the point where it's unplayable.

    Yeah the save system work fine in my mp scenario but not until i played it with friend for 6 hours, after i load that save again. i spawn in the middle of ocean [0,0], thanks for info, i will try this mod out.

     

     i also have question to ask here, i followed this guide on how to make the respawn tent work, but i’m not sure which tent it is. And also not sure if this really work since i can’t test it. Is it the backpack that can take off and deploy as a tent? not the tent that named “Folded tent” that able to be put in any storage? I have only ever found the latter one though. https://ravage.fandom.com/wiki/Respawning_players_in_multiplayer

     

    another question is how to make sleeping bag sleep-able in multiplayer? Is it possible?

×