Jump to content

Sign in to follow this  
glowbal

Broadcasting addaction and removeaction effects on dedicted

Recommended Posts

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 by Glowbal

Share this post


Link to post
Share on other sites

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 HINTS

hint "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

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

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 by Glowbal

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×