Jump to content
Sign in to follow this  
Abrahamsen

Tasks not updating in multiplayer, locality?

Recommended Posts

This isn't working in multiplayer (but in the editor):

officer1 AddEventHandler ["killed",{tskofficer1 setTaskState "SUCCEEDED"; [objNull, ObjNull, tskofficer1, "SUCCEEDED"] execVM "CA\Modules\MP\data\scriptCommands\taskHint.sqf";}];

and this isn't either:

obj_osprey AddEventHandler ["killed",{taskosprey setTaskState "FAILED"; [objNull, ObjNull, taskosprey, "FAILED"] execVM "CA\Modules\MP\data\scriptCommands\taskHint.sqf"; execVM "fail.sqf";}];

The tasks are not updating when the officer1 dies. It does when I try it in the editor though. Same with the osprey.

How come?

I''m new to this forum, and new to arma 2 scripting.

Share this post


Link to post
Share on other sites

Where are you executing this from, and there shouldnt be a space between sqf btw.

Share this post


Link to post
Share on other sites

You guessed it, it's all about locality.

Create a trigger and put this in the cond field: objOfficer1

and this in the onAct: tskofficer1 setTaskState "SUCCEEDED"; nul=[objNull, ObjNull, tskofficer1, "SUCCEEDED"] execVM "CA\Modules\MP\data\scriptCommands\taskHint.sqf";

Replace the eventhandler code with: {objOfficer1 = true; publicvariable "objOfficer1"}

That way, when the officer dies all clients will be notified and then task & hint will be done on all of them locally. This way it will work for JIP as well.

Edited by Shuko

Share this post


Link to post
Share on other sites

Why even use an event handler, stick a trigger with "!alive officer1" in condition and:

tskofficer1 setTaskState "SUCCEEDED"; nul = [objNull, ObjNull, tskofficer1, "SUCCEEDED"] execVM "CA\Modules\MP\data\scriptCommands\taskHint.sqf";

in the onactivation field.

Share this post


Link to post
Share on other sites
Why even use an event handler, stick a trigger with "!alive officer1" in condition and:

tskofficer1 setTaskState "SUCCEEDED"; nul = [objNull, ObjNull, tskofficer1, "SUCCEEDED"] execVM "CA\Modules\MP\data\scriptCommands\taskHint.sqf";

in the onactivation field.

Slothophile, I'm very new to scripting, I thought about this yesterday but forgot it after a few hours of sleep.

I'll just do this I think

Thank you all for the hints, it's so helpful when I get an explanation along with the proposed code.

---------- Post added at 01:40 PM ---------- Previous post was at 01:37 PM ----------

You guessed it, it's all about locality.

Create a trigger and put this in the cond field: objOfficer1

and this in the onAct: tskofficer1 setTaskState "SUCCEEDED"; nul=[objNull, ObjNull, tskofficer1, "SUCCEEDED"] execVM "CA\Modules\MP\data\scriptCommands\taskHint.sqf";

Replace the eventhandler code with: {objOfficer1 = true; publicvariable "objOfficer1"}

That way, when the officer dies all clients will be notified and then task & hint will be done on all of them locally. This way it will work for JIP as well.

I like your answer because it incorporates eventhandlers that I was using to begin with, but I know see that I should just use a trigger.

---------- Post added at 01:42 PM ---------- Previous post was at 01:40 PM ----------

Actually I had already used a trigger to unlock the osprey by having in the cond. field:

! (alive officer1) AND ! (alive officer2) AND ! (alive officer3) AND ! (alive officer4)

I just didn't realize my eventhandler solution didn't work.

---------- Post added at 01:45 PM ---------- Previous post was at 01:42 PM ----------

And there isn't a space between "sq" and "f" in my script, don't know why it showed up here.

Share this post


Link to post
Share on other sites

And yep, triggers are nice, since they are run on every machine. Downside is that if they are overused they'll lag the game, due to the multitude of constant condition-checks.

Very powerful tools though if used wisely :)

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  

×