Jump to content
Sign in to follow this  
jakerod

Init line vs Trigger

Recommended Posts

I have the following in a radio trigger. I realize it is messy but it is a temporary measure until I get the rest of the script sorted out:

waitUntil { !isNil "BIS_fnc_init_1" }; nul = [h8,0,0,1,1] execVM "spawn_h_8.sqf"; nul = [h8_1,0,0,1,1] execVM "spawn_h_8.sqf"; nul = [h8_2,0,0,1,1] execVM "spawn_h_8.sqf"; nul = [h8_3,0,0,1,1] execVM "spawn_h_8.sqf"; nul = [h8,0,0,1,1] execVM "spawn_h_8.sqf"; nul = [h8_1,0,0,1,1] execVM "spawn_h_8.sqf"; nul = [h8_2,0,0,1,1] execVM "spawn_h_8.sqf"; nul = [h8_3,0,0,1,1] execVM "spawn_h_8.sqf"; nul = [h1,0,0,1,1] execVM "spawn_h_1.sqf"; nul = [h1_1,0,0,1,1] execVM "spawn_h_1.sqf"; nul = [h1_2,0,0,1,1] execVM "spawn_h_1.sqf"; nul = [h1_3,0,0,1,1] execVM "spawn_h_1.sqf"; nul = [h1_4,0,0,1,1] execVM "spawn_h_1.sqf"; nul = [h1_5,0,0,1,1] execVM "spawn_h_1.sqf"; nul = [h1_6,0,0,1,1] execVM "spawn_h_1.sqf"; nul = [h7,0,0,1,1] execVM "spawn_h_7.sqf"; nul = [h7_1,0,0,1,1] execVM "spawn_h_7.sqf"; nul = [h3,0,0,1,1] execVM "spawn_h_3.sqf"; nul = [h3_1,0,0,1,1] execVM "spawn_h_3.sqf"; nul = [h3_2,0,0,1,1] execVM "spawn_h_3.sqf";

Essentially each one of those scripts puts guys into a different house. Each one of those scripts looks almost exactly like the following only the variables are different and the positions:

_buildingMark = _this select 0; ///Marker near the Building that Men are Going into
_percentBuildGar = _this select 1; ///Percent of Buildings spawned with men
_percentPosGar = _this select 2; ///Percent of Total Men in Building Spawned
_minSkillRange = _this select 3; ///Lowest Skill of Units
_maxSkillRange = _this select 4; ///Highest Skill of Units

_buildingGar = nearestbuilding _buildingMark;

///Start of House Library

///House_L_1
_H_L_1_pos_00_A = [0.871826,-1.55762,-0.616486];
_H_L_1_pos_01_A =  [-0.468628,-1.91333,-0.610672];
_H_L_1_pos_02_A =  [-0.265747,0.536377,-0.597946];
_H_L_1_pos_00 = _buildingGar modelToWorld _H_L_1_pos_00_A;
_H_L_1_pos_01 = _buildingGar modelToWorld _H_L_1_pos_01_A;
_H_L_1_pos_02 = _buildingGar modelToWorld _H_L_1_pos_02_A;
///Squad for House L_1 
///3 Positions
_L1SquadUnits = ["TK_INS_Soldier_TL_EP1","TK_INS_Soldier_3_EP1","TK_INS_Soldier_4_EP1"];
_L1SquadSkill = [_minSkillRange,_maxSkillRange];
_L1_squad = [getMarkerPos "Squad1", east, _L1SquadUnits, [], [], _L1SquadSkill] call BIS_fnc_spawnGroup;

sleep .5;

{dostop _x} foreach units _L1_squad;
{_x enableattack false} forEach units _L1_squad;
_L1_squad_members = units _L1_squad;

sleep .5;

_L1_squad_mem_00 = _L1_squad_members select 0; 
_L1_squad_mem_01 = _L1_squad_members select 1; 
_L1_squad_mem_02 = _L1_squad_members select 2;
_L1_squad_mem_00 setPosATL _H_L_1_pos_00;
_L1_squad_mem_01 setPosATL _H_L_1_pos_01; 
_L1_squad_mem_02 setPosATL _H_L_1_pos_02;
_L1_squad_mem_00 setunitpos "Up";
_L1_squad_mem_01 setunitpos "Up"; 
_L1_squad_mem_02 setunitpos "Up";

The problem that I am having is that when I have the code in a trigger it creates double the men then I need when I play LAN with my brother (with me hosting). I read that a trigger gets made on each machine so I am assuming it spawns units from both triggers and that is why they get doubled up. So I tried putting the top most code with all the scripts into the init line of a gamelogic instead hoping that it wouldn't double spawn them. No units spawn. No error but no units spawn. Any ideas on how to get around this?

Share this post


Link to post
Share on other sites
Put all the code in the trigger inside

if (isServer) then {};

Thanks I added that in and I will try it out tomorrow. Additionally, I noticed that a few of the scripts run twice on one of the types of houses but when we played the other night it was all the houses so I must have screwed that up when I was trying to find out a reason why. That has been fixed though so between that and your solution I should be good.

If I wanted something to only run on the client side it would be

if (!isServer then {}; correct?

Share this post


Link to post
Share on other sites
if !(isServer) then {};

:)

Thank you. I was at least close.

Would it be better for me to put the whole if (isServer) then {} thing into the script itself instead of the trigger that activates it?

Share this post


Link to post
Share on other sites

You can also just add isServer (or !isServer) to the condition field of the trigger, which is probably the easiest and cleanest way to do it.

Share this post


Link to post
Share on other sites
You can also just add isServer (or !isServer) to the condition field of the trigger, which is probably the easiest and cleanest way to do it.

Okay thanks!

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  

×