Jump to content
Sign in to follow this  
rautapalli

Updating tasks in multiplayer

Recommended Posts

I have this problem where the tasks in my mission only get updated for one player.

This is how i have it set up:

There is a briefcase on the ground, i added a "Pickup" action for it with addAction. When the action is done, it executes a file called briefcase.sqf which looks like this:

deleteVehicle suitcase;

objective_3 setTaskState "Succeeded";
[objNull, objNull, objective_3, "SUCCEEDED"] execVM "CA\Modules\MP\data\scriptCommands\taskHint.sqf";
player setCurrentTask objective_4;

obj3 = 1;

Now the problem is that the task state and the popup only show up for the player that actually did the action. How could i make it execute for every player?

I heard that executing it through a trigger would work, but I'm not really sure how to execute a trigger through addAction either.

Share this post


Link to post
Share on other sites

Hi there.

As you can see here:

http://community.bistudio.com/wiki/addAction

The addAction is local to the unit that has called it, so you first need to use a publicVariable.

So you could do the following.

On the script executed with the action, lets name it "publicVariable.sqf" where you will broadcast a variable and trigger a publicVariableeventhandler.

//publicVariable.sqf

MY_name = name player;

publicVariable "MY_name";

this = [] execVM "pickup.sqf";

On your init.sqf you need to add a publicVariableEventHandler:

http://community.bistudio.com/wiki/addPublicVariableEventHandler

//init.sqf

"MY_name" addPublicVariableEventHandler { this = [] execVM "pickup.sqf"; };

Now here, you can do the rest because the script is running on all machines, not only on the player who executed it.

//pickup.sqf

deleteVehicle suitcase;

//A little text with the name of the player who picks the suitcase

cutText [format ["%1: I have the package.", MY_name], "PLAIN DOWN", 1];

objective_3 setTaskState "Succeeded";

[objNull, objNull, objective_3, "SUCCEEDED"] execVM "CA\Modules\MP\data\scriptCommands\taskHint.sqf";

player setCurrentTask objective_4;

obj3 = 1;

_neo_

Edited by neokika

Share this post


Link to post
Share on other sites

The Task Hint right?

taskhint ["Task done!\nGood job!", [0, 1, 0, 1], "taskDone"]; player setCurrentTask tskObjX;

X being the next objective you want set as a way pint depending on your breifing.

Not to be critical neo but why do you put in the long path if you don't need to?

execVM "CA\Modules\MP\data\scriptCommands\taskHint.sq f";

player setCurrentTask objective_4;

I'm really new to this and was just shown the other way the other day is there a reason you chose this or is it just the way you were taught also?

Share this post


Link to post
Share on other sites
The Task Hint right?

taskhint ["Task done!\nGood job!", [0, 1, 0, 1], "taskDone"]; player setCurrentTask tskObjX;

X being the next objective you want set as a way pint depending on your breifing.

Not to be critical neo but why do you put in the long path if you don't need to?

execVM "CA\Modules\MP\data\scriptCommands\taskHint.sq f";

player setCurrentTask objective_4;

I'm really new to this and was just shown the other way the other day is there a reason you chose this or is it just the way you were taught also?

hi breeze.

i dont know what you mean.

i just explain to him how he will be able to update tasks for all players in a MP game.

neo

Share this post


Link to post
Share on other sites
Thanks, that did just what i wanted it to do!

Good to know.

Anything just ask.

=P

_neo_

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  

×