glowbal 13 Posted November 8, 2011 (edited) Hello, I've been working on a script in which you are able to arrest certain civilians and perform different options after that. It all works by action menu and for single player it all works fine, no issues. However, I would like to have it working on PM, so that it broadcasts animations on all machines, plus removes the previouse action menu option, and add the two new ones. Here is what I have currently; Quote hint "You arrest the Civilian.";// Quick animation. titleText ["I NO TAKIBAN!","PLAIN DOWN"]; 10; _suspect = _this select 0; _caller = _this select 1; _id = _this select 2; // REMOVE ADDACTION OPTIONS _suspect removeAction act1; _suspect removeAction act2; //PLAY ANIMATION _suspect playmove "UnaErc_UnaErcPoslechVelitele"; //ADD NEW ADDACTION act1 = _suspect addaction ["Put Suspect on the Ground","Scripts\interaction\arrest\arrest.sqf"]; ProcessInitCommands; }; I have searched through the forums, but couldn't really find anything that worked for me or something similair. I have tried publicVariable to no success, as well as CBA Event Handlers. The ifServer command didn't work properly (only worked for myself, as I am host. Not for anyone else). So I am pretty sure I am doing something wrong. Please enlighten me, what is the best way to do this and how does it work? Much appriciated, Glowbal Edited November 8, 2011 by Glowbal Share this post Link to post Share on other sites
hellfire257 3 Posted November 8, 2011 Did you try CBA_fnc_GlobalExecute? Syntax example: [-2,{_this switchmove "HaloFreeFall_non"},_unit] call CBA_fnc_GlobalExecute; http://dev-heaven.net/docs/cba/files/network/fnc_globalExecute-sqf.html Share this post Link to post Share on other sites
glowbal 13 Posted November 8, 2011 Sadly I did not get it working with CBA_fnc_GlobalExecute. I start off with an addaction in the menu from the civilian. Quote Act1 = this addaction ["Check Civilian","Scripts\interaction\suspect1.sqf"]; Which activates this .sqf: suspect1.sqf Quote // Quick animation.titleText ["Boro kenâr!","PLAIN DOWN"]; 10; _gen = _this select 0; _caller = _this select 1; _id = _this select 2; // remove the action once it is activated _gen removeAction _id; _gen playmove "AidlPercSnonWnonDnon_talk1"; sleep 2; hint "You realise he does not want to talk to you.. He might be up to something. You might want to keep an eye on him."; Sleep 3; hint "You can arrest him or push him for some intel"; act1 = _gen addaction ["Arrest this civilian","Scripts\interaction\events\ArrestStart.sqf"]; act2 = _gen addaction ["Push for some intel","Scripts\interaction\Reply2.sqf"]; ProcessInitCommands; This one is ok to be ran local. Same with reply2.sqf. The problem starts with activating the arrest script, ArrestStart.Sqf. Quote // TEXT AND HINTShint "You arrest the Civilian."; // ID [-2, { _gen = _this select 0; _caller = _this select 1; _id = _this select 2; // remove the action once it is activated _gen removeAction _id; _gen removeaction act1; _gen removeaction act2; _gen removeaction act3; //ANIMATION _gen switchmove "UnaErc_UnaErcPoslechVelitele"}; act1 = _gen addaction ["Take Suspect with you","Scripts\interaction\arrest\Control.sqf"]; act2 = _gen addaction ["Search Suspect","Scripts\interaction\arrest\Search.sqf"]; act3 = _gen addaction ["Release Suspect","Scripts\interaction\events\Release.sqf"]; ProcessInitCommands; },_this] call CBA_fnc_GlobalExecute; Sleep 3; hint "You can now take him with you, search his stuff, or release him."; From here, you can either take him with you (works through attach to), search or release. Basicly, what I am trying to get working is someway to broadcast animations on all clients and remove/add new addactions for all clients as well. Since my attempts don't work in multiplayer, I am most likely doing something wrong. Share this post Link to post Share on other sites
riouken 15 Posted November 8, 2011 You should do that with CBA Add the eventhandlers to everyone(in the init.sqf for exp.): http://dev-heaven.net/docs/cba/files/events/fnc_addEventHandler-sqf.html Then raise an event to trigger it: http://dev-heaven.net/docs/cba/files/events/fnc_globalEvent-sqf.html Share this post Link to post Share on other sites
mikie boy 18 Posted November 8, 2011 I know some people don't suggest using the Multiplayer framework - but it seems to work ok for me - and i too had the same problems with all seeing actions. other methods are to use CBA as mentioned.. or add PublicVariableEventHandler and use publicvariable - i also had that working. init.sqf if (isServer) then { "suspectsurrender" addPublicVariableEventHandler { ((_this select 1) select 0) playActionNow ((_this select 1) select 1); }; }; place this in you code that activates ///add this to make surrender movement global/// _movement = "Surrender"; if (isServer) then { _suspect playActionNow _movement; // for hosted environment } else { terrorsurrender = [_suspect , _movement]; publicVariable "suspectsurrender"; }; sleep 2; Mp framework - http://community.bistudio.com/wiki/Multiplayer_framework is as below... waituntil { !isNil "BIS_fnc_init" }; //must have function module on map. // to remove the action [nil, _suspect, "per", rREMOVEACTION, _id] call RE; //add action [nil, _suspect, "per", rADDACTION, "whateverthescript.sqf"] call RE; //to play action for everyone [nil,_suspect,rplayActionnow,"UnaErc_UnaErcPoslechVelitele"] call RE; hope this helps Share this post Link to post Share on other sites
glowbal 13 Posted November 8, 2011 (edited) I goti t all working now! Thanks a lot! init.sqf: Quote // START of ArrestScript.sqf - Called on the start of the Arrest ["ArrestStart", { private ["_gen", "_caller", "_id"]; _gen = _this select 0; _caller = _this select 1; _id = _this select 2; // remove the action once it is activated _gen removeAction _id; _gen removeAction act1; _gen removeAction act2; _gen removeAction act3; //ANIMATION _gen switchmove "UnaErc_UnaErcPoslechVelitele"; //ADDACTIONS act1 = _gen addaction ["Take Suspect with you","Scripts\interaction\arrest\Control.sqf"]; act2 = _gen addaction ["Search Suspect","Scripts\interaction\arrest\Search.sqf"]; act3 = _gen addaction ["Release Suspect","Scripts\interaction\arrest\Release.sqf"]; ProcessInitCommands; }] call CBA_fnc_addEventHandler; Action: Quote Act1 = this addaction ["Arrest Civilian","scripts\interaction\arreststart.sqf"]; Arreststart.sqf Quote _suspect = _this select 0;_caller = _this select 1; _id = _this select 2; ["ArrestStart", [_suspect, _caller]] call CBA_fnc_globalEvent; hint "You arrest the Civilian."; Only minor effect is that after the second arrest, the arrest option always appears on action menu, but everyone else works fine. :) Everyone can see it, so I am happy. Edited November 9, 2011 by Glowbal Share this post Link to post Share on other sites