boydee 10 Posted July 18, 2015 Sorry if this has been asked before, I did have a look around and tried a few things to no avail. I found this basic "Deploy HQ" script and I've tried to add Arsenal to the supply box it spawns. It all works in the editor how ever when I upload to a dedicated server the addaction doesn't show up on the box for arsenal. Any input would be helpful. [color="#FF8040"][color="#1874CD"]#define[/color] CAMOCOVER [color="#7A7A7A"]"CamoNet_BLUFOR_big_F"[/color] [color="#006400"][i]// <-- Camo Cover class name[/i][/color] [color="#1874CD"]#define[/color] CRATE [color="#7A7A7A"]"B_supplyCrate_F"[/color] [color="#006400"][i]// <-- Supply Crate class Name[/i][/color] [color="#1874CD"]_HQ[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#000000"]_this[/color] [color="#191970"][b]select[/b][/color] [color="#FF0000"]0[/color][color="#8B3E2F"][b];[/b][/color] [color="#191970"][b]if[/b][/color] [color="#8B3E2F"][b]([/b][/color][color="#191970"][b]isServer[/b][/color][color="#8B3E2F"][b])[/b][/color] [color="#191970"][b]then[/b][/color] [color="#8B3E2F"][b]{[/b][/color] [color="#1874CD"]_flagPole[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#000000"]_this[/color] [color="#191970"][b]select[/b][/color] [color="#FF0000"]1[/color][color="#8B3E2F"][b];[/b][/color] [color="#1874CD"]_flagData[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#1874CD"]_flagPole[/color][color="#8B3E2F"][b],[/b][/color][color="#8B3E2F"][b]([/b][/color][color="#191970"][b]getPosATL[/b][/color] [color="#1874CD"]_flagPole[/color][color="#8B3E2F"][b])[/b][/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color] [color="#1874CD"]_HQ[/color] [color="#191970"][b]setVariable[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#7A7A7A"]"flagData"[/color][color="#8B3E2F"][b],[/b][/color][color="#1874CD"]_flagData[/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color] [color="#1874CD"]_HQ[/color] [color="#191970"][b]setVariable[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#7A7A7A"]"deployed"[/color][color="#8B3E2F"][b],[/b][/color][color="#000000"]false[/color][color="#8B3E2F"][b],[/b][/color][color="#000000"]true[/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color] sillyflip_fnc_deployHQ [color="#8B3E2F"][b]=[/b][/color] [color="#8B3E2F"][b]{[/b][/color] [color="#191970"][b]private[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#7A7A7A"]"_HQ"[/color][color="#8B3E2F"][b],[/b][/color][color="#7A7A7A"]"_camocover"[/color][color="#8B3E2F"][b],[/b][/color][color="#7A7A7A"]"_supply"[/color][color="#8B3E2F"][b],[/b][/color][color="#7A7A7A"]"_flag"[/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color] [color="#1874CD"]_HQ[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#000000"]_this[/color] [color="#191970"][b]select[/b][/color] [color="#FF0000"]0[/color][color="#8B3E2F"][b];[/b][/color] [color="#1874CD"]_camocover[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#191970"][b]createVehicle[/b][/color] [color="#8B3E2F"][b][[/b][/color]CAMOCOVER[color="#8B3E2F"][b],[/b][/color] [color="#191970"][b]getPosATL[/b][/color] [color="#1874CD"]_HQ[/color][color="#8B3E2F"][b],[/b][/color][color="#8B3E2F"][b][[/b][/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b],[/b][/color][color="#FF0000"]0[/color][color="#8B3E2F"][b],[/b][/color][color="#7A7A7A"]"CAN_COLLIDE"[/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color] [color="#1874CD"]_HQ[/color] [color="#191970"][b]setVariable[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#7A7A7A"]"CAMO"[/color][color="#8B3E2F"][b],[/b][/color][color="#1874CD"]_camocover[/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color] [color="#1874CD"]_camocover[/color] [color="#191970"][b]allowDamage[/b][/color] [color="#000000"]false[/color][color="#8B3E2F"][b];[/b][/color] [color="#1874CD"]_supply[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#191970"][b]createVehicle[/b][/color] [color="#8B3E2F"][b][[/b][/color]CRATE[color="#8B3E2F"][b],[/b][/color][color="#8B3E2F"][b][[/b][/color] [color="#8B3E2F"][b]([/b][/color][color="#191970"][b]getPos[/b][/color] [color="#1874CD"]_HQ[/color] [color="#191970"][b]select[/b][/color] [color="#FF0000"]0[/color][color="#8B3E2F"][b])[/b][/color][color="#FF0000"]-2[/color][color="#8B3E2F"][b],[/b][/color] [color="#8B3E2F"][b]([/b][/color][color="#191970"][b]getPos[/b][/color] [color="#1874CD"]_HQ[/color] [color="#191970"][b]select[/b][/color] [color="#FF0000"]1[/color][color="#8B3E2F"][b])[/b][/color][color="#FF0000"]-0.2[/color][color="#8B3E2F"][b],[/b][/color][color="#8B3E2F"][b]([/b][/color][color="#191970"][b]getPos[/b][/color] [color="#1874CD"]_HQ[/color] [color="#191970"][b]select[/b][/color] [color="#FF0000"]2[/color][color="#8B3E2F"][b])[/b][/color][color="#FF0000"]+0.1[/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b],[/b][/color][color="#8B3E2F"][b][[/b][/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b],[/b][/color][color="#FF0000"]0[/color][color="#8B3E2F"][b],[/b][/color][color="#7A7A7A"]"CAN_COLLIDE"[/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color] [color="#1874CD"]_supply[/color] [color="#191970"][b]addAction[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#7A7A7A"]"<t color='#ff1111'>Open Virtual Arsenal</t>"[/color][color="#8B3E2F"][b],[/b][/color] [color="#8B3E2F"][b]{[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#7A7A7A"]"Open"[/color][color="#8B3E2F"][b],[/b][/color][color="#000000"]true[/color][color="#8B3E2F"][b]][/b][/color] [color="#191970"][b]call[/b][/color] BIS_fnc_arsenal[color="#8B3E2F"][b];[/b][/color] [color="#8B3E2F"][b]}[/b][/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color] [color="#1874CD"]_HQ[/color] [color="#191970"][b]setVariable[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#7A7A7A"]"SUPPLY"[/color][color="#8B3E2F"][b],[/b][/color][color="#1874CD"]_supply[/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color] [color="#1874CD"]_flag[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#8B3E2F"][b]([/b][/color][color="#1874CD"]_HQ[/color] [color="#191970"][b]getVariable[/b][/color] [color="#7A7A7A"]"flagData"[/color][color="#8B3E2F"][b])[/b][/color] [color="#191970"][b]select[/b][/color] [color="#FF0000"]0[/color][color="#8B3E2F"][b];[/b][/color] [color="#1874CD"]_flag[/color] [color="#191970"][b]attachTo[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#1874CD"]_HQ[/color][color="#8B3E2F"][b],[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#FF0000"]0[/color][color="#8B3E2F"][b],[/b][/color][color="#FF0000"]-15[/color][color="#8B3E2F"][b],[/b][/color][color="#FF0000"]2[/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color] [color="#006400"][i]// Move the flag to the container[/i][/color] [color="#191970"][b]detach[/b][/color] [color="#1874CD"]_flag[/color][color="#8B3E2F"][b];[/b][/color] [color="#191970"][b]sleep[/b][/color] [color="#FF0000"]1[/color][color="#8B3E2F"][b];[/b][/color] [color="#1874CD"]_camocover[/color] [color="#191970"][b]allowDamage[/b][/color] [color="#000000"]true[/color][color="#8B3E2F"][b];[/b][/color] [color="#1874CD"]_HQ[/color] [color="#191970"][b]setVariable[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#7A7A7A"]"deployed"[/color][color="#8B3E2F"][b],[/b][/color][color="#000000"]true[/color][color="#8B3E2F"][b],[/b][/color][color="#000000"]true[/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color] [color="#8B3E2F"][b]}[/b][/color][color="#8B3E2F"][b];[/b][/color] sillyflip_fnc_packHQ [color="#8B3E2F"][b]=[/b][/color] [color="#8B3E2F"][b]{[/b][/color] [color="#191970"][b]private[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#7A7A7A"]"_HQ"[/color][color="#8B3E2F"][b],[/b][/color][color="#7A7A7A"]"_flag"[/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color] [color="#1874CD"]_HQ[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#000000"]_this[/color] [color="#191970"][b]select[/b][/color] [color="#FF0000"]0[/color][color="#8B3E2F"][b];[/b][/color] [color="#191970"][b]deleteVehicle[/b][/color] [color="#8B3E2F"][b]([/b][/color][color="#1874CD"]_HQ[/color] [color="#191970"][b]getVariable[/b][/color] [color="#7A7A7A"]"CAMO"[/color][color="#8B3E2F"][b])[/b][/color][color="#8B3E2F"][b];[/b][/color] [color="#191970"][b]deleteVehicle[/b][/color] [color="#8B3E2F"][b]([/b][/color][color="#1874CD"]_HQ[/color] [color="#191970"][b]getVariable[/b][/color] [color="#7A7A7A"]"SUPPLY"[/color][color="#8B3E2F"][b])[/b][/color][color="#8B3E2F"][b];[/b][/color] [color="#1874CD"]_flag[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#8B3E2F"][b]([/b][/color][color="#8B3E2F"][b]([/b][/color][color="#1874CD"]_HQ[/color] [color="#191970"][b]getVariable[/b][/color] [color="#7A7A7A"]"flagData"[/color][color="#8B3E2F"][b])[/b][/color] [color="#191970"][b]select[/b][/color] [color="#FF0000"]0[/color][color="#8B3E2F"][b])[/b][/color][color="#8B3E2F"][b];[/b][/color] [color="#1874CD"]_flag[/color] [color="#191970"][b]setPos[/b][/color] [color="#8B3E2F"][b]([/b][/color][color="#8B3E2F"][b]([/b][/color][color="#1874CD"]_HQ[/color] [color="#191970"][b]getVariable[/b][/color] [color="#7A7A7A"]"flagData"[/color][color="#8B3E2F"][b])[/b][/color] [color="#191970"][b]select[/b][/color] [color="#FF0000"]1[/color][color="#8B3E2F"][b])[/b][/color][color="#8B3E2F"][b];[/b][/color] [color="#1874CD"]_HQ[/color] [color="#191970"][b]setVariable[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#7A7A7A"]"deployed"[/color][color="#8B3E2F"][b],[/b][/color][color="#000000"]false[/color][color="#8B3E2F"][b],[/b][/color][color="#000000"]true[/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color] [color="#8B3E2F"][b]}[/b][/color][color="#8B3E2F"][b];[/b][/color] [color="#8B3E2F"][b]}[/b][/color][color="#8B3E2F"][b];[/b][/color] [color="#191970"][b]if[/b][/color] [color="#8B3E2F"][b]([/b][/color][color="#8B3E2F"][b]![/b][/color][color="#191970"][b]isDedicated[/b][/color][color="#8B3E2F"][b])[/b][/color] [color="#191970"][b]then[/b][/color] [color="#8B3E2F"][b]{[/b][/color] [color="#191970"][b]waitUntil[/b][/color][color="#8B3E2F"][b]{[/b][/color][color="#8B3E2F"][b]![/b][/color][color="#8B3E2F"][b]([/b][/color][color="#191970"][b]isNull[/b][/color] [color="#000000"]player[/color][color="#8B3E2F"][b])[/b][/color][color="#8B3E2F"][b]}[/b][/color][color="#8B3E2F"][b];[/b][/color] [color="#1874CD"]_HQ[/color] [color="#191970"][b]addAction[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#7A7A7A"]"<t color='#ff1111'>Deploy HQ</t>"[/color][color="#8B3E2F"][b],[/b][/color][color="#8B3E2F"][b]{[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#000000"]_this[/color][color="#8B3E2F"][b],[/b][/color][color="#7A7A7A"]"sillyflip_fnc_deployHQ"[/color][color="#8B3E2F"][b],[/b][/color][color="#000000"]false[/color][color="#8B3E2F"][b]][/b][/color] [color="#191970"][b]call[/b][/color] BIS_fnc_MP[color="#8B3E2F"][b];[/b][/color] [color="#8B3E2F"][b]}[/b][/color] [color="#8B3E2F"][b],[/b][/color][color="#8B3E2F"][b][[/b][/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b],[/b][/color][color="#FF0000"]0[/color][color="#8B3E2F"][b],[/b][/color][color="#000000"]true[/color][color="#8B3E2F"][b],[/b][/color][color="#000000"]true[/color][color="#8B3E2F"][b],[/b][/color][color="#7A7A7A"]""[/color][color="#8B3E2F"][b],[/b][/color][color="#7A7A7A"]"!(_target getVariable ['deployed',true])"[/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color] [color="#1874CD"]_HQ[/color] [color="#191970"][b]addAction[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#7A7A7A"]"<t color='#ff1111'>Pack HQ</t>"[/color][color="#8B3E2F"][b],[/b][/color][color="#8B3E2F"][b]{[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#000000"]_this[/color][color="#8B3E2F"][b],[/b][/color][color="#7A7A7A"]"sillyflip_fnc_packHQ"[/color][color="#8B3E2F"][b],[/b][/color][color="#000000"]false[/color][color="#8B3E2F"][b]][/b][/color] [color="#191970"][b]call[/b][/color] BIS_fnc_MP[color="#8B3E2F"][b];[/b][/color] [color="#8B3E2F"][b]}[/b][/color][color="#8B3E2F"][b],[/b][/color][color="#8B3E2F"][b][[/b][/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b],[/b][/color][color="#FF0000"]0[/color][color="#8B3E2F"][b],[/b][/color][color="#000000"]true[/color][color="#8B3E2F"][b],[/b][/color][color="#000000"]true[/color][color="#8B3E2F"][b],[/b][/color][color="#7A7A7A"]""[/color][color="#8B3E2F"][b],[/b][/color][color="#7A7A7A"]"_target getVariable ['deployed',false]"[/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color] [color="#006400"][i]//Uncomment for testing to move HQ crate to players location[/i][/color] [color="#006400"][i]//player addAction ["Move HQ",{((_this select 3) select 0) setPosATL (getPosATL player)},[_HQ]];[/i][/color] [color="#8B3E2F"][b]}[/b][/color][color="#8B3E2F"][b];[/b][/color] [/color] Made with KK's SQF to BBCode Converter Share this post Link to post Share on other sites
soolie 189 Posted July 18, 2015 if (!isDedicated) then { waitUntil{!(isNull player)}; _HQ addAction ["<t color='#ff1111'>Deploy HQ</t>",{ [_this,"sillyflip_fnc_deployHQ",false] call BIS_fnc_MP; } ,[],0,true,true,"","!(_target getVariable ['deployed',true])"]; _HQ addAction ["<t color='#ff1111'>Pack HQ</t>",{ [_this,"sillyflip_fnc_packHQ",false] call BIS_fnc_MP; },[],0,true,true,"","_target getVariable ['deployed',false]"]; //Uncomment for testing to move HQ crate to players location //player addAction ["Move HQ",{((_this select 3) select 0) setPosATL (getPosATL player)},[_HQ]]; }; "!" means not. So !isDedicated means it will only fire if host is non dedicated server. Check this out and this Share this post Link to post Share on other sites
ianbanks 30 Posted July 18, 2015 You've got the addAction (for Arsenal) within the if (isServer) then block, which means it isn't running on the clients. You need to run an addAction on each client that you want the action to be visible on. In this case, the best option is probably to write a function that adds the Arsenal action to the box, and then trigger that function on all clients by using bis_fnc_mp. Share this post Link to post Share on other sites
davidoss 552 Posted July 18, 2015 (edited) Try addaction in this form: [{_HQ addAction["<t color='#ff1111'>Deploy HQ</t>", "sillyflip_fnc_deployHQ",[],6,false,true,"","!(_target getVariable ['deployed',true])"];},"BIS_fnc_spawn",true,true] call BIS_fnc_MP; [{_HQ addAction["<t color='#ff1111'>Pack HQ</t>", "sillyflip_fnc_packHQ",[],6,false,true,"","_target getVariable ['deployed',false]"];},"BIS_fnc_spawn",true,true] call BIS_fnc_MP; Edited July 18, 2015 by DaVIdoSS Share this post Link to post Share on other sites
Larrow 2823 Posted July 18, 2015 (edited) Just use the other Ammoboxinit version of BIS_fnc_arsenal, which can be called via the server and will automatically add an action on each client for you. #define CAMOCOVER "CamoNet_BLUFOR_big_F" // <-- Camo Cover class name #define CRATE "B_supplyCrate_F" // <-- Supply Crate class Name _HQ = _this select 0; if (isServer) then { _flagPole = _this select 1; _flagData = [_flagPole,(getPosATL _flagPole)]; _HQ setVariable ["flagData",_flagData]; _HQ setVariable ["deployed",false,true]; sillyflip_fnc_deployHQ = { private ["_HQ","_camocover","_supply","_flag"]; _HQ = _this select 0; _camocover = createVehicle [CAMOCOVER, getPosATL _HQ,[],0,"CAN_COLLIDE"]; _HQ setVariable ["CAMO",_camocover]; _camocover allowDamage false; _supply = createVehicle [CRATE,[ (getPos _HQ select 0)-2, (getPos _HQ select 1)-0.2,(getPos _HQ select 2)+0.1],[],0,"CAN_COLLIDE"]; [ "AmmoboxInit", [ _supply, true] ] call BIS_fnc_arsenal; _HQ setVariable ["SUPPLY",_supply]; _flag = (_HQ getVariable "flagData") select 0; _flag attachTo [_HQ, [0,-15,2]]; // Move the flag to the container detach _flag; sleep 1; _camocover allowDamage true; _HQ setVariable ["deployed",true,true]; }; sillyflip_fnc_packHQ = { private ["_HQ","_flag"]; _HQ = _this select 0; deleteVehicle (_HQ getVariable "CAMO"); deleteVehicle (_HQ getVariable "SUPPLY"); _flag = ((_HQ getVariable "flagData") select 0); _flag setPos ((_HQ getVariable "flagData") select 1); _HQ setVariable ["deployed",false,true]; }; }; if (!isDedicated) then { waitUntil{!(isNull player)}; _HQ addAction ["<t color='#ff1111'>Deploy HQ</t>",{ [_this,"sillyflip_fnc_deployHQ",false] call BIS_fnc_MP; } ,[],0,true,true,"","!(_target getVariable ['deployed',true])"]; _HQ addAction ["<t color='#ff1111'>Pack HQ</t>",{ [_this,"sillyflip_fnc_packHQ",false] call BIS_fnc_MP; },[],0,true,true,"","_target getVariable ['deployed',false]"]; //Uncomment for testing to move HQ crate to players location //player addAction ["Move HQ",{((_this select 3) select 0) setPosATL (getPosATL player)},[_HQ]]; }; "!" means not. So !isDedicated means it will only fire if host is non dedicated server. This is not correct !isDedicated means the following code will not be executed if the machine reading the code is not a dedicated server. So if this was placed in the init.sqf for example a hosted server and any client machines will run it. Edited July 18, 2015 by Larrow Share this post Link to post Share on other sites
boydee 10 Posted July 18, 2015 Thanks for your input guys, @Larrow that does the job thanks so much! Share this post Link to post Share on other sites