Jump to content
Sign in to follow this  
thedog88

another multiplayer addaction thread

Recommended Posts

i know i know theres tons of addaction threads but i promise i went through them. some have similarities but in the end turned out to be different. im not the best scripter so i might be wrong. anyways, i have a few questions in this endeavour but let me explain what im trying to do first. the main focus is to make this dedicated server and JIP ready.

a player approaches an object that was placed in the editor and is there the entire time. he gets an addaction to "search documents" or whatever. at that time he (and only this player) is put into an animation and has to wait until the searching is done. at that time a new task is broadcasted to the entire server and also spawns the task objects, for example destroy a helicopter. after the action is activated it needs to be deleted so that nobody else can activate it again. and of course once the helicopter is destroyed the task completes. also needs to be JIP compatible.

now, i have this working in mp non dedicated however with a few hiccups. my issues are that if anybody other than the group leader activates the action nobody else gets the task update. when the group leader does it (also the host of the mission) the task is broadcasted no problem. also the addaction is deleted for the person triggering it but others still have the option. the task end is made using a trigger, im not sure if that would cause dedicated server issues? the object with the addaction in its init, does it cause dedicated server issues? i almost forgot to mention this only needs to be activated once.

anyways here is how its setup and the codes i used, with some help from bad benson.

object's init line

intel2 = this addAction ["Search Paperwork", "missions\intel2.sqf"]; this setVectorup [0,0,0.1];

intel2.sqf

_id = _this select 2;
(_this select 0) removeaction (_this select 2);	


   0 = (_this select 1) spawn
   {
   _this switchmove "AinvPknlMstpSrasWrflDnon";
   sleep 1; _this enablesimulation false;
   sleep 10; _this enablesimulation true
   };

sleep 1; 
hint "Searching Documents .";
sleep 1; 
hint "Searching Documents ..";
sleep 1; 
hint "Searching Documents ...";
sleep 1; 
hint "Searching Documents .";
sleep 1; 
hint "Searching Documents ..";
sleep 1; 
hint "Searching Documents ...";
sleep 1; 
hint "Searching Documents .";
sleep 1; 
hint "Searching Documents ..";
sleep 1; 
hint "Searching Documents ...";
hint "You found a Document indicating a Weapons Cache Location.";
sleep 6;
hint "Your Tasks have been updated";
[
west,
["taskDestroycache", "The Enemy Stached some weapons in Tsoukalie. According to the documents found it supports Camp Maxwell and Air Station Mike-26. If we can Destroy the Cache the enemy will be weakend giving us a strategic advantage."
,"Destroy Weapons Cache", "", "assigned"]
] call FHQ_TT_addTasks;



cache1 = createVehicle ["Box_East_Wps_F", getmarkerpos "cachemark1", [], 0, "CAN_COLLIDE"];

triger condition

not alive cache1

trigger on activation line

hint "Good Job! The Cache is destroyed. Get back to the primary Objective"; ["taskdestroycache", "succeeded", "tsk1"] call FHQ_TT_markTaskAndNext;  deletemarker "mrk110"; deletemarker "112";

so again, addaction available to all units, until triggered, creates task as well as objective objects. preferably would like to avoid using the triggers to complete the tasks and put it into the script, but i wouldnt know where to begin. any help is appreciated.

thanks in advance

Edited by Thedog88

Share this post


Link to post
Share on other sites

For intel2.sqf, what's _this supposed to be? You're not using parameters in the addaction line it seems. I also suggest changing your sleep from 1 second to .5 in intel2.sqf, and also use hintSilent, as while as just make it loop twice instead of repeating the hint's multiple times.

Share this post


Link to post
Share on other sites

hey dog,

I just got something similar to the addaction completed where I am happy with how it works in hosted and SP games.

I can't help you with your tasks as they are difficult to make truly JIP compatible. Also be aware FHQ_TT is not respawn compatible as they don't use respawn in their missions.

Anyway, I hope I can help with the addaction

Now a little setup to do first.

You need to create the publicvariable "Searched" - this will be where we store a value (0 or 1) to show all players if the location has been searched. It will also hide the addaction to any player after it has been done.

Your intialisation will look like this for the intel object.

this setvariable ["Searched",0,true];intel2 = this addaction ["Search Paperwork","missions\intel2.sqf",[],2,false,false,"","((_target getvariable ""Searched"") == 0) "];

Then add below to your Intel2.sqf file.

(_this select 0) setvariable {"Searched",1,true];

It seems like a lot of work but those extra options in the addaction really help at times.

Share this post


Link to post
Share on other sites

attach action to the player instead of object this way only this player can use it

Share this post


Link to post
Share on other sites
For intel2.sqf, what's _this supposed to be? You're not using parameters in the addaction line it seems. I also suggest changing your sleep from 1 second to .5 in intel2.sqf, and also use hintSilent, as while as just make it loop twice instead of repeating the hint's multiple times.

the reason the hints are repeated is to show the player he is searching, the dots at the end of the message go from 1 to 3 and back to 1.

hey dog,

I just got something similar to the addaction completed where I am happy with how it works in hosted and SP games.

I can't help you with your tasks as they are difficult to make truly JIP compatible. Also be aware FHQ_TT is not respawn compatible as they don't use respawn in their missions.

Anyway, I hope I can help with the addaction

Now a little setup to do first.

You need to create the publicvariable "Searched" - this will be where we store a value (0 or 1) to show all players if the location has been searched. It will also hide the addaction to any player after it has been done.

Your intialisation will look like this for the intel object.

this setvariable ["Searched",0,true];intel2 = this addaction ["Search Paperwork","missions\intel2.sqf",[],2,false,false,"","((_target getvariable ""Searched"") == 0) "];

Then add below to your Intel2.sqf file.

(_this select 0) setvariable {"Searched",1,true];

It seems like a lot of work but those extra options in the addaction really help at times.

cool im gonna give this a shot tonight. i dont neet to take anything out of the sqf? just add this stuff in anywhere?

attach action to the player instead of object this way only this player can use it

i need every player to be able to use it, however it needs to disappear after anybody uses it.

thanks for quick info guys, gonna try whats suggested tonight when i get back from work. if anybody can help out with the task stuff (so i can take out fhq_tt) that would be great. sidenote, cba will be required due to my objects mod so im not sure if they have something for tasks?

Share this post


Link to post
Share on other sites

i need every player to be able to use it, however it needs to disappear after anybody uses it.

Then you dynamically add action to closest player this way you dont need to bother with adding it to the whole server then removing it from the whole server. Or use trigger.

Share this post


Link to post
Share on other sites
cool im gonna give this a shot tonight. i dont neet to take anything out of the sqf? just add this stuff in anywhere?

that is correct.

Share this post


Link to post
Share on other sites
that is correct.

now, im about to go ahead and give this a shot. i will have several of these addactions in the mission on different objects triggering different sidemissions. do i have to change a name or anything for the next addaction? maybe make it searched_1? or something like that?

EDIT: i tried out that script you wrote up kevsnotrev and im sad to report back with broken dreams :( when i loaded in with a buddy we both got the option to "search documents" however when we tried to actually use it it did nothing.

Edited by Thedog88

Share this post


Link to post
Share on other sites

Did you get any script errors? (use -showscripterrors - should be on by default with latest stable build) Or are you using the dev build?

Did the addaction go away after the action 'did nothing'?

Are all of the addactions the same type - search object type or are they different?

Share this post


Link to post
Share on other sites

ill try it out tonight and let you know. the addaction remained after pressing it though. im not using the dev build but im switching to it tonight most likely. all addactions will be the same concept, search documents to receive a sidemission.

Share this post


Link to post
Share on other sites

So here is what I would do

in intel2.sqf, at the top - replace

_id = _this select 2;
(_this select 0) removeaction (_this select 2);	

with

_id = _this select 2;
_netid = netID (_this select 0);
[[_netid,_id],"FNC_DOSEARCH",true, true] spawn BIS_fnc_MP;

Then in init.sqf, you will want to write the function

FNC_DOSEARCH={
_objID = _this select 0;
_actID = _this select 1;
_obj = objectFromNetID _objID;
_obj removeAction _actID;

hint "Your Tasks have been updated";
[
west,
["taskDestroycache", "The Enemy Stached some weapons in Tsoukalie. According to the documents found it supports Camp Maxwell and Air Station Mike-26. If we can Destroy the Cache the enemy will be weakend giving us a strategic advantage."
,"Destroy Weapons Cache", "", "assigned"]
] call FHQ_TT_addTasks;
};

you will want to remove that last bit from your intel2.sqf too

The basic concept here is that once called, the function FNC_DOSEARCH will run for every jip client (and every client currently connected) - I'm not sure how the FHQ_TT_addTasks function works - so this might not be something you want in the function, but you should have enough information now to do what you are trying to do. Let me know how it turns out :)

Share this post


Link to post
Share on other sites

cool, im about to give this a shot. ill let you know :) thanks for your reply

EDIT: this seems to have worked fairly well. im going to try it a few more times. i loaded into the mission, a buddy joined in and we went on a patrol to the first objective. i activated the addaction and the mission showed up for the both of us and the addaction was gone after for both of us as well. awesome :) thank you so much. i do however have a question. if i want to add multiple of these in, how would i go about it?

EDIT 2: could i just do this

make this

_id = _this select 2;
_netid = netID (_this select 0);
[[_netid,_id],"FNC_DOSEARCH",true, true] spawn BIS_fnc_MP;

this

_id = _this select 2;
_netid = netID (_this select 0);
[[_netid,_id],"FNC_DOSEARCH[b]1[/b]",true, true] spawn BIS_fnc_MP;

and make this

FNC_DOSEARCH={
_objID = _this select 0;
_actID = _this select 1;
_obj = objectFromNetID _objID;
_obj removeAction _actID;

hint "Your Tasks have been updated";
[
west,
["taskDestroycache", "The Enemy Stached some weapons in Tsoukalie. According to the documents found it supports Camp Maxwell and Air Station Mike-26. If we can Destroy the Cache the enemy will be weakend giving us a strategic advantage."
,"Destroy Weapons Cache", "", "assigned"]
] call FHQ_TT_addTasks;
};

this

FNC_DOSEARCH[b]1[/b]={
_objID = _this select 0;
_actID = _this select 1;
_obj = objectFromNetID _objID;
_obj removeAction _actID;

hint "Your Tasks have been updated";
[
west,
["taskDestroycache", "The Enemy Stached some weapons in Tsoukalie. According to the documents found it supports Camp Maxwell and Air Station Mike-26. If we can Destroy the Cache the enemy will be weakend giving us a strategic advantage."
,"Destroy Weapons Cache", "", "assigned"]
] call FHQ_TT_addTasks;
};

and then for each additional addaction change it to FNC_DOSEARCH2 etc?

Edited by Thedog88

Share this post


Link to post
Share on other sites

Yes, exactly, although I'm not sure if you can use numbers in function names.

Share this post


Link to post
Share on other sites
Yes, exactly, although I'm not sure if you can use numbers in function names.

worst case scenario ill label them phonetically. i really appreciate your help :)

Share this post


Link to post
Share on other sites

No problem at all.

By the way, you should probably move

[[_netid,_id],"FNC_DOSEARCH",true, true] spawn BIS_fnc_MP;

down under the code for your document search, that way it will wait until you are finished searching the object to update the tasks and send the hint.

edit:

to clarify:

intel2.sqf

_id = _this select 2;
_netid = netID (_this select 0);
   0 = (_this select 1) spawn
   {
   _this switchmove "AinvPknlMstpSrasWrflDnon";
   sleep 1; _this enablesimulation false;
   sleep 10; _this enablesimulation true
   };

sleep 1; 
hint "Searching Documents .";
sleep 1; 
hint "Searching Documents ..";
sleep 1; 
hint "Searching Documents ...";
sleep 1; 
hint "Searching Documents .";
sleep 1; 
hint "Searching Documents ..";
sleep 1; 
hint "Searching Documents ...";
sleep 1; 
hint "Searching Documents .";
sleep 1; 
hint "Searching Documents ..";
sleep 1; 
hint "Searching Documents ...";
hint "You found a Document indicating a Weapons Cache Location.";
sleep 6;

[[_netid,_id],"FNC_DOSEARCH1",true, true] spawn BIS_fnc_MP;



Share this post


Link to post
Share on other sites

triger condition

not alive cache1

correct should be:

!alive cache1

didn't read the whole thread, just corrected this. sorry if this was in no way helpfull. :P

Share this post


Link to post
Share on other sites

This works in mp and dedicated BUT not JIP. No big deal though.

Share this post


Link to post
Share on other sites

It should run the function for any JIP players - that is what the 2nd "true" is for in the array that we give to bis_fnc_mp.

Share this post


Link to post
Share on other sites

one way you can prevent people from using the action again is to delete the object.

Name it in the editor, then at the end of the search and the task completed:

deleteVehicle _intel;

Another way you can prevent them from using your action is to hide the action on use:

Number = unitName addAction [title, filename, (arguments, priority, showWindow, hideOnUse, shortcut, condition, positionInModel, radius, radiusView, showIn3D, available, textDefault, textToolTip)] ;

This is your complete addaction call source:

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

Notice one of the arguments is hideOnUse. Refer to below post hideOnUse is for just hiding the action when you use it.

For transmitting the tasks there is a couple of ways you can approach this:

- One way is to use a trigger. From experience and what I read you can use the trigger to transmit the task globally and I believe is JIP compatible.

The easiest way to accomplish this is to destroy the intel object, by deleting it. When the trigger detects its not alive anymore, with the condition !alive objectNameHere, the condition will fire and in the condition you have your new task assignment. You can also hint from the same trigger that the task has been updated.

Second way is continue what you were doing but use this for your tasks:

newTask = player createSimpleTask ["tankDestroycache"];

newTask setSimpleTaskDescription ["The Enemy Stached some weapons in Tsoukalie. According to the documents found it supports Camp Maxwell and Air Station Mike-26. If we can Destroy the Cache the enemy will be weakend giving us a strategic advantage.", "tankDestroycache", "Destroy Weapons Cache"];

player setCurrentTask newTask;

Then to send a hint out try this at the end of your script:

[["Task Updated"],"BIS_fnc_guiMessage",nil,true] spawn BIS_fnc_MP;

There is also the briefing modules in game, which allow you to set a condition of when they become active. I have not used them for a while, but I will look at them again and respond.

Edited by unknownx9

Share this post


Link to post
Share on other sites

Thanks for the great input. So far everything is working like a charm the way its setup, except jip which is no issue. I thought about deleting the object before hand but i dont thnk it fits the situation. I didnt know about hideonuse and will stash that in my brain for future reference thanks man; )

Share this post


Link to post
Share on other sites

Another way you can prevent them from using your action is to hide the action on use:

Number = unitName addAction [title, filename, (arguments, priority, showWindow, hideOnUse, shortcut, condition, positionInModel, radius, radiusView, showIn3D, available, textDefault, textToolTip)] ;

This is your complete addaction call source:

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

Notice one of the arguments is hideOnUse.

I think hideOnUse just closes the action menu after you select the item, setting it to FALSE leaves the action menu open.

Share this post


Link to post
Share on other sites
I think hideOnUse just closes the action menu after you select the item, setting it to FALSE leaves the action menu open.

hideOnUse: Boolean - (optional) If set to true, it will hide the action menu after selecting that action. If set to false, it will leave the action menu open and visible after selecting that action, leaving the same action highlighted, for the purpose of allowing you to reselect that same action quickly, or to select another action.

Might be right, not sure. Kind of useless in a way in my opinion if thats the case.

Edited by unknownx9

Share this post


Link to post
Share on other sites
hideOnUse: Boolean - (optional) If set to true, it will hide the action menu after selecting that action. If set to false, it will leave the action menu open and visible after selecting that action, leaving the same action highlighted, for the purpose of allowing you to reselect that same action quickly, or to select another action.

Might be right, not sure. Kind of useless in a way in my opinion if thats the case.

k0rd is correct, it will hide the menu. Sometimes you need to select the same item several times so you leave it open. Nothing is useless.

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  

×