Jump to content

Recommended Posts

Hi guys, I've been steadily producing terrible code and making it less terrible as I go. I'm still having problems recognizing locality of certain commands, and when/who needs to execute the specific code. Thanks for your help, as I continue to produce horrible scripts! :sorry:

What I'm trying to do
1) Players use an addaction to start an event (working)
2) Players are transported into a plane (working)

a) the plane begins to get shot down (crash) (working)
b) some radio chatter (text and sound), and music plays (only working for the player that triggered the action ("player1"))
c) some explosion happens and an engine fire starts (working)
d) the plane is forced downward (working kind of brute force though)
3) Players encounter another explosion at low altitude (working)
a) players are knocked unconscious (only working for "player1")
b) random clutter is spawned based on player count (working)
c) players are stripped of random items and those items are placed in some boxes (half working only player1 loses items)
3) Players awaken to a crash site (working again only player1 was unconscious) 
a) music switch to shorter track (working only for player1)
b) static engine noise plays from the wreck (working for playe1 only)

I have also noticed that for "player1" the events progress linearly through the script, but for the other players that is not necessarily the case. I was poking around and it sounds to be scheduler related, but I'm not quite understanding how to work around that. Ideally all of the events in my script would happen synchronously and in the order they are shown in the script. Any help in pointing me where to go from here is much appreciated, script and description.ext to follow.

description.ext
 

Spoiler

overviewPicture = "plane-1.jpg";
respawnOnStart = -1;
respawn = "BASE";
respawnDelay = 3;
respawnDialog = 0;
overviewText = "Plane Crash Takistan";
author = "COCKHEAVEN";
onLoadName = "Plane Crash Takistan";
loadScreen = "plane-1.jpg";
onLoadMission = "Plane Crash Takistan";


class CfgSounds
{
	sounds[] = {};
	
class TestSound1
{
	sound[] = {"@A3\sounds_f\sfx\radio\ambient_radio8.wss",3,1,100};
	name = "TestSound1";
	titles[] = {};
};
class TestSound2
{
	sound[] = {"@A3\sounds_f\sfx\radio\ambient_radio2.wss",3,1,100};
	name = "TestSound2";
	titles[] = {};
};
class TestSound3
{
	sound[] = {"@A3\sounds_f\sfx\radio\ambient_radio3.wss",3,1,100};
	name = "TestSound3";
	titles[] = {};
};
class TestSound4
{
	sound[] = {"@A3\sounds_f\sfx\radio\ambient_radio2.wss",3,1,100};
	name = "TestSound4";
	titles[] = {};
};
};

 



Crash.sqf
 

Spoiler


//----------------------------Get Players and put them in crashing Plane-------------------//
CK_ENGINE = false;
CK_MyDudes = call BIS_fnc_listPlayers;
_CK_MRKR = [CK_MOMY_1,CK_MOMY_2,CK_MOMY_3,CK_MOMY_4,CK_MOMY_5,CK_MOMY_6] call BIS_fnc_selectRandom; // array of invisible helipads (pre placed)
_CK_MOMPOS = getpos _CK_MRKR;
CK_POS = [_CK_MOMPOS select 0, _CK_MOMPOS select 1, (_CK_MOMPOS select 2) + 900];
CK_Plane = [CK_POS, getdir _CK_MRKR, "CUP_B_C130J_USMC", west] call BIS_fnc_spawnVehicle;

CK_Mother = CK_Plane select 0; // get the plane object
CK_Mother setVelocity [0, (velocity CK_Mother select 1) + 220, (velocity CK_Mother select 2) - 10]; // give it some speed and down
CK_PlaneGroup = CK_Plane select 2; // get pilots
CK_Mother animate ["ramp_top",1,true]; // open ramp
CK_Mother animate ["ramp_bottom",.7,true]; // open ramp
CK_Mother allowDamage false; // saftey third
CK_Mother AllowCrewInImmobile True; // no ejections
CK_Mother engineOn true; // turn it on


CK_PlaneGroup setGroupID ["Eagle"]; // RP is fun



Speakers = [CK_Mother];//array of your speakers
SoundPads = []; // empty for soundpads
{
  pads = createVehicle["Land_HelipadEmpty_F", (getpos _x), [], 0, "CAN_COLLIDE"];
  SoundPads pushback pads;
} forEach Speakers;
{
_x say3d ["TestSound1", 1500, 1];
} foreach SoundPads;// make all of your speakers play the sound

CK_Mother sideChat "Roger Ramsen Air Base, maintain altitude make bearing zero three zero airspeed 180"; //cool RP
{
  _x moveInAny CK_Mother; // players in plane
  _x allowDamage false; // saftey third
  _x setVariable ["ace_map_hideBlueForceMarker", true, true]; // turn off BFT (fingers crossed)
} forEach CK_MyDudes;




uisleep 2;
//-----------------------------------------------------------------------------------------//


//---------------------------------Shoot em down-------------------------------------------//
CK_AAA = [_CK_MOMPOS, random 360, "CUP_O_Ural_ZU23_TKM", east] call BIS_fnc_spawnVehicle; // create AA vehicle

CK_AAA commandSuppressiveFire CK_Mother; // Shoot plane

//-----------------------------------------------------------------------------------------//

//---------------------------------Crash the Plane-----------------------------------------//
_bomb = "APERSTripMine_Wire_Ammo" createVehicle (CK_Mother modelToWorld [-10, 0, -.75]);
_bomb setDamage 1;
CK_Mother setFuel 0;
FireBall = createVehicle ["Land_HelipadEmpty_F", (CK_Mother modelToWorld [-10, 0, -.75]), [], 0, "CAN_COLLIDE"];
FireBall attachTo [CK_Mother, [-10, 0, -.75] ];
Flame = createVehicle ["test_EmptyObjectForFireBig", FireBall, [], 0, "CAN_COLLIDE"];
Flame attachto [FireBall, [0, 0, 0] ];
"LeadTrack03_F_EXP" remoteExec ["playmusic"];;
CK_Mother setVelocity [(velocity CK_Mother select 0), (velocity CK_Mother select 1),(velocity CK_Mother select 2) - 50]; // explode and engine and set on fire, play cool music and send plane down


Speakers = [CK_Mother];//array of your speakers
SoundPads = []; // empty for soundpads
{
  pads = createVehicle["Land_HelipadEmpty_F", (getpos _x), [], 0, "CAN_COLLIDE"];
  SoundPads pushback pads;
} forEach Speakers;
{
_x say3d ["TestSound2", 1500, 1];
} foreach SoundPads;// make all of your speakers play the sound

CK_Mother sideChat "Mayday, Mayday, Mayday. This is Eagle we are under fire and going down.";
uisleep 1.5;
CK_Mother sideChat "Ramsen Air Base, Eagle, we are under fire, engine three is out, engine one on fire, prepare for emergency landing";
uisleep 3; // cool RP
while {getposATL CK_Mother select 2 > 300} do {
CK_Mother setVelocity [0, (velocity CK_Mother select 1) + .075, (velocity CK_Mother select 2) - .05];
CK_AAA doFire CK_Mother;
uisleep 1;
 }; // fly down plz
waituntil {getposATL CK_Mother select 2 < 300};
CK_Mother sideChat "I'm going to have to dump your cargo";

_veh = createVehicle ["CFP_C_AFRCHRISTIAN_SUV_01", [getPos CK_Mother select 0, (getPos CK_Mother select 1) - 25,(getPos CK_Mother select 2)], [], 0, "NONE"];
_veh setdir getdir CK_Mother; // dump a vehicle

[objnull, _veh] call BIS_fnc_curatorobjectedited;
_veh SetVelocity [0,0,0]; // parachute plz

_CK_SMK1 = createVehicle ["SmokeShellpurple", (getpos _veh), [], 0, "CAN_COLLIDE"];    
_CK_SMK1 attachTo [(vehicle _veh), [-0.2,0.0,0.5]];   

_CK_SMK2 = createVehicle ["SmokeShellpurple", (getpos _veh), [], 0, "CAN_COLLIDE"];    
_CK_SMK2 attachTo [(vehicle _veh), [0.2,0.0,0.5]];   

_CK_SMK3 = createVehicle ["SmokeShellpurple", (getpos _veh), [], 0, "CAN_COLLIDE"];    
_CK_SMK3 attachTo [(vehicle _veh), [0.0,0.0,0.5]];  


uisleep 2;

while {getposATL CK_Mother select 2 > 120} do {
CK_Mother setVelocity [0, (velocity CK_Mother select 1) + .15, (velocity CK_Mother select 2) - .025];
CK_AAA doFire CK_Mother;
uisleep 1;
 }; // fly down plz

//-----------------------------------------------------------------------------------------//

_bomb = "APERSTripMine_Wire_Ammo" createVehicle (CK_Mother modelToWorld [-10, -5, -.75]);
_bomb setDamage 1;
{
  _x setVariable ["ACE_isUnconscious", true];
} forEach CK_MyDudes; // go to sleep
waituntil {isTouchingGround CK_Mother};
CK_Mother setVelocity [0, 0, 0]; // do not bounce thanks!
CK_AA1 = CK_AAA select 0;
CK_AA2 = CK_AAA select 2;
deletevehicle CK_AA1;
deletegroup CK_AA2;
//--------------------------------Setup plane wreck----------------------------------------//

uisleep 5;
{
  moveOut _x;
} forEach CK_MyDudes; // get out

{
 _x setDamage 1;
} forEach units CK_PlaneGroup; // pilots did not survive

CK_MPOS = getPosATL CK_Mother;
CK_Dir = getdir CK_Mother;

deleteVehicle CK_Mother; // delete old plane
deleteVehicle Flame; // delete old fire

CK_Wreck = createVehicle ["C130J_static_EP1", [CK_MPOS select 0,CK_MPOS select 1,-.5], [], 0, "CAN_COLLIDE"]; // create new plane
CK_Wreck setdir CK_Dir + 180;
CK_Wreck setVectorUp surfaceNormal position CK_Wreck;
FireBall = createVehicle ["Land_HelipadEmpty_F", (CK_Wreck modelToWorld [10, 0, 3.25]), [], 0, "CAN_COLLIDE"]; 
FireBall attachTo [CK_Wreck, [10, -3, -2] ]; 
Flame = createVehicle ["test_EmptyObjectForFireBig", FireBall, [], 0, "CAN_COLLIDE"];
uisleep 2; // create new fire
"EventTrack02_F_Curator" remoteExec ["playmusic"]; // cool music
CK_Wreck animate ["ramp_top",1,true];
CK_Wreck animate ["ramp_bottom",1,true]; // open ramp
//-----------------------------------------------------------------------------------------//

//--------------------------------Take players items----------------------------------------//

{

  _CK_MAGNUM = selectRandom [1,3,5,9,13];
  _CK_ITEMNUM = selectRandom [3,6,12,16];
  _CK_MAGS = magazines _x;
  _CK_ITEMS = items _x;
  _CK_MAGSL = [];
  _CK_ITMSL = [];
for "_i" from _CK_MAGNUM to 0 step -1 do {

_ThisMag = selectRandom _CK_Mags;
_CK_MAGSL pushBack _Thismag;

};
for "_i" from _CK_ITEMNUM to 0 step -1 do {

_ThisItem = selectRandom _CK_ITEMS;
_CK_ITMSL pushBack _ThisItem;

};

	{
	player removeMagazine _x; 
	} foreach _CK_MAGSL;
	{
	player removeItem _x; 
	} foreach _CK_ITMSL;

_CK_BOX = createVehicle ["CFP_B_USSEALS_WDL_SupportBox", [getpos CK_Wreck select 0, getpos CK_Wreck select 1, 0], [], 8, "NONE"];
_CK_BOX allowDamage false;
clearWeaponCargoGlobal _CK_BOX;
clearMagazineCargoGlobal _CK_BOX;
clearBackpackCargoGlobal _CK_BOX;
clearItemCargoGlobal _CK_BOX;
_CK_BOX setPosATL getPosATL _CK_BOX;
_CK_BOX setVelocity [random 6, random 6, random 6];

	{
	_CK_BOX addMagazineCargoGlobal [_x,1]; 
	} foreach _CK_MAGSL;
	{
	_CK_BOX addItemCargoGlobal [_x,1]; 
	} foreach _CK_ITMSL;

} forEach CK_MyDudes;


//-----------------------------------------------------------------------------------------//
uisleep 2;

//----------------------------Wake up Players----------------------------------------------//
CK_JNK = ["Land_HistoricalPlaneDebris_04_F","Land_HistoricalPlaneDebris_03_F","Land_HistoricalPlaneDebris_02_F","Land_HistoricalPlaneDebris_01_F","Fort_Crate_wood","AmmoCrate_NoInteractive_","Land_PlasticCase_01_large_black_F","Land_PlasticCase_01_large_black_CBRN_F","Land_PlasticCase_01_medium_black_F","Land_PlasticCase_01_medium_black_CBRN_F","Land_PlasticCase_01_small_black_F","Land_PlasticCase_01_small_black_CBRN_F","Land_MetalCase_01_large_F","Land_MetalCase_01_small_F","Land_MetalCase_01_medium_F","Box_B_UAV_06_F","Land_Ammobox_rounds_F","Land_PaperBox_01_open_empty_F","Land_PaperBox_01_small_ransacked_brown_F","Land_PaperBox_01_small_open_brown_IDAP_F","Land_PaperBox_01_small_destroyed_white_IDAP_F","Land_PaperBox_01_small_ransacked_white_IDAP_F","Land_EmergencyBlanket_01_discarded_F","Land_EmergencyBlanket_02_discarded_F","Land_WaterBottle_01_pack_F","Land_FoodSack_01_dmg_brown_F","Land_FoodSack_01_empty_white_idap_F"];
CK_JNKNUM = (count CK_MyDudes) * 3;


for "_i" from CK_JNKNUM to 0 step -1 do {

_ThisJNK = selectRandom CK_JNK;
_CK_JNK = createVehicle [_ThisJNK, CK_Wreck, [], 8, "NONE"];
_CK_JNK setPos [getPos _CK_JNK select 0, getPos _CK_JNK select 1, 0];
_CK_JNK setvelocity [random 6, random 6, random 6];
};
{
	_x setvelocity [0,0,0];
	_x setPosATL getPosATL CK_Wreck;
 	_x setVariable ["ACE_isUnconscious", false];
 	_x allowDamage true;
} forEach CK_MyDudes;


[
	[
		["CRASH SITE; ", "align = 'center' shadow = '1' size = '0.7' font='PuristaBold'"],
		["EAGLE", "align = 'center' shadow = '1' size = '0.7'", "#aaaaaa"],
		["","<br/>"], 
		["MOMENTS LATER...","align = 'center' shadow = '1' size = '1.0'"]
	],-.5,.5
] spawn BIS_fnc_typeText2; // mission critical info

playSound3D ["a3\sounds_f\sfx\radio\ambient_radio3.wss", CK_Wreck, true];
CK_Sound = createSoundSource ["Sound_Fire", getpos Flame, [], 0];
//-----------------------------------------------------------------------------------------//

CK_ENGINE = true; // loop var for engine noise

while {CK_ENGINE} do {
playSound3D ["A3\Sounds_F\sfx\missions\bobcat_engine_start.wss", CK_Wreck, true]; // engine noise
uisleep 3.5;
};

 

 

Edited by Cockheaven
speeling

Share this post


Link to post
Share on other sites

If you want to script for multiplayer, start with some basics.

Pay attention from arguments AND effects of EACH command you're using.

If I'm right, I don't understand why, any players can "addAction" this disaster. The fact is this code will run a local code from this "winner" and all the local effects will stay on his PC. You need to remoteExec:

- all EL commands/functions (you'll know what I mean after reading the link) to make these effects global (say3D is a perfect example)

- but also all AL functions for applying them on the right objects' locality (you run locally a code on the "winner"'s PC, but the object is on server), typically setVelocity you want to apply on plane. This plane is on server if no played pilot, on pilot's PC if pilot (driver) is played.

 

Fortunately some commands don't need that (setPosATL is AG EG so, never mind where you'll fire from, all players get the right behavior).

 

So, you have the guideline. I wouldn't script that from an addAction but somewhere on server as result of a trigger (server only).

 

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Thanks again @pierremgi, I have Everything working except for one section and I'm thinking i need to treat this as a function and remote exec the whole thing. Here's the snip.

 

Spoiler

CK_MyDudes = call BIS_fnc_listPlayers;


{

  	_CK_MAGNUM = selectRandom [1,3,5,9,13];
  	_CK_ITEMNUM = selectRandom [3,6,12,16];
  	_CK_MAGS = magazines _x;
  	_CK_ITEMS = items _x;
  	_CK_MAGSL = [];
  	_CK_ITMSL = [];
		for "_i" from _CK_MAGNUM to 0 step -1 do 
			{

			_ThisMag = selectRandom _CK_Mags;
			_CK_MAGSL pushBack _Thismag;

			};
		for "_i" from _CK_ITEMNUM to 0 step -1 do 
			{

			_ThisItem = selectRandom _CK_ITEMS;
			_CK_ITMSL pushBack _ThisItem;

			};

			{
			player removeMagazineGlobal _x; 
			} foreach _CK_MAGSL;
			{
			player removeitem _x; 
			} foreach _CK_ITMSL;

	_CK_BOX = createVehicle ["CFP_B_USSEALS_WDL_SupportBox", [getpos CK_Wreck select 0, getpos CK_Wreck select 1, 0], [], 8, "NONE"];
	_CK_BOX allowDamage false;
	clearWeaponCargoGlobal _CK_BOX;
	clearMagazineCargoGlobal _CK_BOX;
	clearBackpackCargoGlobal _CK_BOX;
	clearItemCargoGlobal _CK_BOX;
	_CK_BOX setPosATL getPosATL _CK_BOX;
	_CK_BOX setVelocity [random 6, random 6, random 6];

		{
		_CK_BOX addMagazineCargoGlobal [_x,1];
		} foreach _CK_MAGSL;

		{
		_CK_BOX addItemCargoGlobal [_x,1]; 
		} foreach _CK_ITMSL;

} forEach CK_MyDudes;

 

So If I'm understanding correctly, what's happening is the outside foreach is running on the server, and it runs once per player. However since it runs on the server the nested foreach containing "removeMagazineGlobal" doesn't run on the player that the outside foreach is run on, how do I accomplish this, Can i define _X = _CK_CurrentPlayer and pass that to the nested foreach, well that's what I'm going to try. Otherwise i was thinking that I make this a function and run the function on each client? But IDK how to do that, at least how to pass params etc...

Share this post


Link to post
Share on other sites

Okay, so i spent some time trying a few things but no success. 

First up I created a function, or I thought I did....
initserver.sqf
 

Spoiler

fnc_CK_STRIP = {
  	_CK_MAGNUM = selectRandom [1,3,5,9,13];
  	_CK_ITEMNUM = selectRandom [3,6,12,16];
  	_CK_MAGS = magazines player;
  	_CK_ITEMS = items player;
  	_CK_MAGSL = [];
  	_CK_ITMSL = [];
		for "_i" from _CK_MAGNUM to 0 step -1 do 
			{

			_ThisMag = selectRandom _CK_Mags;
			_CK_MAGSL pushBack _Thismag;

			};
		for "_i" from _CK_ITEMNUM to 0 step -1 do 
			{

			_ThisItem = selectRandom _CK_ITEMS;
			_CK_ITMSL pushBack _ThisItem;

			};

			{
			player removeMagazineGlobal _x; 
			} foreach _CK_MAGSL;
			{
			player removeitem _x; 
			} foreach _CK_ITMSL;

	_CK_BOX = createVehicle ["CFP_B_USSEALS_WDL_SupportBox", [getpos CK_Wreck select 0, getpos CK_Wreck select 1, 0], [], 8, "NONE"];
	_CK_BOX allowDamage false;
	clearWeaponCargoGlobal _CK_BOX;
	clearMagazineCargoGlobal _CK_BOX;
	clearBackpackCargoGlobal _CK_BOX;
	clearItemCargoGlobal _CK_BOX;
	_CK_BOX setPosATL getPosATL _CK_BOX;
	_CK_BOX setVelocity [random 6, random 6, random 6];

		{
		_CK_BOX addMagazineCargoGlobal [_x,1];
		} foreach _CK_MAGSL;

		{
		_CK_BOX addItemCargoGlobal [_x,1]; 
		} foreach _CK_ITMSL;
};

 

then somewhere in the events chain

remotexec ["fnc_CK_STRIP",0];

didn't work, so i tried 

remotexeccall ["fnc_CK_STRIP",0];

didn't work either...

Second thing I tried was putting it in a script and calling the script

CK_STRIP.sqf
 

Spoiler

      _CK_MAGNUM = selectRandom [1,3,5,9,13];
      _CK_ITEMNUM = selectRandom [3,6,12,16];
      _CK_MAGS = magazines player;
      _CK_ITEMS = items player;
      _CK_MAGSL = [];
      _CK_ITMSL = [];
        for "_i" from _CK_MAGNUM to 0 step -1 do 
            {

            _ThisMag = selectRandom _CK_Mags;
            _CK_MAGSL pushBack _Thismag;

            };
        for "_i" from _CK_ITEMNUM to 0 step -1 do 
            {

            _ThisItem = selectRandom _CK_ITEMS;
            _CK_ITMSL pushBack _ThisItem;

            };

            {
            player removeMagazineGlobal _x; 
            } foreach _CK_MAGSL;
            {
            player removeitem _x; 
            } foreach _CK_ITMSL;

    _CK_BOX = createVehicle ["CFP_B_USSEALS_WDL_SupportBox", [getpos CK_Wreck select 0, getpos CK_Wreck select 1, 0], [], 8, "NONE"];
    _CK_BOX allowDamage false;
    clearWeaponCargoGlobal _CK_BOX;
    clearMagazineCargoGlobal _CK_BOX;
    clearBackpackCargoGlobal _CK_BOX;
    clearItemCargoGlobal _CK_BOX;
    _CK_BOX setPosATL getPosATL _CK_BOX;
    _CK_BOX setVelocity [random 6, random 6, random 6];

        {
        _CK_BOX addMagazineCargoGlobal [_x,1];
        } foreach _CK_MAGSL;

        {
        _CK_BOX addItemCargoGlobal [_x,1]; 
        } foreach _CK_ITMSL;


  	_CK_MAGNUM = selectRandom [1,3,5,9,13];
  	_CK_ITEMNUM = selectRandom [3,6,12,16];
  	_CK_MAGS = magazines player;
  	_CK_ITEMS = items player;
  	_CK_MAGSL = [];
  	_CK_ITMSL = [];
		for "_i" from _CK_MAGNUM to 0 step -1 do 
			{

			_ThisMag = selectRandom _CK_Mags;
			_CK_MAGSL pushBack _Thismag;

			};
		for "_i" from _CK_ITEMNUM to 0 step -1 do 
			{

			_ThisItem = selectRandom _CK_ITEMS;
			_CK_ITMSL pushBack _ThisItem;

			};

			{
			player removeMagazineGlobal _x; 
			} foreach _CK_MAGSL;
			{
			player removeitem _x; 
			} foreach _CK_ITMSL;

	_CK_BOX = createVehicle ["CFP_B_USSEALS_WDL_SupportBox", [getpos CK_Wreck select 0, getpos CK_Wreck select 1, 0], [], 8, "NONE"];
	_CK_BOX allowDamage false;
	clearWeaponCargoGlobal _CK_BOX;
	clearMagazineCargoGlobal _CK_BOX;
	clearBackpackCargoGlobal _CK_BOX;
	clearItemCargoGlobal _CK_BOX;
	_CK_BOX setPosATL getPosATL _CK_BOX;
	_CK_BOX setVelocity [random 6, random 6, random 6];

		{
		_CK_BOX addMagazineCargoGlobal [_x,1];
		} foreach _CK_MAGSL;

		{
		_CK_BOX addItemCargoGlobal [_x,1]; 
		} foreach _CK_ITMSL;

 

then somewhere in the events chain

remotexec ["CK_STRIP.sqf",0];

didn't work, so i tried 

remotexeccall ["CK_STRIP.sqf",0];

didn't work either...

So I was rolling on this train of finally getting locality, and now I've run into a locality blockade... I can run that code locally via debug console and it does what I want it to do. What method am I supposed to use to accomplish this? That code needs to run on each client, I thought remotexec did that, am i using it wrong, is there some other syntax/command to use?
 

Share this post


Link to post
Share on other sites

Consider the server as a good place to spawn AIs, and trigger "events" (wide meaning). So, all local objects (edited crates, vehicles (AI manned or empty, AIs) are managed here. On the other hand, players are local on their PC, but also their subordinates and driven vehicle... I gave you the link for that. Locality can change along with the status (the owner) of the AIs/vehicles...

The addAction always run a code on the "caller" PC, so, this is a good reason to remoteExec on the right place some code for a remote player/AI/object, or for sharing a result of this code.

So, you need to ever pay attention for SYNTAX command AND ARGUMENTS locality AND EFFECTS locality.

BI created, for simplification, some global commands like addItemCargoGlobal. This command (AG EG) is supposed to run from a PC (server or client,) but should never be remoteExecuted everywhere! It's global.

As rule of thumb:

* AG EG  never remoteExec, run as is,

* SE  run it on server only (remoteExec to 2 if necessary)

* AL EG run it on the right place (where local is. i.e. the command must apply to a local object), or remoteExec it on the right place

* AG EL will run fine locally, but you can broadcast it with a remoteExecution and choose the clients. (0 = everywhere: server + clients)

* AL EL  double pay attention for locality of argument and broadcast if needed.

 

Don't mix forEach and locality. forEach is a tool to avoid repeating inner code. That's all.

So, if you want to apply a loadout at start, whatever the unit is played or not, the initServer.sqf is fine. Use the global commands, remoteExec those who are not EG, and do not remoteExec your whole function!

 

Share this post


Link to post
Share on other sites

Here is how I would do it, in conceptual pseudo code:

 

On server:

 

Main script. Does everything it can, and calls out ”events” for stuff that need to be handled locally, for clients to ”listen” to.

 

If AI is piloting the plane in its own group then the plane is probably local to the server (let’s assume that).

 




	TakeOff;



	PlaneTakesHitAndStalls;



	SendEvent(OnPlaneStallBegin);



	EngineExplosion;



	PlaneLoosesHeight;



	PlayAnotherExplosion;



	SendEvent(OnSecondExplosion);



	[/CODE]


 

On client(s):

 



	Function OnPlaneStallBegin {


	    Play radio chattering;


	}


	 


	Function OnSecondExplosion {


	    Make player unconcious;


	    RandomClutter;


	    StripOfItems;


	    AllThatRemains;


	}


	[/CODE]


 

With this ”architecture” you solve all issues with timings and keeps concerns apart. I.e. the server will do its thing, and the clients align, and the code will be relatively easy to maintain.

 

EDIT: Sorry for the formatting. I don’t know why it happens - but it’s when I use my smart phone.

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

×