summaryrefslogtreecommitdiffstats
path: root/Server/Functions/Server_CreateTeam.sqf
diff options
context:
space:
mode:
authorhybrid <hybrid@hybridlabs.pro>2026-06-11 19:38:09 +0300
committerhybrid <hybrid@hybridlabs.pro>2026-06-11 19:38:09 +0300
commita3a91d4f45b22fd487ecbc954ad979be5d03efdd (patch)
treea554ab159a347dcd6c00ca1c7c26c1ec3ac0a6bd /Server/Functions/Server_CreateTeam.sqf
downloada2wf_chernarus-main.tar.gz
a2wf_chernarus-main.tar.bz2
a2wf_chernarus-main.zip
Diffstat (limited to '')
-rw-r--r--Server/Functions/Server_CreateTeam.sqf47
1 files changed, 47 insertions, 0 deletions
diff --git a/Server/Functions/Server_CreateTeam.sqf b/Server/Functions/Server_CreateTeam.sqf
new file mode 100644
index 0000000..83f9151
--- /dev/null
+++ b/Server/Functions/Server_CreateTeam.sqf
@@ -0,0 +1,47 @@
+Private ['_canCreate','_commander','_crews','_ctype','_driver','_firstDone','_gunner','_list','_lockVehicles','_position','_probability','_side','_team','_type','_unit','_units','_vehicle','_vehicles'];
+
+_list = _this select 0;
+_position = _this select 1;
+_side = _this select 2;
+_lockVehicles = _this select 3;
+_team = _this select 4;
+_probability = if (count _this > 5) then {_this select 5} else {-1};
+_units = [];
+_vehicles = [];
+_crews = [];
+_firstDone = false;
+
+//--- Create a group if none are given as a parameter.
+if (isNull _team) then {_team = createGroup _side};
+
+_ctype = switch (_side) do {case West: {'WEST'}; case East: {'EAST'}; case Resistance: {'GUER'}; case Civilian: {'CIV'}};
+
+//--- Create.
+{
+ _canCreate = true;
+ if (_probability != -1) then {
+ if (random 100 > _probability && _firstDone) then {_canCreate = false};
+ _firstDone = true;
+ };
+
+ if (_canCreate) then {
+ if (_x isKindOf 'Man') then {
+ _unit = [_x,_team,_position,_side] Call CreateMan;
+ _units = _units + [_unit];
+ } else {
+ _vehicle = [_x,_position,_side,_lockVehicles] Call CreateVehi;
+ _type = if (_vehicle isKindOf 'Man') then {Format ['WFBE_%1SOLDIER',_ctype] Call GetNamespace} else {if (_vehicle isKindOf 'Air') then {Format ['WFBE_%1PILOT',_ctype] Call GetNamespace} else {Format ['WFBE_%1CREW',_ctype] Call GetNamespace}};
+ if (_vehicle emptyPositions 'driver' > 0) then {_driver = [_type,_team,_position,_side] Call CreateMan;_driver moveInDriver _vehicle;_crews = _crews + [_driver]};
+ if (_vehicle emptyPositions 'gunner' > 0) then {_gunner = [_type,_team,_position,_side] Call CreateMan;_gunner moveInGunner _vehicle;_crews = _crews + [_gunner]};
+ if (_vehicle emptyPositions 'commander' > 0) then {_commander = [_type,_team,_position,_side] Call CreateMan;_commander moveInCommander _vehicle;_crews = _crews + [_commander]};
+ _vehicles = _vehicles + [_vehicle];
+ };
+ };
+} forEach _list;
+
+//--- Add vehicles.
+{
+ _team addVehicle _x;
+} forEach _vehicles;
+
+[_units,_vehicles,_team,_crews] \ No newline at end of file