Jump to content
Sign in to follow this  
clydefrog

person taking item only triggers task complete for that person

Recommended Posts

Hi, I'm having a problem I've tried to fix several times and I can't. I have 2 objectives in my mission where you need to "take" an item using the action menu, which then triggers a task complete message. The problem is the task hints only show up and set the tasks as complete for the person who takes the items and not everybody else.

The first of these tasks consists of an object named "C130" with the following in its init:

_takebox = C130 addaction ["Retrieve Flight Recorder","intel.sqf"];

this is the intel.sqf that it links to:

C130 = true;
PublicVariable "C130";
task3 setTaskState "SUCCEEDED";
C130 removeAction _takebox;
;
exit

(C130 in this script is the task name)

then I have a trigger with condition: taskCompleted task3 // onAct: null = [task3,task4] execVM "complete.sqf";

this is the content of the complete.sqf:

/// How to use
/// Called with 2 Params, param 1 is the completed objective, param 2 is the new objective.
/// null = [task1,task2] execVM "complete.sqf";


_taskcomplete = _this select 0;
_tasknext = _this select 1;

_taskcomplete settaskstate "SUCCEEDED";
[_taskcomplete] call mk_fTaskHint; 

sleep 4;

player setcurrenttask _tasknext;
[_tasknext] call mk_fTaskHint; 

I have also tried having the onAct field as just "player setCurrentTask task 4" as I'm aware that I have already stated task 3 as completed when the script executes but this makes no difference and is not part of the problem.

The second task is more basic; I have a map on the ground named "evi1" and in the trigger above that completes task3 I also have the following

evi1 addaction ["pick up intel", "collect.sqf"];

which adds the action to pick up intel to the map only after task 3 is completed, this is the collect.sqf file:

deletevehicle evi1;
task4 setTaskState "SUCCEEDED";

which just deletes the map when the script is executed by clicking "pick up intel" on the action menu, and then sets the task as complete. I have a trigger condition: taskCompleted task4 // onAct: C130J=true; publicVariable "C130J"; null = [task4,task5] execVM "complete.sqf";

(C130J is the name for task4 in my briefing)

Again I have also tried having the onAct field as just "player setCurrentTask task 5" and [task5] call mk_fTaskHint; as I have already stated task 3 as completed when the script executes but again this makes no difference and is not part of the problem.

Does anybody have any idea how to fix this? It all works fine when I try it myself but if somebody else does the task it only completes and sets the next one for them and nobody else. Is there another way of doing it that can get around the problem? Thanks.

Edited by clydefrog

Share this post


Link to post
Share on other sites

The effects of addAction are local to the caller. That is your problem. Since I'm rather lazy, I fix it by using CBA_fnc_globalExecute, but that of course means you need to use CBA. Your other alternative that I can think of is to use Remote Execute, otherwise known as RE, but I have no experience with that and that might not work either.

CBA_fnc_globalExecute: https://dev-heaven.net/docs/cba/files/network/fnc_globalExecute-sqf.html

RE: http://community.bistudio.com/wiki/Multiplayer_framework

Share this post


Link to post
Share on other sites

I'm using CBA as I'm using ACE, so how would I go about using this thing on those tasks? Everybody can see the action in the menu btw, it's just that the task stuff triggered after it only shows up for the person who used the menu that executes them.

I've put in the object named C130's init:

[-2, {_takebox = C130 addaction ["Retrieve Flight Recorder","intel.sqf"];}] call CBA_fnc_globalExecute;

Is that right?

Ok, that didn't work, I tried adding it for both the addaction parts and the task stuff still doesn't show up for other players.

Edited by clydefrog

Share this post


Link to post
Share on other sites

Nope, only you need to make the parts that you want to have a global effect global. It would be easier if you could send me your mission since you've got a lot spread out here.

Share this post


Link to post
Share on other sites
Nope, only you need to make the parts that you want to have a global effect global. It would be easier if you could send me your mission since you've got a lot spread out here.

I see, well since it is the task completed part that I need to be broadcast globally to everybody on the server, and I also need to remove the action for everybody so it isn't still there when the task is done, should I add the call CBA_fnc_globalExecute to just those parts? e.g.

C130 = true;
PublicVariable "C130";
[-1, {task3 setTaskState "SUCCEEDED";}] call CBA_fnc_globalExecute; // set task as complete for everybody
[-1, {C130 removeAction _takebox;}] call CBA_fnc_globalExecute; // remove action for everybody
;
exit

Should I add it to the C130=true as well?

If I can't work this out I will send you it and you can take a look. At the moment since I can't get it working I have tried doing it a cheap way and on the map object that I had added a pick up action for I have just put a "deletevehicle map" trigger by it, so when you stand right over it it disappears and you get a message saying you've picked it up. I guess I won't get any weird problems doing it this way but it is better the way I want to do it with addAction menus. Same for the other task too really.

Thanks.

Share this post


Link to post
Share on other sites
C130 setVariable ["TAG_takeAction", C130 addAction ["Retrieve Flight Recorder", "intel.sqf"]];
//intel.sqf[-1, {  task3 setTaskState "SUCCEEDED";  C130 removeAction (C130 getVariable "TAG_takeAction");}] call CBA_fnc_globalExecute;

Share this post


Link to post
Share on other sites
C130 setVariable ["TAG_takeAction", C130 addAction ["Retrieve Flight Recorder", "intel.sqf"]];
//intel.sqf[-1, {  task3 setTaskState "SUCCEEDED";  C130 removeAction (C130 getVariable "TAG_takeAction");}] call CBA_fnc_globalExecute;

I'll try this later today, thanks.

Share this post


Link to post
Share on other sites

That works perfect, thanks so much Deadfast and Hellfire for helping me get this task working, it was *I hope* the only thing stopping my mission from working properly.

So for the other more basic one, where I want to "pick up" a map off the floor, would it just be:

evi1 addaction ["pick up intel", "collect.sqf"];  

I take it that setvariable part in the other one is just for the TAG_takeaction part?

and then in the collect.sqf:

deletevehicle evi1;
[-1, {
  task4 setTaskState "SUCCEEDED";
}] call CBA_fnc_globalExecute; 

as deletevehicle is already global so it should disappear for everybody anyways?

Also should I only have the CBA globalexecute set to -1 for all clients and not -2 for all clients and the server? This mission will be played on a dedicated server.

Edited by clydefrog

Share this post


Link to post
Share on other sites

Yes, since the action ID could be different on each client you need to store it on the client. deleteVehicle is global so running that locally will work just fine.

I'm not familiar with CBA_fnc_globalExecute but you want to use whichever runs it everywhere (all clients and the server).

EDIT: I'd also like to use this opportunity to plug in my MultiTask script. An example mission that does exactly what you're after (nicking some documents) is included :)

Edited by Deadfast

Share this post


Link to post
Share on other sites
Yes, since the action ID could be different on each client you need to store it on the client.

Sorry, which bit of my post is this referring to?

Share this post


Link to post
Share on other sites
Sorry, which bit of my post is this referring to?

This part:

I take it that setvariable part in the other one is just for the TAG_takeaction part?

Share this post


Link to post
Share on other sites
This part:

Ok so I've done it right then, I did test that task before with somebody else and it did work so hopefully it's all fine. So you haven't used that CBA globalexecute thing before then? I take it you're just that good at this stuff that you don't need to be familiar with stuff to know how to use it properly? heh

Share this post


Link to post
Share on other sites
Not really, I just took it from what you posted :p

Haha yeah I suppose apart from that setVariable TAG_ stuff that I don't even understand what it does, and you layed it out properly for me.

Share this post


Link to post
Share on other sites

Oh, as for the TAG, you should replace that with an actual tag that you have registered.

Share this post


Link to post
Share on other sites
Oh, as for the TAG, you should replace that with an actual tag that you have registered.

Hmm, I haven't registered a tag on OFPEC as obviously I didn't even know what that thing did, but can I just call it whatever I want? e.g. CFROG?

Share this post


Link to post
Share on other sites
Hmm, I haven't registered a tag on OFPEC as obviously I didn't even know what that thing did, but can I just call it whatever I want? e.g. CFROG?

Well, it has to follow certain guidelines and CFROG happens to do just that :).

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  

×