Danidan 17 Posted September 3, 2018 Hello, I am not an expert and I galley for a while. I have this script and it work good but i Don't use it correcly in multiplayer Init RHQ1: [[RHQ1, ["Deploy HQ", "scripts\HQ\RHQ1.sqf"]], "addAction", true, true] call BIS_fnc_MP; OPEN RHQ = RHQ1.sqf #define RCAMOCOVERR "CamoNet_OPFOR_big_F" // <-- Camo Cover class name #define RCRATER "rhs_mags_CRATE" // <-- Supply RCRATER class Name #define MUR "Land_fort_bagfence_round" #define MUR2 "Land_fort_rampart_EP1"// <-- Supply RCRATER class Name _HQ = _this select 0; _caller = _this select 1; _id = _this select 2; _HQ removeAction _id; _isEmpty = !(getPosATL RHQ1 isFlatEmpty [6, -1, -1, -1, -1, false, RHQ1] isEqualTo []); _isVelocity = speed RHQ1 isEqualTo 0; if (_isEmpty && _isVelocity) then { //_HQ addaction ["RePackage HQ","scripts\HQ\RreHQ1.sqf"]; //removeAction Deploy_RHQ1; Repack_RHQ1 = [[RHQ1, ["Repack HQ", "scripts\HQ\RreHQ1.sqf"]], "addAction", true, true] call BIS_fnc_MP; //if (!alive RHQ1) then {removeAction RHQ1}; //[[RHQ1, ["Repack HQ", "scripts\HQ\RreHQ1.sqf"]], "addAction", true, true] call BIS_fnc_MP; private ["_HQ","_RCAMOCOVERR","_rsupply","_rprotect","_rprotect2"]; _HQ = _this select 0; _RCAMOCOVERR = createVehicle [RCAMOCOVERR, getPosATL _HQ,[],0,"CAN_COLLIDE"]; _RCAMOCOVERR attachTo [RHQ1, [0,0,0.1]]; _HQ setVariable ["CAMO",_RCAMOCOVERR]; _RCAMOCOVERR allowDamage false; _rsupply = createVehicle [RCRATER,[ (getPos _HQ select 0)-6, (getPos _HQ select 1)-0.2,(getPos _HQ select 2)+0.1],[],0,"CAN_COLLIDE"]; _HQ setVariable ["SUPPLY",_rsupply]; detach _rsupply; _rprotect = createVehicle [MUR,[ (getPos _HQ select 0)-6, (getPos _HQ select 1)-0.2,(getPos _HQ select 2)+0.1],[],0,"CAN_COLLIDE"]; _rprotect attachTo [RHQ1, [0,12,-1.5]]; _HQ setVariable ["PROTECT",_rprotect ]; detach _rprotect; _rprotect2 = createVehicle [MUR2,[ (getPos _HQ select 0)-6, (getPos _HQ select 1)-0.2,(getPos _HQ select 2)+0.1],[],0,"CAN_COLLIDE"]; _rprotect2 attachTo [RHQ1, [0,-12.7,-2.3]]; _HQ setVariable ["PROTECT2",_rprotect2 ]; detach _rprotect2; //Creation AGS _rmk19 = "RHS_AGS30_TriPod_VDV" createVehicle ([ (getPos RHQ1 select 0), (getPos RHQ1 select 1),(getPos RHQ1 select 2)+200] ); _rmk19 attachTo [RHQ1, [-10,-0.2,-0.5]]; detach _rmk19; //Creation MG _rmini = "rhs_KORD_high_VDV" createVehicle ([ (getPos RHQ1 select 0), (getPos RHQ1 select 1),(getPos RHQ1 select 2)+200] ); _rmini attachTo [RHQ1, [10,0.2,-0.5]]; detach _rmini; sleep 1; _RCAMOCOVERR allowDamage true; //// Creer position if (playerSide == east) then { _m = createMarkerlocal ['RHQ', (getPos RHQ1)]; _m setMarkerTypelocal 'o_hq'; _m setMarkerColorlocal 'ColorRed'; _m setMarkerTextlocal "HQ REDFOR"; }; _HQ setVariable ["deployed",true,true]; } else { Deploy_RHQ1 =[[RHQ1, ["Deploy HQ", "scripts\HQ\RHQ1.sqf"]], "addAction", true, true] call BIS_fnc_MP; if (side player == east) then {hint " impossible in these conditions";};}; CLOSE RHQ1 = RreHQ1.sqf _HQ = _this select 0; _caller = _this select 1; _id = _this select 2; _RCAMOCOVERR = getPos RHQ1 nearestObject "CamoNet_OPFOR_big_F"; _rprotect = getPos RHQ1 nearestObject "Land_fort_bagfence_round"; _rprotect2 = getPos RHQ1 nearestObject "Land_fort_rampart_EP1"; _rsupply = getPos RHQ1 nearestObject "rhs_mags_crate"; _rmini = getPos RHQ1 nearestObject "rhs_KORD_high_VDV"; _rmk19 = getPos RHQ1 nearestObject "RHS_AGS30_TriPod_VDV"; //_HQ removeAction _id; //_HQ addaction ["Deploy HQ","scripts\HQ\RHQ1.sqf"]; //[[RHQ1, ["Deploy HQ", "scripts\HQ\RHQ1.sqf"]], "addAction", true, true] call BIS_fnc_MP; //removeAction Deploy_RHQ1; Deploy_RHQ1 =[[RHQ1, ["Deploy HQ", "scripts\HQ\RHQ1.sqf"]], "addAction", true, true] call BIS_fnc_MP; //if (!alive RHQ1) then {removeAction RHQ1}; // Delete cover & Delete supplycrate deletevehicle _RCAMOCOVERR; deletevehicle _rsupply; deletevehicle _rprotect; deletevehicle _rprotect2; deletevehicle _rmini; deletevehicle _rmk19; deleteMarkerlocal "RHQ"; I try with the MP function but it duplicates the functions on the other players to see. Thank's for help! Share this post Link to post Share on other sites
pierremgi 4739 Posted September 4, 2018 First of all BIS_fnc_MP is outdated. Use remoteExec instead. Then if RHQ1 is a vehicle (in editor), or any object, and you write a code in its init field, it will run at server start + on each JIP. So, you don't need to, MP/remoteExec the addAction: just write: RHQ1 addAction ["Deploy HQ", "scripts\HQ\RHQ1.sqf"]; On the other hand, you placed another addAction "Repack HQ" inside the first one. That's a bad idea even if this can work (with remoteExec here because the script runs only on the caller PC). Keep your two codes RHQ1.sqf and RreHQ1.sqf but just add one addAction and play with setUserActionText for the text of the menu. You should have something like that: if (isServer) then {userText = "Deploy HQ"; publicVariable "userText"}; this addAction [userText, { params ["_HQ","_caller","_id"]; call { if (isNil {_HQ getVariable "deployed"}) exitWith { _isEmpty = !(getPosATL RHQ1 isFlatEmpty [6, -1, -1, -1, -1, false, RHQ1] isEqualTo []); _isVelocity = speed RHQ1 isEqualTo 0; if (_isEmpty && _isVelocity) then { _HQ setVariable ["deployed",true,true]; userText = "Repack HQ"; publicVariable "userText"; [_HQ, [_id, userText]] remoteExec ["setUserActionText",east,true]; [_HQ,"scripts\HQ\RHQ1.sqf"] remoteExec ["execVM",owner _HQ]; " HQ1 is now deployed" remoteExec ["hintSilent",EAST] } else { "impossible in these conditions" remoteExec ["hintSilent",_caller]; }; }; if (!isNil {_HQ getVariable "deployed"}) exitWith { _HQ setVariable ["deployed",nil,true]; userText = "Deploy HQ"; publicVariable "userText"; [_HQ, [_id, userText]] remoteExec ["setUserActionText",east,true]; [_HQ,"scripts\HQ\RreHQ1.sqf"] remoteExec ["execVM",owner _HQ]; " HQ1 is now repacked" remoteExec ["hintSilent",EAST] }; }; }, nil, 10,false, true,"","alive _target && side _this == east",10]; You can lighten your sqfs as some conditions are already met: east player, alive RHQ, distance to RHQ. And remove all stuff concerning addActions in your sqfs. Just focus on deploy/repack things. 4 Share this post Link to post Share on other sites
Danidan 17 Posted September 4, 2018 Wow! Thank you so mutch! I will test this to night! I will create a main.sqf with this code If I understand well? Fortunately people like you exist Kiss! Share this post Link to post Share on other sites
Danidan 17 Posted September 4, 2018 #define RCAMOCOVERR "CamoNet_OPFOR_big_F" // <-- Camo Cover class name #define RCRATER "rhs_mags_CRATE" // <-- Supply RCRATER class Name #define MUR "Land_fort_bagfence_round" #define MUR2 "Land_fort_rampart_EP1"// <-- Supply RCRATER class Name if (isServer) then { private ["_HQ","_RCAMOCOVERR","_rsupply","_rprotect","_rprotect2"]; _HQ = RHQ1; //Crer camo _RCAMOCOVERR = createVehicle [RCAMOCOVERR, getPosATL _HQ,[],0,"CAN_COLLIDE"]; _RCAMOCOVERR attachTo [RHQ1, [0,0,0.1]]; _HQ setVariable ["CAMO",_RCAMOCOVERR]; _RCAMOCOVERR allowDamage false; //Crer caisse d'arme _rsupply = createVehicle [RCRATER,[ (getPos _HQ select 0)-6, (getPos _HQ select 1)-0.2,(getPos _HQ select 2)+0.1],[],0,"CAN_COLLIDE"]; _HQ setVariable ["SUPPLY",_rsupply]; detach _rsupply; //Crer mur _rprotect = createVehicle [MUR,[ (getPos _HQ select 0)-6, (getPos _HQ select 1)-0.2,(getPos _HQ select 2)+0.1],[],0,"CAN_COLLIDE"]; _rprotect attachTo [RHQ1, [0,12,-1.5]]; _HQ setVariable ["PROTECT",_rprotect ]; detach _rprotect; //Crer protection avant _rprotect2 = createVehicle [MUR2,[ (getPos _HQ select 0)-6, (getPos _HQ select 1)-0.2,(getPos _HQ select 2)+0.1],[],0,"CAN_COLLIDE"]; _rprotect2 attachTo [RHQ1, [0,-12.7,-2.3]]; _HQ setVariable ["PROTECT2",_rprotect2 ]; detach _rprotect2; //Creation AGS _rmk19 = "RHS_AGS30_TriPod_VDV" createVehicle ([ (getPos RHQ1 select 0), (getPos RHQ1 select 1),(getPos RHQ1 select 2)+200] ); _rmk19 attachTo [RHQ1, [-10,-0.2,-0.5]]; detach _rmk19; //Creation MG _rmini = "rhs_KORD_high_VDV" createVehicle ([ (getPos RHQ1 select 0), (getPos RHQ1 select 1),(getPos RHQ1 select 2)+200] ); _rmini attachTo [RHQ1, [10,0.2,-0.5]]; detach _rmini; sleep 1; _RCAMOCOVERR allowDamage true; //// Creer position if (playerSide == east) then { _m = createMarkerlocal ['RHQ', (getPos RHQ1)]; _m setMarkerTypelocal 'o_hq'; _m setMarkerColorlocal 'ColorRed'; _m setMarkerTextlocal "HQ REDFOR"; }; }; That's work really good! I have use this script with "If (server) then " else the MG multiplicate. If i wan't make the same for opfor i make new sqf or i have other solution? Thank to show me the right way! Share this post Link to post Share on other sites
pierremgi 4739 Posted September 5, 2018 I guess the opposite side has different HQs. So you can addAction for all players (jus remove && side _this == east in the condition of the addAction). Then add some condition inside the code: example: call { if (side _caller == west) exitWith { bla bla code for spawning blue stuff at right positions}; if (side _call == east) exitWith { other code for east guys}; }; Note: call { if..exitWith. if.. exitWith...} is same as switch... do... but It's my choice. Share this post Link to post Share on other sites