Comrades in Arms Discussion Board

Full Version: AddMPeventhandler help needed.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Okay, so I'm trying to create a Simple script to keep an eye on the players ROE. So I'm trying to create
an MPEventhandler with the command "AddMPEventHandler".

And I've understood that the script should look something like this (correct??):
grp addmpeventhandler ["killed", text "a friendly has died"]

Where; grp is an variable which consists of an array of all of the friendlies. (Can it be used this way, or do I need to use it "foreach"?)

But how can I make it so, that when one unit out of a certain array of units kills one out of another array, it gives a text and then ends the mission?
No to multiple things:
Quote:grp addmpeventhandler ["killed", text "a friendly has died"]
1. with addMPEventHandler you have to use the corresponding eventhandler types, so instead of "killed" you have to use "MPKilled", see biki for reference.
2. grp has to be the name of the unit you want to add the eventhandler to or you have to use something like:
Code:
{_x addMPEventHandler ["MPKilled", _this execVM "killed.sqf"]} forEach allUnits;
This will add the eventhandler to all units present in the mission; allUnits in the biki.

I suggest you start with a more simple setup for your mission because I can tell you that scripting multiplayer missions is particularly complicated to get right. Start with basic attack/defend missions with minimal scripting and work your way up from there.
yeah, I guess I should, though I've done missions which have been a bit more complicated! Tongue And to be honest, this thing is not used in most of the missions available. I mean a Script that watches is a friendly has been killed. So why should I go the hard way! Big Grin

I think I'll do the mission just without the thingy. Tongue
Something like

groupA = [guy1, guy2];
groupB = [civ1, civ2, civ3];
ROEhandler = { if(_this select 1 in groupA) then {activateMyEndTrigger=true; hint format [{%1 killed a civ and the mission will now end.}, _this select 1];} else {hint {A civilian has died!};};};

{_x addMPeventhandler [{MPKilled}, {foo=_this call ROEhandler;}]} foreach units groupB;

Then make a trigger that ends the mission with condition activateMyEndTrigger with some time delay so you can actually read the hint message.
Is this MP compatible if I just make the variables public?
Running that script in init.sqf or some init line should be enough.

I assume MPeventhandlers only trigger where the unit is local but the code string is executed on all machines.
Okay, thanks for all the help!  Wink
Something like This?

On another thought, this will probably not work because _this might not be transmitted as an array but as a code string from the eventhandler. So the clients will be all like "hey what's _this supposed to be?  ???" Big Grin

Changing the handler like this might work:
{_x addMPeventhandler [{MPKilled}, format [{foo=%1 call ROEhandler;}, _this]]} foreach units groupB;
How's this project going Bubba?
It has been, sadly enough (once again), been postponed due to school and other life.

As you may have noticed, I haven't even been able to join most of the the coop nights lately.
But this is to what I'll return to when I'm able to continue!

Thanks again for the help so far!