Jump to content
Sign in to follow this  
Nielsen

Problem with JIP: PublicVariables and MP Framework not working.

Recommended Posts

Well, I just added the hints for myself since they are so, as you said yourself, convenient. You can have a hintless version by just deleting:

Lines 18-20

if !SHK_Jiptasks_JIP then {
 call compile format ["task%1 call SHK_showTaskHint",_this];
};

Line 43

task%1 call SHK_showTaskHint;

And the whole taskhint function:

SHK_showTaskHint = { // Task call SHK_showTaskHint
 private "_p";
 _p = switch (tolower(taskstate _this)) do {
   case "created": { [localize "str_taskNew", [1,1,1,1], "taskNew"] };
   case "current": { [localize "str_taskSetCurrent", [1,1,1,1], "taskCurrent"] };
   case "assigned": { [localize "str_taskSetCurrent", [1,1,1,1], "taskCurrent"] };
   case "succeeded": { [localize "str_taskAccomplished", [0.600000,0.839215,0.466666,1.000000], "taskDone"] };
   case "failed": { [localize "str_taskFailed", [0.972549,0.121568,0.000000,1.000000], "taskFailed"] };
   case "canceled": { [localize "str_taskCancelled", [0.750000,0.750000,0.750000,1.000000], "taskFailed"] };
 };
 taskHint [format [(_p select 0) + "\n%1", ((taskDescription _this) select 1)], (_p select 1), (_p select 2)];
};

Here you go:

SHK_createTask = { // "name" call SHK_createTask
 if isserver then {
   SHK_Jiptasks set [count SHK_Jiptasks,_this];
   publicvariable "SHK_Jiptasks";
 };
 if !isdedicated then {
   /* -- add extra tasks below -- */
   switch _this do {
     case "gohome": {
       taskGoHome = player createSimpleTask ["gohome"]; 
       taskGoHome setSimpleTaskDescription ["Time to go <marker name='mGoHome'>home</marker>.","Home",""]; 
       taskGoHome setTaskState "Assigned";
       player setcurrenttask taskGoHome;
       "mGoHome" setmarkeralphalocal 1;
     };
   };
   /* -- add extra tasks above -- */
 };
};
SHK_updateTask = { // ["name","state"] call SHK_updateTask
 if isserver then {
   SHK_Jiptasks set [count SHK_Jiptasks,_this];
   publicvariable "SHK_Jiptasks";
 };
 if !isdedicated then {
   call compile format ["task%1 settaskstate ""%2""",(_this select 0),(_this select 1)];
 };
};
SHK_Jiptasks_JIP = false;
if isserver then {
 SHK_Jiptasks = [];
} else {
 if (isnull player) then { SHK_Jiptasks_JIP = true };
};
if !isdedicated then {
 [] spawn {
   waitUntil {!isnull player};
   player createDiaryRecord ["Diary",["About","<br />Version: 20100703<br />Made by: Shuko of LDD Kyllikki<br />Contact: shuko@Quakenet<br />www.kyllikki.fi"]];
   /* -- add briefing tasks below -- */
   taskAmbush= player createSimpleTask ["ambush"];
   taskAmbush setSimpleTaskDescription ["A convoy of unbelievers is coming from the <marker name='mNorth'>north</marker>. Go and smite their necks!","Ambush",""];
   taskAmbush setTaskState "Assigned";
   player setcurrenttask taskAmbush;
   /* -- add briefing tasks above -- */

   if SHK_Jiptasks_JIP then {
     waituntil {!isnil "SHK_Jiptasks"};
     {
       switch (typename _x) do {
         case (typename ""): { _x call SHK_createTask };
         case (typename []): { call compile format ["task%1 settaskstate ""%2""",(_x select 0),(_x select 1)] };
       };
     } foreach SHK_Jiptasks;
     SHK_Jiptasks_JIP = false;
   };
 };
};

You can actually delete the whole SHK_createTask function in missions that you are not creating tasks after the mission has started.

Edited by Shuko

Share this post


Link to post
Share on other sites

Init.sqf not running might be caused by syntax error? For example with sqf files if you have a { or [ ro ( too much and then execVM the script, it doesn't get run. At least not from my experience.

Share this post


Link to post
Share on other sites
I have no knowledge of the impact that init.sqf has on cpu performance.

Didn't really mean pure processing power.

Arma 2's scripting engine has a feature that's job is to prevent starvation; if a "script" takes longer than 3ms to execute, it's pushed back of the queue. It can cause all kind of unwanted surprises.

---------- Post added at 02:29 AM ---------- Previous post was at 02:28 AM ----------

Init.sqf not running might be caused by syntax error? For example with sqf files if you have a { or [ ro ( too much and then execVM the script, it doesn't get run. At least not from my experience.

Indeed, nobody should edit missions without -showscripterrors.

Share this post


Link to post
Share on other sites

@Shk:

Thanks man. I'll propably go with the taskhint version for the most part. I actually do think its a neat feature, I was just illustrating a point.

As for the processing thing - AHA!. That is good to know. In that case, I figure it would be a good idea making the script a "higher priority". But as I said, I trust your judgement regarding if it is needed or not.

EDIT: Btw, what happens if you delay your script. I mean does the 3ms rule disregard sleep commands and such? Or is that something I should take into consideration when making functions?

@MuzzleFlash:

Yeah. I do have -showscripterrors on though. I remember when I first discovered that command some months back. I was like: WTF have I been doing! Spending countless hours looking through scripts for a missing ';' is something every missionmaker could surely do without. I dont really wanna think about what I could have accomplished with the time I've spent looking for scripterrors like the coding noob that I am, not knowing that this command (of course!) existed. :rolleyes:

Edited by Nielsen
added question

Share this post


Link to post
Share on other sites

EDIT: Btw, what happens if you delay your script. I mean does the 3ms rule disregard sleep commands and such? Or is that something I should take into consideration when making functions?

Nah, you can use sleep.

Share this post


Link to post
Share on other sites
Latest version with hints:

SHK_createTask = { // "name" call SHK_createTask
 if isserver then {
   SHK_Jiptasks set [count SHK_Jiptasks,_this];
   publicvariable "SHK_Jiptasks";
 };
 if !isdedicated then {
   /* -- add extra tasks below -- */
   switch _this do {
     case "gohome": {
       taskGoHome = player createSimpleTask ["gohome"]; 
       taskGoHome setSimpleTaskDescription ["Time to go <marker name='mGoHome'>home</marker>.","Home",""]; 
       taskGoHome setTaskState "Assigned";
       player setcurrenttask taskGoHome;
       "mGoHome" setmarkeralphalocal 1;
     };
   };
   /* -- add extra tasks above -- */
   if !SHK_Jiptasks_JIP then {
     call compile format ["task%1 call SHK_showTaskHint",_this];
   };
 };
};
SHK_showTaskHint = { // Task call SHK_showTaskHint
 private "_p";
 _p = switch (tolower(taskstate _this)) do {
   case "created": { [localize "str_taskNew", [1,1,1,1], "taskNew"] };
   case "current": { [localize "str_taskSetCurrent", [1,1,1,1], "taskCurrent"] };
   case "assigned": { [localize "str_taskSetCurrent", [1,1,1,1], "taskCurrent"] };
   case "succeeded": { [localize "str_taskAccomplished", [0.600000,0.839215,0.466666,1.000000], "taskDone"] };
   case "failed": { [localize "str_taskFailed", [0.972549,0.121568,0.000000,1.000000], "taskFailed"] };
   case "canceled": { [localize "str_taskCancelled", [0.750000,0.750000,0.750000,1.000000], "taskFailed"] };
 };
 taskHint [format [(_p select 0) + "\n%1", ((taskDescription _this) select 1)], (_p select 1), (_p select 2)];
};
SHK_updateTask = { // ["name","state"] call SHK_updateTask
 if isserver then {
   SHK_Jiptasks set [count SHK_Jiptasks,_this];
   publicvariable "SHK_Jiptasks";
 };
 if !isdedicated then {
   call compile format ["
   task%1 settaskstate ""%2"";
   task%1 call SHK_showTaskHint;
   ",(_this select 0),(_this select 1)];
 };
};
SHK_Jiptasks_JIP = false;
if isserver then {
 SHK_Jiptasks = [];
} else {
 if (isnull player) then { SHK_Jiptasks_JIP = true };
};
if !isdedicated then {
 [] spawn {
   waitUntil {!isnull player};
   player createDiaryRecord ["Diary",["About","<br />Version: 20100703<br />Made by: Shuko of LDD Kyllikki<br />Contact: shuko@Quakenet<br />www.kyllikki.fi"]];
   /* -- add briefing tasks below -- */
   taskAmbush= player createSimpleTask ["ambush"];
   taskAmbush setSimpleTaskDescription ["A convoy of unbelievers is coming from the <marker name='mNorth'>north</marker>. Go and smite their necks!","Ambush",""];
   taskAmbush setTaskState "Assigned";
   player setcurrenttask taskAmbush;
   /* -- add briefing tasks above -- */

   if SHK_Jiptasks_JIP then {
     waituntil {!isnil "SHK_Jiptasks"};
     {
       switch (typename _x) do {
         case (typename ""): { _x call SHK_createTask };
         case (typename []): { call compile format ["task%1 settaskstate ""%2""",(_x select 0),(_x select 1)] };
       };
     } foreach SHK_Jiptasks;
     SHK_Jiptasks_JIP = false;
   };
 };
};

Im having a problem with the hidden task to show up. It worked with your first version but the one above I can not get to work. I even just used what you have above and tried to pull it up with an alpha trigger.

ACT "gohome" call SHK_createTask

Here is my whole init.

server execVM "revive_init.sqf";
"find" setMarkerAlphalocal 0;

SSHK_createTask = { // "name" call SHK_createTask
 if isserver then {
   SHK_Jiptasks set [count SHK_Jiptasks,_this];
   publicvariable "SHK_Jiptasks";
 };
 if !isdedicated then {
   /* -- add extra tasks below -- */
   switch _this do {
     case "gohome": {
       taskGoHome = player createSimpleTask ["gohome"]; 
       taskGoHome setSimpleTaskDescription ["Time to go <marker name='mGoHome'>home</marker>.","Home",""]; 
       taskGoHome setTaskState "Assigned";
       player setcurrenttask taskGoHome;
       "mGoHome" setmarkeralphalocal 1;
     };
   };
   /* -- add extra tasks above -- */
   if !SHK_Jiptasks_JIP then {
     call compile format ["task%1 call SHK_showTaskHint",_this];
   };
 };
};
SHK_showTaskHint = { // Task call SHK_showTaskHint
 private "_p";
 _p = switch (tolower(taskstate _this)) do {
   case "created": { [localize "str_taskNew", [1,1,1,1], "taskNew"] };
   case "current": { [localize "str_taskSetCurrent", [1,1,1,1], "taskCurrent"] };
   case "assigned": { [localize "str_taskSetCurrent", [1,1,1,1], "taskCurrent"] };
   case "succeeded": { [localize "str_taskAccomplished", [0.600000,0.839215,0.466666,1.000000], "taskDone"] };
   case "failed": { [localize "str_taskFailed", [0.972549,0.121568,0.000000,1.000000], "taskFailed"] };
   case "canceled": { [localize "str_taskCancelled", [0.750000,0.750000,0.750000,1.000000], "taskFailed"] };
 };
 taskHint [format [(_p select 0) + "\n%1", ((taskDescription _this) select 1)], (_p select 1), (_p select 2)];
};
SHK_updateTask = { // ["name","state"] call SHK_updateTask
 if isserver then {
   SHK_Jiptasks set [count SHK_Jiptasks,_this];
   publicvariable "SHK_Jiptasks";
 };
 if !isdedicated then {
   call compile format ["
   task%1 settaskstate ""%2"";
   task%1 call SHK_showTaskHint;
   ",(_this select 0),(_this select 1)];
 };
};
SHK_Jiptasks_JIP = false;
if isserver then {
 SHK_Jiptasks = [];
} else {
 if (isnull player) then { SHK_Jiptasks_JIP = true };
};
if !isdedicated then {
 [] spawn {
   waitUntil {!isnull player};
   player createDiaryRecord ["Diary",["About","<br />Version: 20100703<br />Made by: Shuko of LDD Kyllikki<br />Contact: shuko@Quakenet<br />www.kyllikki.fi"]];
   /* -- add briefing tasks below -- */
   taskcamp = player createSimpleTask ["Prisoner Camp"];
   taskcamp setSimpleTaskDescription ["This is the last know Position of the Reporter Harris. We belive he is in the town middle of <marker name=""camp1"">Bastam and Rasman</marker> ", "Prisoner Camp", ""];
   taskcamp setTaskState "Created";
   taskMi8 = player createSimpleTask ["Destory Mi8"];
   taskMi8 setSimpleTaskDescription ["Move south along the town and get  to the location of the <marker name=""heli"">Presidental helicopter</marker> and destroy it. So Aziz cant escape from the region. The helicopter it probably camouflaged.", "Destroy Mi8", ""];
   taskMi8 setTaskState "Created";
   /* -- add briefing tasks above -- */

   if SHK_Jiptasks_JIP then {
     waituntil {!isnil "SHK_Jiptasks"};
     {
       switch (typename _x) do {
         case (typename ""): { _x call SHK_createTask };
         case (typename []): { call compile format ["task%1 settaskstate ""%2""",(_x select 0),(_x select 1)] };
       };
     } foreach SHK_Jiptasks;
     SHK_Jiptasks_JIP = false;
   };
 };
};

if(true) exitWith {}; 

Edited by mia389

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  

×