Jump to content
Sign in to follow this  
davidoss

allunits SIDE west.

Recommended Posts

Hi. I am stack and need help.

How i get this correctly?

_blufor = allUnits side WEST;

Share this post


Link to post
Share on other sites
_blufor = [];

{if ((side _x) == west) then {_blufor pushBack _x}} forEach allUnits;

Share this post


Link to post
Share on other sites

If you want the number of players that are connected to a server use playersNumber instead.

playersNumber east; //OpFor

playersNumber west; //BluFor

playersNumber independent;

playersNumber civilian;

This is for multiplayer only, but since you did not specify what scenario you're working on, I thought I will write it anyway.

Greez Kilo

Share this post


Link to post
Share on other sites
_blufor = [];

{if ((side _x) == west) then {_blufor pushBack _x}} forEach allUnits;

This is working great (there is going about spawned/generated AI) but i need something like this for all west vehicles too.

I am trying to customize nice IED script maked by Drunken Officer called IEDtoMine V2.

That code is making placed BIS IED set off by all playable units or all switchable units.

For my insurgency mission i need to make IED'S to set off by all units WEST and i got it (Thanks to you guys).

Now i need the same for vehicles which are belongs to WEST. Have no idea how to charge it.

if (isServer) then {
waituntil {!isnil "bis_fnc_init"};
DOF_USBV =
	{
			private ["_usbv","_boom","_blufor","_granatentyp","_usbvtyp","_granate"];

			_blufor = [];
			{if ((side _x) == west) then {_blufor pushBack _x}} forEach allUnits;
			_usbv = _this select 0;
			_boom = _this select 1;	
			_usbvtyp = typeof _usbv;
				switch (_usbvtyp) do
				 {
					case "IEDUrbanBig_Remote_Ammo" : {_granatentyp = "Sh_82mm_AMOS"};
					case "IEDLandBig_Remote_Ammo" : {_granatentyp = "R_230mm_fly"};
					case "IEDUrbanSmall_Remote_Ammo" : {_granatentyp = "R_TBG32V_F"};
					case "IEDLandSmall_Remote_Ammo" : {_granatentyp = "R_60mm_HE"};
				 };

			waituntil {sleep 0.1; {_x distance _usbv < _boom} count _blufor > 0 };


			_granate = createVehicle [_granatentyp,[getPos _usbv select 0, getPos _usbv select 1,0],[], 0, 'FLY'];
			[_granate,-90,0] call BIS_fnc_setPitchBank;
			_granate setVelocity [0, 0, -80];
			deleteVehicle _usbv;
	};

 {	if (_x isKindof "IEDUrbanBig_Remote_Ammo" || _x isKindof "IEDLandBig_Remote_Ammo" || _x isKindof "IEDUrbanSmall_Remote_Ammo" || _x isKindof "IEDLandSmall_Remote_Ammo") then {	[_x, 2.4] spawn DOF_USBV; }	}	foreach allMines;
 };

At this moment as vehicle driver you can blew up only if you drive directly your wheels through the mine, because there are no trigger for driver /crew /wehicle.

It should be triggered if you drive near with distance at least 5-8 m .

Edited by DaVIdoSS

Share this post


Link to post
Share on other sites
i need something like this for all west vehicles too.

_bluforVehicles = [];

{
if (_x isKindOf "LandVehicle") then {
	_side = getNumber (configFile >> "CfgVehicles" >> (typeOf _x) >> "side");

	if (_side == 1) then {_bluforVehicles pushBack _x};
};
}
forEach vehicles;

Share this post


Link to post
Share on other sites

Cool many thanks and i really admire your knowledge.

Holly shit this is working just awesome.

But is there a possibility to integrate that into this script? Or i need to execute just new one for vehicles?

Edited by DaVIdoSS

Share this post


Link to post
Share on other sites

Try

if (isServer) then {
waituntil {!isnil "bis_fnc_init"};
DOF_USBV =
	{
			private ["_usbv","_boom","_blufor","_bluforVehicles","_granatentyp","_usbvtyp","_granate","_side"];

			_blufor = [];
			_bluforVehicles = [];

			{if ((side _x) == west) then {_blufor pushBack _x}} forEach allUnits;

			{
				if (_x isKindOf "LandVehicle") then {
					_side = getNumber (configFile >> "CfgVehicles" >> (typeOf _x) >> "side");

					if (_side == 1) then {_bluforVehicles pushBack _x};
				};
			}
			forEach vehicles;

			_usbv = _this select 0;
			_boom = _this select 1;	
			_usbvtyp = typeof _usbv;

			_granatentyp = switch (_usbvtyp) do
			{
				case "IEDUrbanBig_Remote_Ammo" : {"Sh_82mm_AMOS"};
				case "IEDLandBig_Remote_Ammo" : {"R_230mm_fly"};
				case "IEDUrbanSmall_Remote_Ammo" : {"R_TBG32V_F"};
				case "IEDLandSmall_Remote_Ammo" : {"R_60mm_HE"};
			};

			waituntil {sleep 0.1; {_x distance _usbv < _boom} count (_blufor + _bluforVehicles) > 0 };

			_granate = createVehicle [_granatentyp,[getPos _usbv select 0, getPos _usbv select 1,0],[], 0, 'FLY'];
			[_granate,-90,0] call BIS_fnc_setPitchBank;
			_granate setVelocity [0, 0, -80];
			deleteVehicle _usbv;
	};

{if (_x isKindof "IEDUrbanBig_Remote_Ammo" || _x isKindof "IEDLandBig_Remote_Ammo" || _x isKindof "IEDUrbanSmall_Remote_Ammo" || _x isKindof "IEDLandSmall_Remote_Ammo") then {	[_x, 2.4] spawn DOF_USBV; }	} foreach allMines;
};

Share this post


Link to post
Share on other sites

Fantastic job but we need different

_this select 1

from

 [_x, 2.4] spawn DOF_USBV;

specially for vehicles. Now is 2.4 for disarmers , for vehicles should be 9.5.

How to integrate both values?

Edited by DaVIdoSS

Share this post


Link to post
Share on other sites
if (isServer) then {
waituntil {!isnil "bis_fnc_init"};
DOF_USBV =
	{
			private ["_blufor","_bluforVehicles","_granatentyp","_granate","_side"];

			_blufor = [];
			_bluforVehicles = [];

			{if ((side _x) == west) then {_blufor pushBack _x}} forEach allUnits;

			{
				if (_x isKindOf "LandVehicle") then {
					_side = getNumber (configFile >> "CfgVehicles" >> (typeOf _x) >> "side");

					if (_side == 1) then {_bluforVehicles pushBack _x};
				};
			}
			forEach vehicles;

			_granatentyp = switch (typeOf _this) do
			{
				case "IEDUrbanBig_Remote_Ammo" : {"Sh_82mm_AMOS"};
				case "IEDLandBig_Remote_Ammo" : {"R_230mm_fly"};
				case "IEDUrbanSmall_Remote_Ammo" : {"R_TBG32V_F"};
				case "IEDLandSmall_Remote_Ammo" : {"R_60mm_HE"};
			};

			waituntil {
				sleep 0.1;

				({_x distance _this < 2.4} count _blufor > 0) or {({(_x distance _this) < 9.5} count _bluforVehicles) > 0}
			};

			_granate = createVehicle [_granatentyp,[getPos _this select 0, getPos _this select 1,0],[], 0, 'FLY'];
			[_granate,-90,0] call BIS_fnc_setPitchBank;
			_granate setVelocity [0, 0, -80];
			deleteVehicle _this;
	};

{if (_x isKindof "IEDUrbanBig_Remote_Ammo" || _x isKindof "IEDLandBig_Remote_Ammo" || _x isKindof "IEDUrbanSmall_Remote_Ammo" || _x isKindof "IEDLandSmall_Remote_Ammo") then {	_x spawn DOF_USBV; } } foreach allMines;
};

Share this post


Link to post
Share on other sites

Well works perfectly without errors. You are great.

Thank you very much.

PS:

How long you have learned programming?

Share this post


Link to post
Share on other sites
How long you have learned programming?

Since spring of 2014.

Share this post


Link to post
Share on other sites

There is one more problem. I assume i am executing this bad from init.sqf

if (isServer) then {
[] execVM "scripts\ied.sqf";
};

because if i reconnect then it is not working. IEDs do not explode if i even step over.

I think i am no more in _blufor array.

I need then manually execute this script server side from debug console.

This is something with jip players. Dont knew how to fix it. :-(

Edited by DaVIdoSS

Share this post


Link to post
Share on other sites
if (isServer) then {
waituntil {!isnil "bis_fnc_init"};
DOF_USBV =
	{
			private ["_granatentyp","_granate"];

			_granatentyp = switch (typeOf _this) do
			{
				case "IEDUrbanBig_Remote_Ammo" : {"Sh_82mm_AMOS"};
				case "IEDLandBig_Remote_Ammo" : {"R_230mm_fly"};
				case "IEDUrbanSmall_Remote_Ammo" : {"R_TBG32V_F"};
				case "IEDLandSmall_Remote_Ammo" : {"R_60mm_HE"};
			};

			waituntil {
				sleep 0.1;

				(({((side _x) == blufor) and {(_x distance _this) < 2.4}} count allUnits) > 0) or {({(_x isKindOf "LandVehicle") and {(getNumber (configFile >> "CfgVehicles" >> (typeOf _x) >> "side")) == 1} and {(_x distance _this) < 9.5}} count vehicles) > 0}
			};

			_granate = createVehicle [_granatentyp,[getPos _this select 0, getPos _this select 1,0],[], 0, 'FLY'];
			[_granate,-90,0] call BIS_fnc_setPitchBank;
			_granate setVelocity [0, 0, -80];
			deleteVehicle _this;
	};

{if (_x isKindof "IEDUrbanBig_Remote_Ammo" || _x isKindof "IEDLandBig_Remote_Ammo" || _x isKindof "IEDUrbanSmall_Remote_Ammo" || _x isKindof "IEDLandSmall_Remote_Ammo") then {	_x spawn DOF_USBV; } } foreach allMines;
};

Share this post


Link to post
Share on other sites

Thanks for i assume better code. But this is not solving the jip problem.

Anyway great job sir. How to execute server side script if new player connecting?

Edited by DaVIdoSS

Share this post


Link to post
Share on other sites

init.sqf

if (isServer) then {ied = compileFinal (preprocessFileLineNumbers "scripts\ied.sqf")};

ied.sqf

_granatentyp = switch (typeOf _this) do
{
case "IEDUrbanBig_Remote_Ammo" : {"Sh_82mm_AMOS"};
case "IEDLandBig_Remote_Ammo" : {"R_230mm_fly"};
case "IEDUrbanSmall_Remote_Ammo" : {"R_TBG32V_F"};
case "IEDLandSmall_Remote_Ammo" : {"R_60mm_HE"};
};

waituntil {
sleep 0.1;

(({((side _x) == blufor) and {(_x distance _this) < 2.4}} count allUnits) > 0) or {({(_x isKindOf "LandVehicle") and {(getNumber (configFile >> "CfgVehicles" >> (typeOf _x) >> "side")) == 1} and {(_x distance _this) < 9.5}} count vehicles) > 0}
};

_granate = createVehicle [_granatentyp,[getPos _this select 0, getPos _this select 1,0],[], 0, 'FLY'];
[_granate,-90,0] call BIS_fnc_setPitchBank;
_granate setVelocity [0, 0, -80];
deleteVehicle _this;

Add this code into action of placing charge:

[_charge, "ied", false] call BIS_fnc_MP;

Edited by Schatten

Share this post


Link to post
Share on other sites

As usual, great. Thank you. Mission complete. Now IEDs are dangerous as hell.

:icon_dj:

Share this post


Link to post
Share on other sites

I forgot something. Is it possible to discharge IED? It's importante because if unit discharged IED ied script (spawned on server) will not be terminated.

Share this post


Link to post
Share on other sites

Yes we can discharge IED,s. But the whole ieds are editor objects. And its works just beautifully.

I just use this:

Placed manually many objects in editor:

IEDLandSmall_F
IEDUrbanSmall_F
IEDLandBig_F
IEDUrbanBig_F

init.sqf

if (isServer) then {
//run on dedicated server or player host

ied = compileFinal (preprocessFileLineNumbers "scripts\ied.sqf");
[] spawn ied;
};

ied.sqf

if (isServer) then {

DOF_USBV =
	{
			private ["_granatentyp","_granate"];

			_granatentyp = switch (typeOf _this) do
			{
				case "IEDUrbanBig_Remote_Ammo" : {"R_230mm_HE"};
				case "IEDLandBig_Remote_Ammo" : {"Bo_GBU12_LGB_MI10"};
				case "IEDUrbanSmall_Remote_Ammo" : {"R_TBG32V_F"};
				case "IEDLandSmall_Remote_Ammo" : {"R_60mm_HE"};
			};

			waituntil {
				sleep 0.1;

				(({((side _x) == blufor) and {(_x distance _this) < 2.6}} count allUnits) > 0) or {({(_x isKindOf "LandVehicle") and {(getNumber (configFile >> "CfgVehicles" >> (typeOf _x) >> "side")) == 1} and {(_x distance _this) < 8.5}} count vehicles) > 0}
			};

			_granate = createVehicle [_granatentyp,[getPos _this select 0, getPos _this select 1,0],[], 0, 'FLY'];
			[_granate,-90,0] call BIS_fnc_setPitchBank;
			_granate setVelocity [0, 0, -80];
			deleteVehicle _this;
	};

{if (_x isKindof "IEDUrbanBig_Remote_Ammo" || _x isKindof "IEDLandBig_Remote_Ammo" || _x isKindof "IEDUrbanSmall_Remote_Ammo" || _x isKindof "IEDLandSmall_Remote_Ammo") then {	_x spawn DOF_USBV; } } foreach allMines;
};

Can you see any problems here?

Edited by DaVIdoSS

Share this post


Link to post
Share on other sites

I don't see any errors. But if ied script spawns each time on player connected DOF_USBV script will be spawn on same IEDs many times.

If you use my solution, it needs to be improved to terminate ied script after IED is discharged.

Share this post


Link to post
Share on other sites

This is whole time your solution.

Yes you could make it perfect but how?

I don't have any script to spawn IEDs with init or actions.

Really i don't knew how to go forward.

Can you help?

Share this post


Link to post
Share on other sites

Is there any script to discharge IED?

Edited by Schatten

Share this post


Link to post
Share on other sites

We use AGM actions.

fn_defuseExplosive.sqf

/*
Name: AGM_Explosives_fnc_DefuseExplosive

Author: Garth de Wet (LH)

Description:
	Defuses an Explosive

Parameters: 
	0: OBJECT - unit
	1: OBJECT - Explosive

Returns:
	Nothing

Example:
	[player, AGM_Interaction_Target] call AGM_Explosives_fnc_DefuseExplosive;
*/
private ["_unit", "_explosive"];
_unit = _this select 0;
_explosive = _this select 1;

if (getNumber (ConfigFile >> "CfgAmmo" >> typeof _explosive >> "AGM_explodeOnDefuse") == 1) exitWith {
[_unit, -1, [_explosive, 1], true] call AGM_Explosives_fnc_DetonateExplosive;
};

_unit action ["Deactivate", _unit, _explosive];

fn_PlaceExplosive.sqf

/*
Name: AGM_Explosives_fnc_PlaceExplosive

Author(s):
	Garth de Wet (LH)

Description:
	Places an explosive at the requested position

Parameters:
	0: OBJECT - unit
	1: POSITION - Position to place explosive
	2: NUMBER - Rotation
	3: STRING - Magazine class
	4: Config - Config of trigger
	5: ARRAY - variables required for the trigger type

Returns:
	OBJECT: Placed explosive

Example:
	_explosive = [player, player modelToWorld [0,0.5, 0.1], 134, "SatchelCharge_Remote_Mag", "Command", []] call AGM_Explosives_fnc_PlaceExplosive;
*/
private ["_pos", "_dir", "_magazineClass", "_ammo", "_triggerSpecificVars", "_unit", "_triggerConfig", "_explosive"];
_unit = _this select 0;
_pos = _this select 1;
_dir = _this select 2;
_magazineClass = _this select 3;
_triggerConfig = _this select 4;
_triggerSpecificVars = _this select 5;
_setDir = true;
if (count _this > 6) then {
_setDir = _this select 6;
};

if (isNil "_triggerConfig") exitWith {
diag_log format ["AGM_Explosives: Error config not passed to PlaceExplosive: %1", _this];
objNull
};

_magazineTrigger = ConfigFile >> "CfgMagazines" >> _magazineClass >> "AGM_Triggers" >> _triggerConfig;
_triggerConfig = ConfigFile >> "CfgAGM_Triggers" >> _triggerConfig;

if (isNil "_triggerConfig") exitWith {
diag_log format ["AGM_Explosives: Error config not found in PlaceExplosive: %1", _this];
objNull
};

_ammo = getText(ConfigFile >> "CfgMagazines" >> _magazineClass >> "ammo");
if (isText(_magazineTrigger >> "ammo")) then {
_ammo = getText (_magazineTrigger >> "ammo");
};
_triggerSpecificVars pushBack _triggerConfig;
_explosive = createVehicle [_ammo, _pos, [], 0, "NONE"];
if (isText(_triggerConfig >> "onPlace") && {[_unit,_explosive,_magazineClass,_triggerSpecificVars] call compile (getText (_triggerConfig >> "onPlace"))}) exitWith {_explosive};
if (_setDir) then {
[[_explosive, _dir, getNumber (_magazineTrigger >> "pitch")], "AGM_Explosives_fnc_setPos"] call AGM_Core_fnc_execRemoteFnc;
};
_explosive

fn_StartDefuse.sqf

/*
 Name: AGM_Explosives_fnc_StartDefuse

 Author: Garth de Wet (LH)

 Description:
   Starts defusing an explosive

 Parameters: 
   0: OBJECT - Unit to defuse explosive
   1: OBJECT - Target explosive

 Returns:
   Nothing

 Example:
   [player, AGM_Interaction_Target] call AGM_Explosives_fnc_StartDefuse;
*/
private ["_unit","_target"];
_unit = _this select 0;
_target = _this select 1;

// [_specialist, _target] call _fnc_DefuseTime;
_fnc_DefuseTime = {
 _target = _this select 1;

 _defuseTime = 5;
 if (isNumber(ConfigFile >> "CfgAmmo" >> typeOf (_target) >> "AGM_DefuseTime")) then {
   _defuseTime = getNumber(ConfigFile >> "CfgAmmo" >> typeOf (_target) >> "AGM_DefuseTime");
 };
 if (!(_this select 0) && {AGM_Explosives_PunishNonSpecialists}) then {
   _defuseTime = _defuseTime * 1.5;
 };
 _defuseTime
};
_actionToPlay = "MedicOther";
if (STANCE _unit == "Prone") then {
 _actionToPlay = "PutDown";
};

if (AGM_player != _unit) then {
 // If the unit is a player, call the function on the player.
 if (isPlayer _unit) then {
   [[_unit, _target], "AGM_Explosives_fnc_StartDefuse", _unit] call AGM_Core_fnc_execRemoteFnc;
 } else {
   [_unit, _target, [[_unit] call AGM_Core_fnc_isEOD, _target] call _fnc_DefuseTime] spawn {
     (_this select 0) playActionNow _actionToPlay;
     (_this select 0) disableAI "MOVE";
     (_this select 0) disableAI "TARGET";
     sleep (_this select 2);
     [(_this select 0), (_this select 1)] call AGM_Explosives_fnc_DefuseExplosive;
     (_this select 0) enableAI "MOVE";
     (_this select 0) enableAI "TARGET";
   };
 };
} else {
 _unit playActionNow _actionToPlay;
 if (AGM_Explosives_RequireSpecialist) then {
   if ([_unit] call AGM_Core_fnc_isEOD) then {
     [[true, _target] call _fnc_DefuseTime, [_unit,_target], "AGM_Explosives_fnc_DefuseExplosive", localize "STR_AGM_Explosives_DefusingExplosive"] call AGM_Core_fnc_progressBar;
   };
 } else {
   [[([_unit] call AGM_Core_fnc_isEOD), _target] call _fnc_DefuseTime, [_unit,_target], "AGM_Explosives_fnc_DefuseExplosive", localize "STR_AGM_Explosives_DefusingExplosive"] call AGM_Core_fnc_progressBar;
 };
};

This does not need to be. I can just disable AGM explosives. Do you have any other script?

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  

×