Jump to content
peeta

Removing Map Objects in MP

Recommended Posts

I've almost become suicidal over this script. What am I doing wrong? The object here is that all terrain objects within the "markx" markers (they are ellipses) will be hidden. This works fine and dandy in SP (play scenario through the Editor) but will not work in a dedicated server environment.

 

init.sqf

// Removing map objects script
_removeObjects = compile loadFile "\scripts\removeMapObjects.sqf";
_null = [["mark1","mark2","mark3","mark4","mark5","mark6","mark7","mark8","mark9","mark10","mark11","mark12","mark13","mark14","mark15","mark16","mark17","mark18","mark19"], "_removeObjects", false, true] call BIS_fnc_MP;

removeMapObjects.sqf

_markerArray = _this select 0;

{
_terrainobjects = nearestTerrainObjects [(getMarkerPos _x),[],(getMarkerSize _x)select 0];
{hideObjectGlobal _x} forEach _terrainobjects;
}forEach _markerArray;

Share this post


Link to post
Share on other sites

 

I've almost become suicidal over this script. What am I doing wrong? The object here is that all terrain objects within the "markx" markers (they are ellipses) will be hidden. This works fine and dandy in SP (play scenario through the Editor) but will not work in a dedicated server environment.

 

init.sqf

// Removing map objects script
_removeObjects = compile loadFile "\scripts\removeMapObjects.sqf";
_null = [["mark1","mark2","mark3","mark4","mark5","mark6","mark7","mark8","mark9","mark10","mark11","mark12","mark13","mark14","mark15","mark16","mark17","mark18","mark19"], "_removeObjects", false, true] call BIS_fnc_MP;

removeMapObjects.sqf

_markerArray = _this select 0;

{
_terrainobjects = nearestTerrainObjects [(getMarkerPos _x),[],(getMarkerSize _x)select 0];
{hideObjectGlobal _x} forEach _terrainobjects;
}forEach _markerArray;

I could be totally off here, but this is what I think.  I don't think you need to use BIS_fnc_MP.  

 

When a player joins in, they should download and run init.sqf on their PC, so there is no need for BIS_fnc_MP unless you want to run it on every other client also, whenever someone joins.  So the server would run the script.  Then player 1 joins, and the server and player 1 runs the script again.  Then player 2 joins, and now the server, player 1, and player 2 run the script.  

 

I don't think you need to do that.  If the effects of hideObjectGlobal are global, then you should only have to run it once on one machine.  Otherwise you are just being super redundant and using up causing needless network traffic.  Try just checking if init.sqf is running on the server (it will run once on every machine that loads the map) then if so, running the function from init.sqf without passing it to BIS_fnc_MP

 

So you could try replacing everything you have posted in init.sqf with just this :

if (isServer) then {
["mark1","mark2","mark3","mark4","mark5","mark6","mark7","mark8","mark9","mark10","mark11","mark12","mark13","mark14","mark15","mark16","mark17","mark18","mark19"] call (compile loadfile "\scripts\removeMapObjects.sqf"); 
};

Share this post


Link to post
Share on other sites

 

I could be totally off here, but this is what I think.  I don't think you need to use BIS_fnc_MP.  

 

When a player joins in, they should download and run init.sqf on their PC, so there is no need for BIS_fnc_MP unless you want to run it on every other client also, whenever someone joins.  So the server would run the script.  Then player 1 joins, and the server and player 1 runs the script again.  Then player 2 joins, and now the server, player 1, and player 2 run the script.  

 

I don't think you need to do that.  If the effects of hideObjectGlobal are global, then you should only have to run it once on one machine.  Otherwise you are just being super redundant and using up causing needless network traffic.  Try just checking if init.sqf is running on the server (it will run once on every machine that loads the map) then if so, running the function from init.sqf without passing it to BIS_fnc_MP

 

So you could try replacing everything you have posted in init.sqf with just this :

if (isServer) then {
["mark1","mark2","mark3","mark4","mark5","mark6","mark7","mark8","mark9","mark10","mark11","mark12","mark13","mark14","mark15","mark16","mark17","mark18","mark19"] call (compile loadfile "\scripts\removeMapObjects.sqf"); 
};

Yeah, that was a negative. :(

Share this post


Link to post
Share on other sites

initServer.sqf:

peeta_fnc_removeMapObjects = {
	{
		_position = getMarkerPos _x;
		_size = getMarkerSize _x select 0;
		{hideObjectGlobal _x} forEach nearestTerrainObjects [_position, [], _size];
	} forEach _this;
};

_hideObjectMarkers = ["mark1","mark2","mark3","mark4","mark5","mark6","mark7","mark8","mark9","mark10","mark11","mark12","mark13","mark14","mark15","mark16","mark17","mark18","mark19"];

_hideObjectMarkers call peeta_fnc_removeMapObjects;
  • Like 3
  • Thanks 1

Share this post


Link to post
Share on other sites

 

initServer.sqf:

peeta_fnc_removeMapObjects = {
	{
		_position = getMarkerPos _x;
		_size = getMarkerSize _x select 0;
		{hideObjectGlobal _x} forEach nearestTerrainObjects [_position, [], _size];
	} forEach _this;
};

_hideObjectMarkers = ["mark1","mark2","mark3","mark4","mark5","mark6","mark7","mark8","mark9","mark10","mark11","mark12","mark13","mark14","mark15","mark16","mark17","mark18","mark19"];

_hideObjectMarkers call peeta_fnc_removeMapObjects;

So, with this does a function need to be made in the description and have the function script point towards the initserver.sqf? because just having it as is did not fix our issue.

Share this post


Link to post
Share on other sites

Then something else is wrong with your server.  I took that code as is, put it in the initServer.sqf file.  Put down 19 markers and uploaded it to a dedicated server.  I ended up with 19 holes in the forest.

 

http://imgur.com/a/gsZgx

Share this post


Link to post
Share on other sites

Then something else is wrong with your server.  I took that code as is, put it in the initServer.sqf file.  Put down 19 markers and uploaded it to a dedicated server.  I ended up with 19 holes in the forest.

This does indeed work now. Appreciate the help bro!

Share this post


Link to post
Share on other sites

@kylania Trying to get this to work with triggers, without having to define an array of trigger names in the script.

Trigger's "On activation":

this call peeta_fnc_removeMapObjects;

 

InitServer.sqf:

peeta_fnc_removeMapObjects = {
	{
		_position = position _x;
		_size = triggerArea _x select 0;
		{hideObjectGlobal _x} forEach nearestTerrainObjects [_position, [], _size];
	} forEach _this;
};

The reason I'm using triggers is because I can visually see the area affected in the editor and I don't have to add a marker to an array each time I want to add another area to clear.

 

Any idea what I'm doing wrong?

Share this post


Link to post
Share on other sites

You might not get an answer from Kylania. He has been absent from the forum since the end of last year.

Rumour has it he's backpacking in the high Andes.

  • Haha 2

Share this post


Link to post
Share on other sites
On 6/5/2018 at 10:06 PM, Drift_91 said:

@kylania Trying to get this to work with triggers, without having to define an array of trigger names in the script.

Trigger's "On activation":


this call peeta_fnc_removeMapObjects;

 

InitServer.sqf:


peeta_fnc_removeMapObjects = {
	{
		_position = position _x;
		_size = triggerArea _x select 0;
		{hideObjectGlobal _x} forEach nearestTerrainObjects [_position, [], _size];
	} forEach _this;
};

The reason I'm using triggers is because I can visually see the area affected in the editor and I don't have to add a marker to an array each time I want to add another area to clear.

 

Any idea what I'm doing wrong?


Dude you don't even need to script anything anymore. 
Just go to modules, environment, hide terrain objects and drop that module down, not only do you get a real time representation but you can also resize it super easy. It's possibly the best module ever.
 

 

Edited by JD Wang
added video I found
  • Like 1

Share this post


Link to post
Share on other sites
On 2018-06-05 at 6:16 AM, Tankbuster said:

You might not get an answer from Kylania. He has been absent from the forum since the end of last year.

Rumour has it he's backpacking in the high Andes.

Ah, alright. Hope he's doing well. Last I'd been on the forums he was active and I'm a fan of how clean his code is.

On 2018-06-06 at 7:34 AM, JD Wang said:

Dude you don't even need to script anything anymore. 
Just go to modules, environment, hide terrain objects and drop that module down, not only do you get a real time representation but you can also resize it super easy. It's possibly the best module ever.

Oh wow, I feel silly now. Has this been around since 3DEN first came out? I recall glancing over that module a few times but had no idea what it did and I assumed it was added by some mod I had installed. I'll check it out right now.

Share this post


Link to post
Share on other sites
1 hour ago, Drift_91 said:

Ah, alright. Hope he's doing well. Last I'd been on the forums he was active and I'm a fan of how clean his code is.

 

 

Yeah me too. One of the good guys.

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

×