FOX Dome 1 Posted March 10, 2013 (edited) So lets just start i have a Prob with that random Script stuff in A3-A i making a MP PvP Mission (Spec ops stuff^^) i have (so far) 4 Tasks and want that 1 of the 4 Task's is randomly chosen at mission start, so Every time you play the mission gets different. I tried a Few Scripts from A2/OA but somehow they ain't working or i am to stupid to use them right. (not New to ArmA scripting) The most other stuffs works Perfect but somehow the Randommission.sqf Dont Chose a task i have no clue what the error is, so i hope some of You script gods can help me a Little bit or show me a Better way to do that Thanks in advance Translated with Google (and my own bad english) init.sqf (realy empty since im stuck with that prob) if (isserver) then {execVM "Randommission.sqf";} so here is my Randommission.sqf hint "test"; _mission = switch (random floor(4)) do { // Main objective: Capture case 0: {execVM "taskb1.sqf"; }; // Main objective: Destroy case 1: {execVM "taskb2.sqf"; }; // infiltrate case 2: {execVM "taskb3.sqf"; }; // Supply case 3: {execVM "taskb4.sqf"; }; and this is one of my taskb.sqf's if (side player != west) exitWith {}; taskb2 = player createSimpleTask ["Main objective: Destroy"]; taskb2 setSimpleTaskDescription ["Destroy the Ka60 and kill the test pilot <br />", "Main objective : Destroy", ""]; Edited March 10, 2013 by rAMMY Share this post Link to post Share on other sites
Freddan962 1 Posted March 10, 2013 That's quite a interesting question, I'll see what I can come up with. Share this post Link to post Share on other sites
loyalguard 14 Posted March 10, 2013 I am not sure if you copied and pasted from your actual script or retyped your code here, but you are missing thread handles in front of execVM which could be causing the problems. e.g. null = [] execVM "taskb1.sqf"; Have you tried this? _mission = switch (random floor(4)) do { // Main objective: Capture case 0: {null = [] execVM "taskb1.sqf"; }; // Main objective: Destroy case 1: {null = [] execVM "taskb2.sqf"; }; // infiltrate case 2: {null = [] execVM "taskb3.sqf"; }; // Supply case 3: {null = [] execVM "taskb4.sqf"; }; Share this post Link to post Share on other sites
cuel 25 Posted March 10, 2013 You don't need script handles since init.sqf runs in scheduled environment. The problem is that you're doing random before floor. _mission = switch (floor (random 4)) do { Share this post Link to post Share on other sites
Desrat 0 Posted March 10, 2013 your script is only run on server? is that the correct outcome your looking for? Your referencing player as well which will fail on dedicated servers might wanna read these topics specifically regarding tasks and multiplayer https://community.bistudio.com/wiki/player https://community.bistudio.com/wiki/BIS_fnc_MP http://forums.bistudio.com/showthread.php?148176-Join-In-Progress-Tasks&p=2322498#post2322498 Share this post Link to post Share on other sites
FOX Dome 1 Posted March 10, 2013 (edited) Also no luck edit: ok thx for links than i will have to Read a few things (somehow logic if something just runs on server it maybe wont run in editor^^) edit2: so i have read the stuff but im still not Realy geting a Clue Edit3: also if someboddy has a Working version of a Random task Selection script pls give me a link^^ Edited March 10, 2013 by rAMMY Share this post Link to post Share on other sites
Inkompetent 0 Posted March 11, 2013 I am not sure if you copied and pasted from your actual script or retyped your code here, but you are missing thread handles in front of execVM which could be causing the problems. e.g. null = [] execVM "taskb1.sqf"; Loyalguard's post is generally good, but please, do not under ANY circumstances whatsoever, ever, use 'null' or 'nil' or any other existing variable/value as script handles. It is terribly bad practice. Instead make up something else. For example 'foo' is a common variable name for dummy-variables. Share this post Link to post Share on other sites
FOX Dome 1 Posted March 11, 2013 so I Played a little bit around with the script and changed a Few things you guys Posted but still no luck can someboddy provide a Small Working sample... i guess MP scripting isn't my strong side ^^ Share this post Link to post Share on other sites
cuel 25 Posted March 11, 2013 If you don't need the script handle for anything (such as terminate) you can just use 0 or any integer since they cannot be reassigned (you can't tell the engine that 0 is now 1) rAMMY I noticed that you were missing the closing curly braces for the switch. It's alot easier to see if you use a proper indent style :). This works. _mission = floor random 4 ; switch (_mission) do { // Main objective: Capture case 0: { [] execVM "taskb1.sqf"; }; // Main objective: Destroy case 1: { [] execVM "taskb2.sqf"; }; // infiltrate case 2: { [] execVM "taskb3.sqf"; }; // Supply case 3: { [] execVM "taskb4.sqf"; }; }; Share this post Link to post Share on other sites
FOX Dome 1 Posted March 11, 2013 A realy big thanks Cuel Works like a Charm Share this post Link to post Share on other sites