Jump to content
Sign in to follow this  
carlostex

Markers and JIP persistancy...with CBA_fnc_setMarkerPersistant

Recommended Posts

The same you did before renaming,

call compile preProcessFileLineNumbers "init_createMarkers.sqf";

Share this post


Link to post
Share on other sites

That was what i was doing before except the file name was fn_createMarkers. What does the file name have to do with anything? Is RV engine going to treat the file differently because i'm using fn_ vs init_? Makes no sense to me. Or were you just reffering to the fact of aesthetics or organization? Anyway since i agree that createMarkers is not a function "per se" i'll rename as init_ as i also agree it makes more sense but only from aesthetic POV.

---------- Post added at 05:43 PM ---------- Previous post was at 05:41 PM ----------

Ok, i' just re read your older post above. You said for "consistency sake". I get you.

Thanks Sickboy

---------- Post added at 05:55 PM ---------- Previous post was at 05:43 PM ----------

Another question Sickboy:

I find this code by you very useful:

//Code by Sickboy
TEX_INIT = false;
TEX_Server = false; 
TEX_Client = false; 
TEX_JIP = false;

if (playersNumber east + playersNumber west + playersNumber resistance + playersNumber civilian > 0) then { TEX_MP = true } else { TEX_MP = false };

if (isServer) then
{
 TEX_Server = true;
 if (!(isNull player)) then { TEX_Client = true };
 TEX_INIT = true;
} else {
 TEX_Client = true;
 if (isNull player) then
 {
     TEX_JIP = true;
     [] spawn { waitUntil { !(isNull player) }; TEX_INIT = true };
 } else {
     TEX_INIT = true;
 };
};

I removed it from init.sqf, because i want to keep it clean, so i've put it in a .sqf separate file. I'm initializing it with call compile as well.

Whaddya think? It's pretty much the same right? If there's any disadvantage let me know.

Share this post


Link to post
Share on other sites

NP, glad to help.

Re the init code - probably works but is old code (stems from A1 if I recall), and especially when using CBA can be replaced:

There's the SLX_XEH_MACHINE array in CBA, which is initialized and maintained:

https://dev-heaven.net/projects/cca/repository/revisions/develop/entry/addons/xeh/init_pre.sqf#L137

If you for instance want to wait for the player ready, you could:

[] spawn {
 waitUntil {SLX_XEH_MACHINE select 5};
 // do stuff with player
};

You can use select 8 instead to wait for all XEH PostInit eventhandlers to have ran as well.

Or even better, in description.ext, if you use Extended_PostInit_EventHandlers these are InitOnce, and execute on server usually just before the briefing, while on clients once the Player object is ready.

Share this post


Link to post
Share on other sites

Thanks Sickboy.

I still have to take a look at what scripts i'm using that needed that old code. I think i was using it to synchronize some editor placed markers for JIP players, and it was working, but since i'm using CBA and that awesome eventhandler and function you've helped me with i don't think i wil need it anymore. Anyway looks like there is some very neat stuff i can do in the description.ext with CBA stuff, i just need to understand better how things work. It's funny but i've been making missions since OFP days, then A1 never got my attention to make missions again. With A2 however since the end of 2010 i've been learning so much stuff specially regarding scripting (i never believed i would be able to do it) it's actually scary. And at the sime time there's still so much more to learn.

I'm very interested in optimization,scripting and mission wise, as i want to populate an island with around 350 AI and keep it running nicely. So i've removed all editor placed AI's which had tons of stuff in their inits, which i learned that even when they do not exist anymore their inits do still run. Now i'm spawning units from a script but each group is execVM a respawn script (AI_respawn by norrin i think) and as soon as i have all my mission tasks done i'll start working on that, maybe do all the groups respawns in a single script only.

Share this post


Link to post
Share on other sites

Read through this but a little confused now !

I have tried a few things :-

1) Pre placed Marker then move it via an addaction

in my ini i have

["currentpoint", true] call CBA_fnc_setMarkerPersistent;

it all works but if i disconnected and join again the marker is where it was pre placed?

also tried creating the marker each time

_movepoint = ["currentpoint",getpos can1,"PERSIST"] call CBA_fnc_createMarker;

This all works again in Hosted but when i disconnect and join no marker ?

Is it because it is through addaction ?

@CarlosTex can you post a working example how you got it working ?

Many thanks

Share this post


Link to post
Share on other sites

Where did you pre placed the marker? On the editor?

psvialli, don't forget that everything that you put in the editor runs again when JIP players connect. So everything goes back to its original position.

save this as "init_createMarkers.sqf";

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 setMarkerType _type;
_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
};

and this in the init.sqf of your mission:

call compile preProcessFileLineNumbers "init_CreateMarkers.sqf";

Then make sure you create the marker ONLY on the server:

if (isServer) then {
["markerxxx", [5835.1426,3076.4465], "ICON", "mil_objective", [0.5,0.5], "ColorRed"] call TEX_fnc_createMarker;
};

And finally one line below make it persistant:

["markerxxx", true] call CBA_fnc_setMarkerPersistent;

Edited by CarlosTex

Share this post


Link to post
Share on other sites

Nice going there Tex!

Once bug in code:

"markerxxx", [5835.1426,3076.4465], "ICON", "mil_objective", [0.5,0.5], "ColorRed"] call TEX_fnc_createMarker;

lacks initial '[':

["markerxxx", [5835.1426,3076.4465], "ICON", "mil_objective", [0.5,0.5], "ColorRed"] call TEX_fnc_createMarker;

Share this post


Link to post
Share on other sites

Right i usually make copy and paste errors. Thanks Sickboy.

Sickboy BTW, do you have any idea why AI groups do out of path planning errors in the RPT? I noticed that some of the AI groups in my mission were stopping to a dead halt, and when i checked the RPT's there were out of path planning errors... This is killing me... Those groups are being spawned by BIS_fnc_spawnGroup BTW....

Share this post


Link to post
Share on other sites

Many thanks for the Example / explanation however i am still having an issue not sure if it is because it is on a dedi server or because i am using it through an add action ?

my add action calls the script that has this

if (isServer) then {
["rallym", getpos playerss1_object, "ICON", "mil_objective", [0.5,0.5], "ColorRed"] call TEX_fnc_createMarker;
["rallym", true] call CBA_fnc_setMarkerPersistent;
};

When i test on hosted it works but when i try on Dedi it does not even create the marker? is it because of the add action ?

Share this post


Link to post
Share on other sites

Try this:

[-0, {["rallym", getpos playerss1_object, "ICON", "mil_objective", [0.5,0.5], "ColorRed"] call TEX_fnc_createMarker;
["rallym", true] call CBA_fnc_setMarkerPersistent;}] call CBA_fnc_globalExecute;

Also make sure you have initialised the eventhandler

Share this post


Link to post
Share on other sites

Actually you should just drop the isServer check, because the client is not a server, and the action is triggered on the player's machine.

Additionally, usage of CBA_fnc_globalExecute other than for debugging is not recommended.

In case you need to trigger remote events, better use CBA_fnc_addEventHandler and CBA_fnc_globalEvent,

this only sends parameters over the network, as opposed to globalExecute which also sends the code.

Edited by Sickboy

Share this post


Link to post
Share on other sites

I just tested it again but using a radio trigger this time and it worked as expected. but when using add action - no go ?!

Ill test it again with the above code , but it looks like it must be the add action ?

Share this post


Link to post
Share on other sites

What i gave you should work, but it would be better to follow Sickboy's advice. You can also use MP framework for the addaction.

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  

×