Jump to content

Photo
- - - - -

Markers and JIP persistancy...with CBA_fnc_setMarkerPersistant


  • Please log in to reply
37 replies to this topic
Thread Starter
CarlosTex
CarlosTex

    Master Sergeant

  • Members
  • 763 posts

Posted 23 April 2012 - 13:15 #1

Allright seems like when i try to do something on my own i seldom fail.

I need to set some markers i create while mission is progressing to be JIP persistant. I'm trying to achieve that with CBA_fnc_setMarkerPersistant but failing.

I better show how i'm calling stuff and whatnot so...

The script that creates the markers is called by an addaction attached to an object. Called with MP framework:

[player,_chair,rADDACTION,"Download Serial Numbers", "scripts\serials_hint.sqf",[_chair, player, 1, [_serialgen1,_serialgen2,_serialgen3,_serialgen4]],1,true,true,"","(_target distance _this) < 4"] call RE;

serials_hint.sqf:

//Script and code by CarlosTex
//Made for FORCEFIELDS
waitUntil{!(isNil "BIS_MPF_InitDone")};

_actionobj = _this select 0;
_actionid = _this select 2;
_serialvars = _this select 3;

_mkrgen1 = createMarker ["markerGEN1",[getpos enemygen1 select 0,getpos enemygen1 select 1]];
_mkrgen1 setMarkerShape "ICON";
"markerGEN1" setMarkerType "mil_warning";
"markerGEN1" setMarkerSize [0.5, 0.5];
"markerGEN1" setMarkerColor "ColorRed";

_mkrgen2 = createMarker ["markerGEN2",[getpos enemygen2 select 0,getpos enemygen2 select 1]];
_mkrgen2 setMarkerShape "ICON";
"markerGEN2" setMarkerType "mil_warning";
"markerGEN2" setMarkerSize [0.5, 0.5];
"markerGEN2" setMarkerColor "ColorRed";

_mkrgen3 = createMarker ["markerGEN3",[getpos civiliangen1 select 0,getpos civiliangen1 select 1]];
_mkrgen3 setMarkerShape "ICON";
"markerGEN3" setMarkerType "mil_warning";
"markerGEN3" setMarkerSize [0.5, 0.5];
"markerGEN3" setMarkerColor "ColorRed";

_mkrgen4 = createMarker ["markerGEN4",[getpos civiliangen2 select 0,getpos civiliangen2 select 1]];
_mkrgen4 setMarkerShape "ICON";
"markerGEN4" setMarkerType "mil_warning";
"markerGEN4" setMarkerSize [0.5, 0.5];
"markerGEN4" setMarkerColor "ColorRed";

		_text = parseText format[
        "<t color='#FFCC33'>Generators Serials</t><br/><t color='#D80000'>%1</t><br/><t color='#D80000'>%2</t><br/><t color='#FFFFFF'>%3</t><br/><t color='#FFFFFF'>%4</t><br/>", (_serialvars select 3) select 0, (_serialvars select 3) select 1, (_serialvars select 3) select 2, (_serialvars select 3) select 3];
        [nil,nil,rHINT,_text] call RE;
		
[player,_actionobj,rREMOVEACTION,_actionid] call RE; 

[_mkrgen1, true] call CBA_fnc_setMarkerPersistent;
[_mkrgen2, true] call CBA_fnc_setMarkerPersistent;
[_mkrgen3, true] call CBA_fnc_setMarkerPersistent;
[_mkrgen4, true] call CBA_fnc_setMarkerPersistent;

OK markers are created fine, in fact everything is fine, except if i leave the dedicated server and rejoin again the markers won't be there anymore. I think i'm using the correct syntax. CBA wiki says about this function:

Sets or unsets JIP persistency on a global marker.

Will broadcast event to server, if function is called on a client


No go, markers disappear when i JIP.... :confused:

EDIT: No RPT errors BTW....
Arma 3 and xAItment.

1 Sentence. 1 Erection. 1 Jizz.

Please vote for this:

http://dev-heaven.net/issues/13606

sickboy
sickboy

    Colonel

  • Members
  • 9947 posts

Posted 23 April 2012 - 13:22 #2

The syntax seems fine. I do believe we tested the function mostly with server-created markers, but I dont think it should matter.

Did you verify if the function calls are executed? E.g put a diag_log before and after the setMarkerPersistent lines and confirm in rpt, or use a hint etc.

Could you verify it in an empty test mission, with just one or two units, mission init.sqf with if (isServer) then { createMarker ...; ... setMarker...; .. call CBA_fnc_setMarkerPersistent };
And see how that goes?

If still issues, if you could please create a ticket and attach such test mission https://dev-heaven.n...ects/cca/issues, then I'll get right on it, see if we have a bug or what's going on :)

Edited by Sickboy, 23 April 2012 - 13:30.


Thread Starter
CarlosTex
CarlosTex

    Master Sergeant

  • Members
  • 763 posts

Posted 23 April 2012 - 13:33 #3

Hum, never used diag_log before so what's the syntax?

Should i just write diag_log before and after calling the functions or does it need diag_log plus anything? I'm using no handlers when calling the functions.

Also do you want me to test empty test mission on single player?
Arma 3 and xAItment.

1 Sentence. 1 Erection. 1 Jizz.

Please vote for this:

http://dev-heaven.net/issues/13606

sickboy
sickboy

    Colonel

  • Members
  • 9947 posts

Posted 23 April 2012 - 13:41 #4

For syntax please refer to the BIKI: http://community.bis...m/wiki/diag_log
e.g: diag_log "before marker"; and diag_log "after marker"; could perhaps be useful.

Testing in SinglePlayer won't help, since there's no JIP there ;-)

Thread Starter
CarlosTex
CarlosTex

    Master Sergeant

  • Members
  • 763 posts

Posted 23 April 2012 - 14:01 #5

Right i'll do that. I thought maybe you just wanted to see if it was doing it's thing on the server, since isServer in SP returns true.

---------- Post added at 03:01 PM ---------- Previous post was at 02:46 PM ----------

OK still have to do the empty mission test but i set up the diag_log like this:

diag_log format ["%1, %2, %3, %4, %5, %6, %7, %8", _d1, _d2, _d3, _d4, _mkrgen1, _mkrgen2, _mkrgen3, _mkrgen4]; 
_d1 = [_mkrgen1, true] call CBA_fnc_setMarkerPersistent;
_d2 = [_mkrgen2, true] call CBA_fnc_setMarkerPersistent;
_d3 = [_mkrgen3, true] call CBA_fnc_setMarkerPersistent;
_d4 = [_mkrgen4, true] call CBA_fnc_setMarkerPersistent;
diag_log format ["%1, %2, %3, %4, %5, %6, %7, %8", _d1, _d2, _d3, _d4, _mkrgen1, _mkrgen2, _mkrgen3, _mkrgen4];

Server RPT returned nothing on this. Arma2OA RPT returned:
"any, any, any, any, markerGEN1, markerGEN2, markerGEN3, markerGEN4"
"true, true, true, true, markerGEN1, markerGEN2, markerGEN3, markerGEN4"

So apparently markers are created fine, handler variables are undefined before the calls, and return true after the calls.

I JIP'ped and markers gone. :mad:
Arma 3 and xAItment.

1 Sentence. 1 Erection. 1 Jizz.

Please vote for this:

http://dev-heaven.net/issues/13606

sickboy
sickboy

    Colonel

  • Members
  • 9947 posts

Posted 23 April 2012 - 14:11 #6

Thanks a bunch, if can repro with the empty mission and put in ticket I'll try to look and resolve tonight or tomorrow.

Thread Starter
CarlosTex
CarlosTex

    Master Sergeant

  • Members
  • 763 posts

Posted 23 April 2012 - 14:27 #7

Good news for Sickboy, bad news for me.

When tested in empty mission, the marker kept persistant when i JIPped. Then i tried running the test mission again without calling CBA_fnc_setMarkerPersistant. I JIPped and marker was not there.

So i need to understand what i'm doing wrong. Apparently marker must be created on the server, otherwise no go. So i have to change my code. Any thoughts? Is it the way i'm calling?
Arma 3 and xAItment.

1 Sentence. 1 Erection. 1 Jizz.

Please vote for this:

http://dev-heaven.net/issues/13606

sickboy
sickboy

    Colonel

  • Members
  • 9947 posts

Posted 23 April 2012 - 14:35 #8

Thanks for testing it out :)

All looks good, it could be related to how markers are handled on the client. It is possible that if the client disconnects, the markers are completely removed,
I seem to remember something similar with markers someone places on the Map in the Map screen?

If it's the case, we should either document this limitation in the function, or we should update the function to deal with this situation, but on first sight it would not be very pretty.

As workaround, you could order the server to create the markers: Init.sqf
if (isServer) then {
   // Setup eventHandler
   ["carlos_markers", { _marker = _this select 0; _pos = _this select 1; ....; createMarker [_marker, _pos]; .... }] call CBA_fnc_addEventHandler; // Probably add markerType/Color/Shape etc

   // Helper function
   carlos_fnc_createMarker = { ["carlos_markers", _this] call CBA_fnc_localEvent }; // no need to broadcast, we're already on the server
} else {
   // Helper function
   carlos_fnc_createMarker = { ["carlos_markers", _this] call CBA_fnc_globalEvent }; // broadcast to execute on server
};

// To create a marker:
["markerName", [x,y,z]] call carlos_fnc_createMarker;

Edited by Sickboy, 23 April 2012 - 14:42.


Thread Starter
CarlosTex
CarlosTex

    Master Sergeant

  • Members
  • 763 posts

Posted 24 April 2012 - 08:40 #9

Thanks Sickboy. Yesterday i achived it changing the script:

//Script and code by CarlosTex
//Made for FORCEFIELDS
waitUntil{!(isNil "BIS_MPF_InitDone")};

_actionobj = _this select 0;
_actionid = _this select 2;
_serialvars = _this select 3;

[-0, {
_mkrgen1 = createMarker ["markerGEN1",[getpos enemygen1 select 0,getpos enemygen1 select 1]];
_mkrgen1 setMarkerShape "ICON";
"markerGEN1" setMarkerType "mil_warning";
"markerGEN1" setMarkerSize [0.5, 0.5];
"markerGEN1" setMarkerColor "ColorRed";

_mkrgen2 = createMarker ["markerGEN2",[getpos enemygen2 select 0,getpos enemygen2 select 1]];
_mkrgen2 setMarkerShape "ICON";
"markerGEN2" setMarkerType "mil_warning";
"markerGEN2" setMarkerSize [0.5, 0.5];
"markerGEN2" setMarkerColor "ColorRed";

_mkrgen3 = createMarker ["markerGEN3",[getpos civiliangen1 select 0,getpos civiliangen1 select 1]];
_mkrgen3 setMarkerShape "ICON";
"markerGEN3" setMarkerType "mil_warning";
"markerGEN3" setMarkerSize [0.5, 0.5];
"markerGEN3" setMarkerColor "ColorRed";

_mkrgen4 = createMarker ["markerGEN4",[getpos civiliangen2 select 0,getpos civiliangen2 select 1]];
_mkrgen4 setMarkerShape "ICON";
"markerGEN4" setMarkerType "mil_warning";
"markerGEN4" setMarkerSize [0.5, 0.5];
"markerGEN4" setMarkerColor "ColorRed";

[_mkrgen1, true] call CBA_fnc_setMarkerPersistent;
[_mkrgen2, true] call CBA_fnc_setMarkerPersistent;
[_mkrgen3, true] call CBA_fnc_setMarkerPersistent;
[_mkrgen4, true] call CBA_fnc_setMarkerPersistent;

}] call CBA_fnc_globalExecute;


		_text = parseText format[
        "<t color='#FFCC33'>Generators Serials</t><br/><t color='#D80000'>%1</t><br/><t color='#D80000'>%2</t><br/><t color='#FFFFFF'>%3</t><br/><t color='#FFFFFF'>%4</t><br/>", (_serialvars select 3) select 0, (_serialvars select 3) select 1, (_serialvars select 3) select 2, (_serialvars select 3) select 3];
        [nil,nil,rHINT,_text] call RE;
		
[player,_actionobj,rREMOVEACTION,_actionid] call RE;

Basically calling the marker creation and setpersistancy ONLY on the server.

And i do agree that maybe you guys do need to change or improve your documentation on this function.

The function you wrote there for me looks interesting enough. I'll probably move all my functions to separate scripts and compile them, than writing the same code all the time or have it in the init.sqf.

Thanks Sickboy!
Arma 3 and xAItment.

1 Sentence. 1 Erection. 1 Jizz.

Please vote for this:

http://dev-heaven.net/issues/13606

sickboy
sickboy

    Colonel

  • Members
  • 9947 posts

Posted 24 April 2012 - 09:01 #10

Sure mate np, glad you got it sorted. I've updated the function documentation, will be in a future update.

Thread Starter
CarlosTex
CarlosTex

    Master Sergeant

  • Members
  • 763 posts

Posted 24 April 2012 - 09:34 #11

Just for info:

I couldn't not make your function to work. I set it up on init.sqf like this:

if (isServer) then {
   // Setup eventHandler
   ["TEX_markers", 
	{ 
	_marker = _this select 0; //String
	_pos = _this select 1; //Array
	_shape = _this select 2; //String
	_type = _this select 3; //String
	_size = _this select 4; //Array 
	_color = _this select 5; //String
	_mkr = createMarker [_marker, _pos];
	_marker setMarkerShape _shape;
	_marker setMarkerSize _size;
	_marker setMarkerColor _color;
	}] call CBA_fnc_addEventHandler; //EventHandler	
	
   // Helper function
   TEX_fnc_createMarker = { ["TEX_markers", _this] call CBA_fnc_localEvent }; // no need to broadcast, we're already on the server
} else {
   // Helper function
   TEX_fnc_createMarker = { ["TEX_markers", _this] call CBA_fnc_globalEvent }; // broadcast to execute on server
};


// To create a marker:
["MarkerOne", (getmarkerpos "mkrpos"), "icon", "mil_warning", [0.5,0.5], "ColorGreen"] call TEX_fnc_createMarker;

No errors, no nothing, diag_log shows nothing wrong in RPT but marker is never created. It would be nice to have this function working but i won't cry for it.
Arma 3 and xAItment.

1 Sentence. 1 Erection. 1 Jizz.

Please vote for this:

http://dev-heaven.net/issues/13606

sickboy
sickboy

    Colonel

  • Members
  • 9947 posts

Posted 24 April 2012 - 09:48 #12

Does the "mkrpos" marker exist, and diag_log

(getmarkerpos "mkrpos") shows correct value?



Thread Starter
CarlosTex
CarlosTex

    Master Sergeant

  • Members
  • 763 posts

Posted 24 April 2012 - 09:48 #13

Yes it is editor place. And diag_log (getmarkerpos "mkrpos") returns as well.
Arma 3 and xAItment.

1 Sentence. 1 Erection. 1 Jizz.

Please vote for this:

http://dev-heaven.net/issues/13606

sickboy
sickboy

    Colonel

  • Members
  • 9947 posts

Posted 24 April 2012 - 09:50 #14

I suppose the main problem is that you do not use
_marker setMarkerType _type;


Thread Starter
CarlosTex
CarlosTex

    Master Sergeant

  • Members
  • 763 posts

Posted 24 April 2012 - 09:59 #15

OMG!!!! :couch:
Arma 3 and xAItment.

1 Sentence. 1 Erection. 1 Jizz.

Please vote for this:

http://dev-heaven.net/issues/13606

sickboy
sickboy

    Colonel

  • Members
  • 9947 posts

Posted 24 April 2012 - 10:01 #16

Haha, love the smiley :) No worries, happens to us all :P

Thread Starter
CarlosTex
CarlosTex

    Master Sergeant

  • Members
  • 763 posts

Posted 24 April 2012 - 10:02 #17

BTW, how beneficial do you consider if i decide to precompile it, since i'm probably gonna call it quite a few times during the mission?
Arma 3 and xAItment.

1 Sentence. 1 Erection. 1 Jizz.

Please vote for this:

http://dev-heaven.net/issues/13606

sickboy
sickboy

    Colonel

  • Members
  • 9947 posts

Posted 24 April 2012 - 10:21 #18

BTW, how beneficial do you consider if i decide to precompile it, since i'm probably gonna call it quite a few times during the mission?

It already is precompiled.

---------- Post added at 12:21 ---------- Previous post was at 12:15 ----------

The diff is in:

A) Not precompiled
Init: Nothing
Call:
[someParam, someParam2] call compile preProcessFileLineNumbers "functionName.sqf";

vs

B) Precompiled
Init:
TEX_functionName = { .... function content ... };
Which could also have been (no real difference other than directory structure):
TEX_functionName = compile preProcessFileLineNumbers "functionName.sqf"

Call:
[someParam, someParam2] call TEX_functionName;

Edited by Sickboy, 24 April 2012 - 10:21.


Thread Starter
CarlosTex
CarlosTex

    Master Sergeant

  • Members
  • 763 posts

Posted 24 April 2012 - 10:50 #19

OK, i wrote the function in a separate script called "fn_createMarkers.sqf".

So in the init.sqf i have:

call compile preProcessFileLineNumbers "functions\fn_createMarkers.sqf".

So this would be getting the same result because it is already precompiled?:

execVM "functions\fn_createMarkers.sqf"


I thought that preCompiling meant something like when you write a program in C# language and then compile it with GCC, ICC or Open64 compilers makes it faster because you're not running raw data (and obviously compiler also translates it into machine language). (Probably now you'll get that i understand 0 about programming). :confused:

So basically doing:
global or local variable = {code here};

already precompiles it?


EDIT: BTW when i tested my mission precompiling the function in the init.sqf and creating the markers using the function everything is working fine. But with your explanation i understand now that i also could have execVM "functions\fn_CreateMarkers.sqf" and it would be the same.

So what's the point of having the command if you can preCompile in the scripts instead?

Edited by CarlosTex, 24 April 2012 - 10:55.

Arma 3 and xAItment.

1 Sentence. 1 Erection. 1 Jizz.

Please vote for this:

http://dev-heaven.net/issues/13606

sickboy
sickboy

    Colonel

  • Members
  • 9947 posts

Posted 24 April 2012 - 11:32 #20

Nope you misunderstood me.

As said you already precompiled the function from the beginning by specifying it as TEX_name = { ... }, there is nothing more you need to do.
TEX_name = { ... }; comes down to the same as putting the code in a sqf and then using TEX_name = compile preProcessFileLineNumbers "file.sqf";

Especially don't use execVM if you are going to use it over and over, besides that it is to run scripts, and not to call functions that return anything.