Jump to content
avibird 1

Is there a way to call a script for only playable/player units in mission!

Recommended Posts

If a script has this in the mission.SQF to call the script for the units

 

[] execVM "ca\Modules\MP\data\scripts\MPFramework.sqf";
[AllUnits] execVM "DAPMAN\Init.sqf";                                                //All units
if (side _x == WEST) then {[[_x]] execVM "DAPMAN\Init.sqf";          //West units

if (side _x == EAST) then {[[_x]] execVM "DAPMAN\Init.sqf";           //East units

[[player]] execVM "DAPMAN\Init.sqf";                                               //Only human players

 

Is there a way to have only Playable units to use the script?

[[playable_AI] execVM "DAPMAN\Init.sqf";  

 

I looked around but can't find any information on this.   

_justPlayers = allPlayers - entities "HeadlessClient_F";
switchableUnits
playableUnit

 

 

Second thoughts

Is there a way just to call AI units and not player/playable units? for the script.
 

         

Share this post


Link to post
Share on other sites


//just playable units

{[_x] execVM "DAPMAN/init.sqf";} forEach playableUnits;


//just AI

{[_x] execVM "DAPMAN/init.sqf";} forEach allUnits - playableUnits;

  • Like 1

Share this post


Link to post
Share on other sites

Thank you austin_medic 

 

So would I put just this in for all AI units (all sides) that are not playable

{[_x] execVM "DAPMAN/init.sqf";} forEach allUnits - playableUnits;                        // would this call the script for all non playable units in the mission?

 

I would not have to put this is

[AllUnits] execVM "DAPMAN\Init.sqf";                                                                     // This calls All units of all sides editor placed units and spawned units during the game.

Share this post


Link to post
Share on other sites

hasInterface may be a better solution, as isPlayer may sometimes return false on a client machine. It also means that code can be executed on a local server (when the player is a player and server) and ensures code is not executed on headless client.

 

Also, by using the commands for remote execution, you can broadcast a function to execute on specific targets (see remoteExec for more details).

 

Hope that helps,

 

Bull

Share this post


Link to post
Share on other sites

I can't get the it to work not allowing playable units to not USE the script by using this code  {[_x] execVM "DAPMAN/init.sqf";} forEach allUnits - playableUnits//just AI

 

This is the information DAP gave can. Anyone help to get the script to work but not allowing the playable units to use it in the mission.

 

DAPMAN

Current Version 0.2.5

WARNING: this version requires Functions Module (script version included in template).

Conditions for correct work:

- string #include "DAPMAN\RscTitles.hpp" - in RscTitles block (class RscTitles {...};) in Description.ext (Root mission folder)
- string #include "DAPMAN\CfgSounds.hpp" - in CfgSounds block (class CfgSounds {...};) in Description.ext (Root mission folder)

- string [] execVM "ca\Modules\MP\data\scripts\MPFramework.sqf"; - in Init.sqf (Root mission folder)
- string [AllUnits] execVM "DAPMAN\Init.sqf"; - in Init.sqf (Root mission folder)

You can change value "AllUnits" to any units array. Then this script will work only for selected units.
Also you can use this string for new created units during  mission

Example:

_squad = ["B_Soldier_SL_F","B_soldier_AR_F","B_Soldier_LAT_F","B_Soldier_F","B_medic_F"];

_group = createGroup WEST;

_n=0;
_count= (count(_squad));
_spawnpos = getMarkerPos "respawn_west";

_squad select 0 createUnit [_spawnpos, _group,"", 0.45, "LIEUTENANT"];
while {(_n<_count)} do
{
 _n=_n+1;
 _unitType = _squad select _n;
 _unitType createUnit [_spawnpos, _group];
};

[(units _group)] execVM "DAPMAN\Init.sqf"; - this string run script, which assign wound-scripts for new created units.

SPECIAL VARIABLES:

If you want set DAPMAN script only for players, then you need set special global variable:

Example:

DAP_AIFAS_PLAYERSONLY = 1;
PublicVariable "DAP_AIFAS_PLAYERSONLY";

Share this post


Link to post
Share on other sites

{ if !(hasInterface) then {//YOUR CODE};} foreach allunits;

Checks if all units have an interface (Are players or headless), if they are, is returned false and they dont receive the goods.

Untested, but should be close.

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

×