daza 36 Posted August 10, 2009 I have a mission where i have an empty helicopter that needs to be stolen and brought back to a helipad on base. Its the last objective which will complete the mission. (It would be easy if it was just a extraction chopper, using waypoints in the editor, when it reaches the last waypoint the mission could end.) But if you use a empty vehicle you cant assign waypoints to it in the editor. This is going to be a coop mission. So im trying to make it work using some script code from an Arma1 mission i got working. But had to change some of the syntax. What i have in the Trigger: Activation when Blufor is present. 10 x 10 radius Type: end#1 Con: (alive ka1) or (alive ka2) and (player in ka1) or (player in ka2); act: tskObj3 setTaskState "SUCCEEDED"; [tskObj3] call mk_fTaskHint; The trigger accepts it no syntax errors. But when i run mission, to test it. It goes straight to the end of mission with debriefing. My unit i had to check trigger, wasnt even in the radius zone. The choppers are named correctly but are miles away, still empty. Ive tried looking for a Arma2 mission that has steal a vehicle and return it to point x. Didnt find anything i could look over how they did it. The only other thing i can think of to make it work is check distance between helimarker and vehicle. But i dont know how to do that, i tried with a(getmarkerpos "lzka" == b(getpos ka1); I keeping getting a missing ; error with that one. I dont know what im doing with that. But i think i have the right idea, but cant get it to work. Do you guys know of any missions or scripts can deal with a scenario like this? Or suggest how i can solve this problem? Surely something as simple as landing a chopper on a designated marker to complete an objective cant be this damn hard? :confused: Thanks for your help Daza Share this post Link to post Share on other sites
VanhA-ICON 11 Posted August 10, 2009 unPbo my "co12 Hijack" and see how it's done. :) http://forums.bistudio.com/showthread.php?t=76333 No big deal really. besides other conditions just group the chopper with trigger to be activated by it. Share this post Link to post Share on other sites
daza 36 Posted August 10, 2009 Thanks Vanha-icon. :) I will check it out! Share this post Link to post Share on other sites
nominesine 0 Posted August 10, 2009 Group [F2] the trigger with the empty helicopter. Open the trigger and notice that you now have a new option for activation. Select VEHICLE in the drop down menu. Done. Share this post Link to post Share on other sites
daza 36 Posted August 11, 2009 Thanks guys!! i managed to get it working! This is awesome. Just two questions VanHa-icon... How did you add the custom pic you had at the start of the mission? it was called "VA" in the resource menu, but its not in the default resource list. The other question is publicvariable. I know what it does (the server updates all the client machines) but how does it work exactly? the task was set to succeeded and the last line was publicVariable "Kolmas";Kolmas = true; no where else did i see that variable mentioned. How does the server update to the other clients that the task was indeed completed? Since im mainly going to focus on MP missions, i need to understand this better. Thanks for your help! Cheers Daza Share this post Link to post Share on other sites
VanhA-ICON 11 Posted August 11, 2009 Oh, those variables are only used as conditions for the ending trigger. You can do it some other ways also. I'm no whiz kid here either m8. The picture resource is defined by that "h" file. Only the resource control path is defined at description.ext. BR VanhA Share this post Link to post Share on other sites
nominesine 0 Posted August 11, 2009 publicVariable "Kolmas"; Kolmas = true; This is not the correct way to use publicVariable. This is: 1) Change the variable on one computer first 2) Broadcast the change to the clients afterwards Assuming that kolmas was false to begin with, the above code will only ensure that every client in the game continues to regard kolmas as being false, and then you change it to true on one computer only. The correct syntax would be: Kolmas = true; publicVariable "Kolmas" Share this post Link to post Share on other sites
daza 36 Posted August 12, 2009 This is not the correct way to use publicVariable. This is:1) Change the variable on one computer first 2) Broadcast the change to the clients afterwards Assuming that kolmas was false to begin with, the above code will only ensure that every client in the game continues to regard kolmas as being false, and then you change it to true on one computer only. The correct syntax would be: Kolmas = true; publicVariable "Kolmas" I never did see the name of that public variable mentioned before or after except there (what i quote in my previous post). So still trying to grasp how it works... So this Pvariable relates to the task having succeeded in the mission, right? How would that Pvariable link that objtask so thatthe client machines gets the update on that task being "succeeded". Ok, the public variable is a flag in itself, changing from false to true. But do you need some more script lines once that variable becomes true to actually update the client machines that the task has been done. Or does that line you corrected, is enough? sort of syncing or putting a tag on that objtask with a public variable, which the server then automatically updates the other machines because its a public variable? am i on the right path with this? If i can work this out, then i can be sure to have my MP games running smoothly. Thanks for your help Nominesine :) Share this post Link to post Share on other sites
nominesine 0 Posted August 12, 2009 (edited) I'm not sure I understand your problem correctly, but this is how it works. Forgive me if my answer seems obvious. I'm not trying to lecture you, just trying to keep it on a basic level: Problem: When you change a variable, the change is sometimes just recognized on the client where the change takes place. This can be a problem in MP games. Example 1: If you change a variable in the activating line of a waypoint, the change will only be registered by players/client in the group that triggered the waypoint. If the unit is completely AI controlled the change will only happen on the server. Example 2: Lets say that you have started a script using the addAction command. This script will only run on the client where the player who triggered the action is playing. Any variables changed in the script will then register on his machine only. The server and the other players won't know what is happening. The publicVariable command is the solution to the above problem. It can be used to broadcast the variable to all clients in the network. Example 3: myVariable = true; publicVariable "myVariable" This will be recognized on all machines. Example 4: myVariable = true; This may only be recognized on the machine where the command was given. Generally speaking variables and commands behaves like this: Triggers: An editor placed trigger usually fires simultaneously on all machines. Hence varaibles changed in a triggers on activation line will be recognized by all clients in the network. Including the server. Scripts started from triggers will run on all machines. The only exception to this rule is if you fiddle with the condition line of the trigger. As long the condition is left on it's default this, all triggers can be regarded as a MP safe. Waypoints: Changes made in the activation line of waypoints are local. Scripts started from waypoints may not run on all computers. Some clients will miss varable changes issued here. Hence waypoints are not MP-safe. Use publicVariable. Scripts: The init.sqs or init.sqf is run on all clients including the server upon mission start. It can therefore be used to change variables for all players simultaneously. It is MP-safe. Scripts started within missions are not MP-safe, unless you start them from a trigger (see above). Happy editing :) EDIT: OFPEC Forum has an entire board dedicated to resolving Multiplayer Issues. It's a very good place to ask for help with all MP questions, basic as well as advanced. Just follow this link. Edited August 12, 2009 by nominesine Share this post Link to post Share on other sites
daza 36 Posted August 12, 2009 (edited) Thanks for your reply. Some very handy info there. What im trying to understand though, is How to correctly use a public variable. (i dont mean syntax). Ok an example for MP. Lets say Task1 is to take one enemy helicopter, and destroy the second one. A Player takes one helicopter and blows the other up. Task succeeded! As you said a public variable is needed in order to update the other client machines that this task has been met.(i got that bit). But how does the public variable actually update the other machines that taskobj1 has been completed? Do i need to associate task1 with that variable in the init.sqf? so when its switches to true the server knows what it relates to? thats what im trying to figure out. Or does it know what it relates to because its within the trigger itself?? sort of like grouping the variable with the trigger/task...? Thanks for your patience. I have one other problem in relation to Task hints..im using tskobj1 setTaskState "SUCCEEDED"; nul = [objNull, ObjNull, tskobj1, "Failed"] execVM "CA\Modules\MP\data\scriptCommands\taskHint.sqf";Kola = true; publicVariable "Kola"; When the condition is met, it displays "Task Failed: any" Its the same with the others, whether its a succeeded one. I thought it would use the title of task i defined in the briefing.sqf. "any" must be a default thing when there is no data/title to display. Any ideas why its just saying any? or isnt it recognising my briefing file? the briefing file is a copied one from a previous mission. I changed the details/instructions/tasks etc But it doesnt display when i run it in Arma as a pbo mission. This happened with another mission too, and i then it started to show. I couldnt see any differences with the template. If i have a comma or " missing in the briefing file will it not display at all? and will that cause taskhint not to display properly either? I suppose my other question should go into another thread? but it all relates to the same mission and tasks. Thanks again for your valuable help, once i find out the answers to these questions i can finalise my missions ive been working on. Daza ---------- Post added at 10:16 PM ---------- Previous post was at 10:01 PM ---------- tskLZ= player createSimpleTask["Secure the chopper"];tskLZ setSimpleTaskDescription["Fly the hind to carrier", "LZ", "HUD LZ"]; tskLZ setSimpleTaskDestination (getMarkerPos "home"); if (isNil "Kolmas") then { tskLZ settaskstate "Created"; } else { tskLZ settaskstate "Succeeded"; "home" setMarkerColor "ColorGreen"; Update. This is from that Hijack mission. I found this in the briefing file. So i know understand how the public variable works! However in that Hijack mission there is no public variables for failures...surely there needs to be some for those as well? im guess so. So will create a new publicvariable for failures too. Just the Hint task problem i mentioned before to solve now. :D Edited August 12, 2009 by Daza Share this post Link to post Share on other sites
nominesine 0 Posted August 12, 2009 tskobj1 setTaskState "SUCCEEDED"; nul = [objNull, ObjNull, tskobj1, "Failed"] execVM "CA\Modules\MP\data\scriptCommands\taskHint.sqf";Kola = true; publicVariable "Kola"; Let's leave the objNull end execVM part of your command line for a while, ok? Here's a straight forward (and working) example based on what you want to achieve. Assumption: Player must capture helicopter1 and destroy helicopter2. It's a MP COOP game and any player may complete the task. Mission Designers Problem: You must fins a MP-safe way to decide when the first helicopter is captured and the second one is destroyed. Solution: If a player is piloting helicopter1 it's only fair to say that he has indeed captured it. Make a trigger: CONDITION: driver helicopter1 == player ACTIVATION: heloCaptured = true; publicVariable "heloCaptured" player is a handle that refers to any unit played by a human. As you might have guessed the above trigger will therefore only fire on one machine (I have fiddled with the condition line and replaced this). But since I use a publicVariable heloCaptured will nevertheless be true on all machines. Now make a second trigger, to check if the second helo is detroyed. CONDITION: !(alive helicopter2) ACTIVATION: heloDestroyed = true A unit that is killed will be registered as dead by all machines in the network. Hence no need to broadcast a public variable this time. Now it's time to tick off the task objective in the briefing. make a thrid trigger: CONDITION: heloCaptured AND heloDestroyed ACTIVATION: tskobj1 setTaskState "SUCCEEDED"; Since this trigger will now fire on all clients the task will be ticket off on all machines more or less simultaneously. You may face a discrepancy of up to three seconds between server and client, but that is a game engine limitation. It cannot be affected. Share this post Link to post Share on other sites
daza 36 Posted August 12, 2009 Thanks again nominesine :) I fully understand it now, and also that there isnt one way to skin a cat. Thanks for your patience with me getting it sorted. The only problem i got now, is the briefing wont show. Ive used a previous briefing template, redid the description for tasks and markernames etc. But it wont show. I will post this problem in the thread where that briefing manager was announced. Daza Share this post Link to post Share on other sites
daza 36 Posted December 27, 2009 Hi guys, I'm reworking this mission (in relation to this thread i started a while back) as a TvT MP mission. I have the public variables set to change status of objectives for JIP players within the briefing file. Here is a snippet from the briefing. // Secondary Objective tskObj2 = player createSimpleTask["Secondary: Destroy second KA50"]; tskObj2 setSimpleTaskDescription["Turn it into a pile of junk.", "Destroy second KA50","Destroy second KA50"]; //>---------------------------------------------------------< // Primary Objective tskObj1 = player createSimpleTask["Primary: Capture One KA50 and RTB"]; tskObj1 setSimpleTaskDescription["Objective located <marker name='obj1'>here</marker>. Have your best pilot fly the bird directly out of the hangar. Then take it back to base here <marker name='LZKA'>LZ</marker>.", "Capture 1 Ka50", "Capture 1 Ka50"]; player setCurrentTask tskObj1; }; if (isNil "kaa1") then { tskobj1 settaskstate "Created"; } else { tskobj1 settaskstate "Succeeded"; }; if (isNil "kaa2") then { tskobj2 settaskstate "Created"; } else { tskobj2 settaskstate "Succeeded"; }; case EAST: // REDFOR briefing goes here { }; So that if (isnil blahblah) is set within the West part of briefing, why am i getting an error on that upon respawning on the Guerrila side? and yet it there are no errors on first pass of briefing file at the start? (note: no objectives were achieved during the testing) When i die and respawn the briefing file is run again i encounter this error... Error in expression <skobj1 settaskstate "Created"; } else { tskobj1 settaskstate "Succeeded"; }; i> Error position: <tskobj1 settaskstate "Succeeded"; }; i> Error Undefined variable in expression: tskobj1 File C:\Users\Darian\Documents\ArmA 2 Other Profiles\Daza[NZ]\mpmissions\BlackSharkUprisingv1.Chernarus\briefing.sqf, line 69 Error in expression <skobj2 settaskstate "Created"; } else { tskobj2 settaskstate "Succeeded"; }; c> Error position: <tskobj2 settaskstate "Succeeded"; }; c> Error Undefined variable in expression: tskobj2 I have in the init file kaa1=false and kaa2=false. I guess i will have to use an eventhandler for JIP. Share this post Link to post Share on other sites