OFPEC Forum
Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting Multiplayer => Topic started by: ArMaTeC on 04 Mar 2008, 14:30:43
-
Hi all
Ok im currently working hard on the A&B Predator mod and im hitting a wall when trying to get the random tail numbers synchronization in MP below is my current code and my question is how can i make this work in mp with out causeing to much network lag.
_thisuav = _this select 0;
_check = _thisuav getVariable "armatuavnumber1";
if ( !isnil ( "_check" ) ) then
{
_thisuav setobjecttexture [ 0, format [ "\ArMaT_Predator\char\numbers\%1.paa", _thisuav getVariable "armatuavnumber1" ] ];
_thisuav setobjecttexture [ 1, format [ "\ArMaT_Predator\char\numbers\%1.paa", _thisuav getVariable "armatuavnumber2" ] ];
_thisuav setobjecttexture [ 2, format [ "\ArMaT_Predator\char\numbers\%1.paa", _thisuav getVariable "armatuavnumber3" ] ];
_thisuav setobjecttexture [ 3, format [ "\ArMaT_Predator\char\numbers\%1.paa", _thisuav getVariable "armatuavnumber4" ] ];
_thisuav setobjecttexture [ 4, format [ "\ArMaT_Predator\char\numbers\%1.paa", _thisuav getVariable "armatuavnumber5" ] ];
_thisuav setobjecttexture [ 6, format [ "\ArMaT_Predator\char\numbers\%1.paa", _thisuav getVariable "armatuavnumber6" ] ];
_thisuav setobjecttexture [ 7, format [ "\ArMaT_Predator\char\numbers\%1.paa", _thisuav getVariable "armatuavnumber7" ] ];
_thisuav setobjecttexture [ 8, format [ "\ArMaT_Predator\char\letters\%1.paa", _thisuav getVariable "armatuavletter1" ] ];
_thisuav setobjecttexture [ 9, format [ "\ArMaT_Predator\char\letters\%1.paa", _thisuav getVariable "armatuavletter2" ] ];
_thisuav setobjecttexture [ 10, format [ "\ArMaT_Predator\char\letters\%1.paa", _thisuav getVariable "armatuavletter3" ] ];
_thisuav setobjecttexture [ 11, format [ "\ArMaT_Predator\char\letters\%1.paa", _thisuav getVariable "armatuavletter4" ] ];
_thisuav setobjecttexture [ 12, format [ "\ArMaT_Predator\char\letters\%1.paa", _thisuav getVariable "armatuavletter5" ] ];
_thisuav setobjecttexture [ 13, format [ "\ArMaT_Predator\char\letters\%1.paa", _thisuav getVariable "armatuavletter6" ] ];
}else
{
_numberarraynum = [ 0, 1, 2, 3, 4, 5, 6, 7 ];
_letterarraynum = [ 8, 9, 10, 11, 12, 13 ];
_numbers = [ "00", "01", "02", "03", "04", "05", "06", "07", "08", "09" ];
_alphabet = [ "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" ];
_numcount = count _numbers;
_count = 0;
_alphacount = count _alphabet;
{
_randomselect = _numbers select round( random( _numcount ) );
if ( !( format[ "%1", _randomselect ] in _numbers ) ) then
{
_randomselect = "00";
};
_thisuav setobjecttexture [ _x, format [ "\ArMaT_Predator\char\numbers\%1.paa", _randomselect ] ];
_count = _count + 1;
_thisuav setVariable [ format [ "armatuavnumber%1", _count ], _randomselect ];
sleep 0.5;
}
foreach _numberarraynum;
_count = 0;
{
_randomselect = _alphabet select round ( random( _alphacount ) );
if ( !( format[ "%1", _randomselect ] in _alphabet ) ) then
{
_randomselect = "a";
};
_thisuav setobjecttexture [ _x, format [ "\ArMaT_Predator\char\letters\%1.paa", _randomselect ] ];
_count = _count + 1;
_thisuav setVariable [ format [ "armatuavletter%1", _count ], _randomselect ];
sleep 0.5;
}
foreach _letterarraynum;
};
-
Mandoble has solved the issue of making sure variables set on an object for player A is sync'd with player B, C and D. He has used this solution in his MMA v2.2 release.
Study mando_missilereload.sqf which does some publicVariables.
Also study mando_vehvars.sqf which is running on all nodes to sync the variables with all the player nodes. That piece of code is a valuable GEM. Royalty.
ViperMaul
-
ok thanks looked at mando's code and had a thougth that i migth as well just use the 1.09 addition of publicVariable useing an array as its the same thing just alot less code with the same networktraffic only issue is that this will limmit the number of UAV's that can be used.
This is not an issue as i built the script to run only with 2 UAV's (RUS/US).
_thisuav = _this select 0;
if ( !isnil ( "armatuavnumberus" ) )
then
{
_eliment = 0;
{
_thisuav setobjecttexture [ ((armatuavnumberus select _eliment) select 0), format [ "\ArMaT_Predator\char\numbers\%1.paa", ((armatuavnumberus select _eliment) select 1) ] ];
_eliment = _eliment+1;
sleep 0.01;
}
foreach armatuavnumberus;
_eliment = 0;
{
_thisuav setobjecttexture [ ((armatuavletterus select _eliment) select 0), format [ "\ArMaT_Predator\char\letters\%1.paa", ((armatuavletterus select _eliment) select 1) ] ];
_eliment = _eliment+1;
sleep 0.01;
}
foreach armatuavletterus;
}else
{
armatuavnumberus = [];
armatuavletterus = [];
_numberarraynum = [ 0, 1, 2, 3, 4, 5, 6, 7 ];
_letterarraynum = [ 8, 9, 10, 11, 12, 13 ];
_numbers = [ "00", "01", "02", "03", "04", "05", "06", "07", "08", "09" ];
_alphabet = [ "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" ];
_numcount = count _numbers;
_count = 0;
_alphacount = count _alphabet;
{
_randomselect = _numbers select round( random( _numcount ) );
if ( !( format[ "%1", _randomselect ] in _numbers ) )
then
{
_randomselect = "00";
};
_thisuav setobjecttexture [ _x, format [ "\ArMaT_Predator\char\numbers\%1.paa", _randomselect ] ];
_count = _count + 1;
armatuavnumberus = armatuavnumberus+[[_count-1,_randomselect]];
sleep 0.01;
}
foreach _numberarraynum;
_count = 0;
{
_randomselect = _alphabet select round ( random( _alphacount ) );
if ( !( format[ "%1", _randomselect ] in _alphabet ) )
then
{
_randomselect = "a";
};
_thisuav setobjecttexture [ _x, format [ "\ArMaT_Predator\char\letters\%1.paa", _randomselect ] ];
_count = _count + 1;
armatuavletterus = armatuavletterus+[[8+_count-1,_randomselect]];
sleep 0.1;
}
foreach _letterarraynum;
};
player sidechat format["Number: %1",armatuavnumberus];
player sidechat format["Letters: %1",armatuavletterus];
publicVariable "armatuavnumberus";
publicVariable "armatuavletterus";
The work continues