thefinn 3 Posted November 17, 2014 I've been playing around with loadouts for co-op for a week or more now. Obviously, just adding weapons and magazines globally doesn't work "out of the box". What I'd like to know is .. exactly how this is supposed to work - the difference between server-side addweapon and client-side addweapon and what this MEANS in-game. I'd rather know how to fish, than be given a fish in this case, ok ? Trying to piece together how client side vs server side works with ARMA through reading scripts is not really cutting it. As far as code is concerned: Reveal hidden contents if (isServer) then { ...stuff... { if (_x=="this") then { _mags = getArray(configfile >> "cfgWeapons" >> (_weapon) >> "magazines"); { _a = 0; while {_a =_a + 1; _a < 10} do { _unit addMagazineglobal _x; }; } forEach [_mags select 0]; } else { _mags = getArray(configfile >> "cfgWeapons" >> (_weapon) >> _x >> "magazines"); { _b = 0; while {_b =_b + 1; _b < 10} do { _unit addMagazineglobal _x; }; } forEach [_mags select 0]; }; } forEach _muzzles; _x addWeaponGlobal _weapon; } foreach _units; } Now after doing this, I am getting a bunch of the correct magazines, but no gun. The AI on the other hand is getting the guns, but no magazines! :) I feel like I'm close... but... Share this post Link to post Share on other sites
jshock 513 Posted November 17, 2014 (edited) If anyone would like to take a look at the whole script, click on "Redressing Script", in my signature. And also mind that I haven't updated that script in probably 6 months, and I've learned a lot since then. Edited November 17, 2014 by JShock Share this post Link to post Share on other sites
thefinn 3 Posted November 17, 2014 (edited) Yeah I changed that a little bit, adding the while loop to deal with addmagazineglobal (which won't add a number of magazines, just one at a time). Here's the whole script. I've fixed all ammo issues, however, under no circumstances will the player himself be issued a weapon other than the default (for whatever reason). Reveal hidden contents _shouldhalo = false; _units = [WEST] call fnc_RedressExclusion; // ^ Choose your faction to redress. _special = (_this select 0); _grenade = (_this select 1); _amount = (_this select 2); _smkgrenade = (_this select 3); _amounts = (_this select 4); _ATunits = []; _Medunits = []; _AAunits = []; _backpackarr = ["B_FieldPack_blk"]; // ^-- Fill this with all the classnames of backpacks you would like to have chosen. _weaponarr = ["SMG_01_Holo_pointer_snds_F"]; // ^-- Fill this with the weapon classnames you would like to use. _uniformarr = ["U_IG_Guerilla2_1"]; // ^-- Fill this with the uniform classnames you would like to use. _headarr = ["H_Watchcap_blk"]; // ^-- Fill this with the headgear classnames you would like to use. _vestarr = ["V_PlateCarrier1_blk"]; // ^-- Fill this with the vest classnames you would like to use. _gogglearr = ["G_Balaclava_blk"]; // ^-- Fill this with the goggle classnames you would like to use. { if ((typeOf _x == "O_Soldier_AT_F") || (typeOf _x == "I_Soldier_AT_F") || (typeOf _x == "B_Soldier_AT_F")) then { _ATunits set [count _ATunits, _x];}; if ((typeOf _x == "O_medic_F") || (typeOf _x == "I_medic_F") || (typeOf _x == "B_medic_F")) then { _Medunits set [count _Medunits, _x];}; if ((typeOf _x == "O_Soldier_AA_F") || (typeOf _x == "I_Soldier_AA_F") || (typeOf _x == "B_Soldier_AA_F")) then { _AAunits set [count _AAunits, _x];}; } foreach _units; //The redressing process... if (isServer) then { { _uniform = _uniformarr call BIS_fnc_selectRandom; _weapon = _weaponarr call BIS_fnc_selectRandom; _backpack = _backpackarr call BIS_fnc_selectRandom; _head = _headarr call BIS_fnc_selectRandom; _vest = _vestarr call BIS_fnc_selectRandom; _goggle = _gogglearr call BIS_fnc_selectRandom; _muzzles = getArray(configfile >> "cfgWeapons" >> (_weapon) >> "muzzles"); _unit = _x; _x unassignItem "NVGoggles_OPFOR"; _x unassignItem "NVGoggles"; _x unassignItem "NVGoggles_INDEP"; clearItemCargo _x; clearWeaponCargo _x; clearMagazineCargo _x; removeallWeapons _x; removeAllHandgunItems _x; removeHeadgear _x; removeGoggles _x; removeUniform _x; removeBackpack _x; _x forceaddUniform _uniform; _x addBackpackglobal _backpack; _x addHeadgear _head; _x addVest _vest; _x addGoggles _goggle; _x addMagazines [_grenade, _amount]; _x addMagazines [_smkgrenade, _amounts]; _x additem "NVGoggles_OPFOR"; _x assignitem "NVGoggles_OPFOR"; _x action["NVGoggles_OPFOR", _x]; { if (_x=="this") then { _mags = getArray(configfile >> "cfgWeapons" >> (_weapon) >> "magazines"); { _a = 0; while {_a =_a + 1; _a < 10} do { if (isplayer _unit) then { _unit addMagazineglobal _x; } else { _unit addMagazine [_x, 1]; }; }; } forEach [_mags select 0]; } else { _mags = getArray(configfile >> "cfgWeapons" >> (_weapon) >> _x >> "magazines"); { _b = 0; while {_b =_b + 1; _b < 10} do { if (isplayer _unit) then { _unit addMagazineglobal _x; } else { _unit addMagazine [_x, 1]; }; }; } forEach [_mags select 0]; }; } forEach _muzzles; if (isplayer _x) then { _x addweaponGlobal _weapon; } else { _x addweapon _weapon; }; } foreach _units; if (_special) then { { _x addWeapon "launch_RPG32_F"; _x addMagazine ["RPG32_HE_F", 2]; } foreach _ATunits; { clearAllItemsFromBackpack _x; _x addItemToBackpack "Medikit"; _x addItemToBackpack "FirstAidKit"; _x addItemToBackpack "FirstAidKit"; _x addItemToBackpack "FirstAidKit"; } foreach _Medunits; { _x addWeapon "launch_Titan_F"; _x addMagazine ["Titan_AA", 2]; } foreach _AAunits; }; if (_shouldhalo) then { { //Parameters private ["_unit","_altitude","_chemLight","_autoOpen","_saveLoadOut"]; _unit = _x; _altitude = 2000; _chemLight = false; _autoOpen = true; _saveLoadOut = true; //Validate parameters if (isNull _unit) exitWith {"Unit parameter must not be objNull. Accepted: OBJECT" call BIS_fnc_error}; if (_altitude < 500) exitWith {"Altitude is too low for HALO. Accepted: 500 and greater." call BIS_fnc_error}; //create a log entry ["HALO function has started"] call BIS_fnc_log; //add immersion effects and sound if (isPlayer _unit) then { cutText ["", "BLACK FADED",999]; [_unit] spawn { private "_unit"; _unit = _this select 0; sleep 2; "dynamicBlur" ppEffectEnable true; "dynamicBlur" ppEffectAdjust [6]; "dynamicBlur" ppEffectCommit 0; "dynamicBlur" ppEffectAdjust [0.0]; "dynamicBlur" ppEffectCommit 5; cutText ["", "BLACK IN", 5]; private "_heliNear"; _heliNear = nearestObjects [_unit, ["helicopter"], 50]; /* if (count _heliNear == 0) then {playSound "C130_exit"}; */ while {animationState _unit != "para_pilot" && alive _unit} do { playSound "flapping"; //play flapping sound sleep 4.2; }; }; }; //add a chemlight to helmet if (_chemLight) then { [_chemLight,_unit] spawn { private ["_chemlight","_unit","_light"]; _chemLight = _this select 0; _unit = _this select 1; _light = "chemlight_red" createVehicle [0,0,0]; //create the chemlight if (headgear _unit != "") then { _light attachTo [_unit,[-0.07,0.1,0.25],"head"]; //attach light to helmet _light setVectorDirAndUp [[0,1,-1],[0,1,0.6]]; //set vector dir and up } else { _light attachTo [_unit,[0,-0.07,0.06],"LeftShoulder"]; }; waitUntil {animationState _unit == "para_pilot"}; if (headgear _unit != "") then { _light attachTo [vehicle _unit,[0,0.14,0.84],"head"]; _light setVectorDirAndUp [[0,1,-1],[0,1,0.6]]; } else { _light attachTo [vehicle _unit,[-0.13,-0.09,0.56],"LeftShoulder"]; _light setVectorDirAndUp [[0,0,1],[0,1,0]]; }; waitUntil {isTouchingGround _unit || (getPos _unit select 2) < 1}; detach _light; deleteVehicle _light; //delete the chemlight }; }; //save the backpack and its contents, also adds fake pack to front of unit if (_saveLoadOut && !isNull (unitBackpack _unit) && (backpack _unit) != "b_parachute") then { private ["_pack","_class","_magazines","_weapons","_items","_helmet"]; _pack = unitBackpack _unit; _class = typeOf _pack; _magazines = getMagazineCargo _pack; _weapons = getWeaponCargo _pack; _items = getItemCargo _pack; _helmet = headgear _unit; removeBackpack _unit; //remove the backpack _unit addBackpack "b_parachute"; //add the parachute [_unit,_class,_magazines,_weapons,_items,_helmet,_altitude] spawn { private ["_unit","_class","_magazines","_weapons","_items","_helmet","_altitude"]; _unit = _this select 0; _class = _this select 1; _magazines = _this select 2; _weapons = _this select 3; _items = _this select 4; _helmet = _this select 5; _altitude = _this select 6; private "_packHolder"; _packHolder = createVehicle ["groundWeaponHolder", [0,0,0], [], 0, "can_collide"]; _packHolder addBackpackCargoGlobal [_class, 1]; waitUntil {animationState _unit == "HaloFreeFall_non"}; _packHolder attachTo [_unit,[-0.12,-0.02,-.74],"pelvis"]; _packHolder setVectorDirAndUp [[0,-1,-0.05],[0,0,-1]]; waitUntil {animationState _unit == "para_pilot"}; _packHolder attachTo [vehicle _unit,[-0.07,0.67,-0.13],"pelvis"]; _packHolder setVectorDirAndUp [[0,-0.2,-1],[0,1,0]]; waitUntil {isTouchingGround _unit || (getPos _unit select 2) < 1}; detach _packHolder; deleteVehicle _packHolder; //delete the backpack in front _unit addBackpack _class; //return the backpack clearAllItemsFromBackpack _unit; //clear all gear from new backpack if (_altitude > 3040 && _helmet != "" && _helmet != "H_CrewHelmetHeli_B") then {(unitBackpack _unit) addItemCargoGlobal [_helmet, 1]}; //(not complete) do a check to see if there is available space for "_i" from 0 to (count (_magazines select 0) - 1) do { (unitBackpack _unit) addMagazineCargoGlobal [(_magazines select 0) select _i,(_magazines select 1) select _i]; //return the magazines }; for "_i" from 0 to (count (_weapons select 0) - 1) do { (unitBackpack _unit) addWeaponCargoGlobal [(_weapons select 0) select _i,(_weapons select 1) select _i]; //return the weapons }; for "_i" from 0 to (count (_items select 0) - 1) do { (unitBackpack _unit) addItemCargoGlobal [(_items select 0) select _i,(_items select 1) select _i]; //return the items }; }; } else { if ((backpack _unit) != "b_parachute") then {_unit addBackpack "B_parachute"}; //add the parachute if unit has no backpack }; if (_altitude > 3040 && (headgear _unit) != "H_CrewHelmetHeli_B") then {_unit addHeadgear "H_CrewHelmetHeli_B"}; _unit setPos [(getPos _unit select 0), (getPos _unit select 1), _altitude]; //Set the altitude of the HALO jump if (!isPlayer _unit) then { _unit allowDamage FALSE; //god mode :) _unit switchMove "HaloFreeFall_non"; //place the AI into the free fall animation _unit disableAI "ANIM"; //disable the AI animation so they cant switch back to standing }; if (isPlayer _unit) then { [_unit,_autoOpen] spawn { private ["_unit","_autoOpen"]; _unit = _this select 0; _autoOpen = _this select 1; if (_autoOpen) then { waitUntil {(getPos _unit select 2) < 150 || animationState _unit == "para_pilot" && alive _unit}; _unit action ["OpenParachute", _unit]; //open parachute if 150m above ground }; waitUntil {animationState _unit == "para_pilot"}; // Parachute opening effect for more immersion playSound "open_chute"; //play chute opening sound setAperture 0.05; setAperture -1; "DynamicBlur" ppEffectEnable true; "DynamicBlur" ppEffectAdjust [8.0]; "DynamicBlur" ppEffectCommit 0.01; sleep 1; "DynamicBlur" ppEffectAdjust [0.0]; "DynamicBlur" ppEffectCommit 3; sleep 3; "DynamicBlur" ppEffectEnable false; "RadialBlur" ppEffectAdjust [0.0, 0.0, 0.0, 0.0]; "RadialBlur" ppEffectCommit 1.0; "RadialBlur" ppEffectEnable false; while {(getPos _unit select 2) > 2} do { playSound "para_pilot"; sleep 4.2; }; }; }; [_unit] spawn { private "_unit"; _unit = _this select 0; waitUntil {isTouchingGround _unit || (getPos _unit select 2) < 1 && alive _unit}; if (!isPlayer _unit) then { _unit enableAI "ANIM"; //enable the animations _unit setPos [(getPos _unit select 0), (getPos _unit select 1), 0]; //this removes the unit from the parachute _unit setVelocity [0,0,0]; //set speed to zero _unit setVectorUp [0,0,1]; //set the unit upright sleep 1; _unit allowDamage TRUE; //allow unit to be damaged again } else { // Parachute closing effect for more immersion playSound "close_chute";//play chute closing sound cutText ["", "BLACK FADED", 999]; sleep 2; cutText ["", "BLACK IN", 2]; _unit setDamage 0; //heal the unit to 100% in case of injury }; }; //create a log ["HALO function has completed"] call BIS_fnc_log; //Return Value _unit; } foreach _units; }; }; Is there some magical reason the weapon needs to be given to the player on the client side or something ? Edited November 17, 2014 by thefinn Share this post Link to post Share on other sites
epicgoldenwarrior 11 Posted November 17, 2014 I have no issues using regular addWeapon and whatever. I have a few scripts I run for respawn games, so if you die you spawn w/ same loadout. If you need any help, or want to see the scripts just gimme a heads up. I may forget I posted here lol Share this post Link to post Share on other sites