Jump to content
  • 0

scripting join in progress markers?


MassAsster

Question

for giggles - we have a marker on the map called " MainMarker "

 

I want to pick up the information from the marker and recreate the marker for the player who just joined...

 

 

soo, in my Init i write

onPlayerConnected "[_id, _name] execVM ""jipmarkers.sqf""";  // Prep my JIP side mission markers

-  in my jipmarkers.sqf i write...

private ["_MainMarkerb","_pos"];

    _pos = getMarkerPos "MainMarker";
    _MainMarkerb = createMarker["MainMarker2", _pos];
    _MainMarkerb setMarkerColor "ColorOrange";
    _MainMarkerb setMarkerShape "ELLIPSE";
    _MainMarkerb setMarkerBrush "Grid";
    _MainMarkerb setMarkerSize [100,100]

 

 

 

 

anyone see a better way to go about this or - is this method incorrect?

Link to comment
Share on other sites

10 answers to this question

Recommended Posts

  • 0

I thought it would do that by itself because most global command are run on a JIP client even if you run that command before they join. So usually the game does that for you, so again did you even test it if you have to do that? :)

If the marker is always visible you can add it in the mission

Link to comment
Share on other sites

  • 0

Yeah ive tested a few diff methods for attempting to pass the marker on to new players - none of them seem to work...

 

the markers are being created via script

	_MainMarker = createMarker ["MainMarker", Ccoords];
	_MainMarker setMarkerColor "ColorGreen";
	_MainMarker setMarkerShape "ELLIPSE";
	_MainMarker setMarkerBrush "Grid";
	_MainMarker setMarkerSize [175,175];

and being that Ccoords was set as a public variable - i thought i could tap into that - and simply re-run the code posted above to re-create the marker for the new guy..

 

but alas - no luck so far...

Link to comment
Share on other sites

  • 0

If nothing works there is always the file "dayz_server\compile\server_playerLogin.sqf" (inside the file dayz_server.pbo obviously), which will be executed whenever a players logs in.

So following the last command at the bottom of the file

(owner _playerObj) publicVariableClient "dayzPlayerLogin";

that means the server will send a public variable of the name "dayzPlayerLogin" to the connected client/player. wherever that is read on the client you can add the code you want I think.

Funny thing is I can't find the place where the client receives that variable, it should be something like:

 "dayzPlayerLogin" addPublicVariableEventHandler { ... };

but there is nothing like that in the client code, weird.. maybe you can find it... :o

 

You can still add your own variable and send it to the player.. maybe^^

Link to comment
Share on other sites

  • 0
_preplacedmkr = MainMarker;

_markname = "MainMarker";

objmkr = [_markname, _preplacedmkr]; publicVariable "objmkr";



_preplacedmkr2 = MainMarker75;

_markname2 = "MainMarker75";

objmkr2 = [_markname2, _preplacedmkr2]; publicVariable "objmkr2";


onPlayerConnected {"MainMarker" setMarkerPos (getMarkerPos "MainMarker")};

if (isServer) then 

{

	"objmkr" addPublicVariableEventHandler 

	{
	

	createMarker [((_this select 1) select 0), position ((_this select 1) select 1)];

	MainMarker setMarkerColor "ColorGreen";

	MainMarker setMarkerShape "ELLIPSE";

	MainMarker setMarkerBrush "Grid";

	MainMarker setMarkerSize [175,175];



	};

};



onPlayerConnected {"MainMarker75" setMarkerPos (getMarkerPos "MainMarker75")};

if (isServer) then 

{

	"objmkr2" addPublicVariableEventHandler 

	{
	

	createMarker [((_this select 1) select 0), position ((_this select 1) select 1)];

	MainMarker75 setMarkerColor "ColorRed";

	MainMarker75 setMarkerShape "ELLIPSE";

	MainMarker75 setMarkerBrush "Grid";

	MainMarker75 setMarkerSize [100,100];



	};

};


this code works for the marker75  - but not for the other...  

 

 

also throws errors

 




5:31:13 Error in expression <ateMarker [((_this select 1) select 0), position ((_this select 1) select 1)];
M>
 5:31:13   Error position: <position ((_this select 1) select 1)];
M>
 5:31:13   Error Generic error in expression
 5:31:13 File mpmissions\__cur_mp.chernarus\init.sqf, line 150
 5:31:13 Error in expression <ateMarker [((_this select 1) select 0), position ((_this select 1) select 1)];
M>
 5:31:13   Error position: <position ((_this select 1) select 1)];
M>
 5:31:13   Error Generic error in expression
 5:31:13 File mpmissions\__cur_mp.chernarus\init.sqf, line 164
Link to comment
Share on other sites

  • 0

Seems like that is not the whole script since the error says line 150 but your script only has 70... so add line numbers in your post (when you paste code here specify the starting line number) or lets see the whole script :D

As far as I can see your code executes the marker code only on the server, but every time a player connects.. that is weird :D
Anyway I have another idea how you can solve this, problem is with your copy & paste stuff it seems you don't know what you are doing, no offense :D

So my idea is in onPlayerConnected {} event ask the server for the markers, I put in examples for the code, but it's not tested:

  • when a player connects ask the server for a list of all "global markers you have added (the server has to keep a list of them of course)
    onPlayerConnected {
    	sendMeTheMarkerList = player; // you have to send an object so the server knows where the request comes from
    	publicVariableServer "sendMeTheMarkerList"; // sends the request to the server only
    };
  • server sends back the marker list to the client
    "sendMeTheMarkerList" addPublicVariableEventHandler {
    	_player = _this select 1;
    	_owner = owner _player;	
           markerList = [["marker1", [0,0,0], ...], ...]; // marker list with all information needed, id, position, other stuff like size and color
    	_owner publicVariableClient "markerList"; // sends the list back to the client
    };
  • client can call createMarkerLocal and the other commands, so the marker will be local only for the client
    "markerList" addPublicVariableEventHandler {
    	_markerList = _this select 1;	// do something with the markers
    	{
    		_marker = createMarkerLocal [_x select 0, _x select 1];	// other marker commands
    	} _markerList;
    };

In theory that should work and is pretty simple in ArmA scripting.
Maybe you can even skip steps 1 and 2, and the server can just send the marker list when a client connects, without him asking for it...

Link to comment
Share on other sites

  • 0
As far as I can see your code executes the marker code only on the server, but every time a player connects.. that is weird

 

 

That's correct. Markers are put down by the "DayZ Mission System" - but these markers are lost on players who join after the markers are created, or who die and have to reconnect. So I am attempting to fetch the markers,

 

onPlayerConnected {"MainMarker" setMarkerPos (getMarkerPos "MainMarker")};

 

 

and pass them back to the players who do not have them, hence the exec of the code only on player connect.

 

It's run on server because, well , that's who has the marker locations.

 

 

Your suggestion (and I love that you took the time for it) appears to grab static marker locations.

markerList = [["marker1", [0,0,0] ...........................

The markers I'm attempting to grab are dynamic :*(

 

 

 

I hardly claim myself as an expert in this script, I'm more akin to a blind man stumbling in the dark, every now and then I find my way out!

 

I know this script more or less works, as it achieves the desired goal with one marker,  I'm simply trying to figure out why the first marker is failing to do the same, with the same code. The best reason I can come up with is that maybe something else is using "objmkr" and causing it to not fetch the location. Ill try changing that and see what happens.

 

Thanks for the help so far Axe!

Link to comment
Share on other sites

  • 0

Your suggestion (and I love that you took the time for it) appears to grab static marker locations.

The markers I'm attempting to grab are dynamic :*(

It was just an example with my static marker, I guess I have to write that all the time, thats why I said "...", the list can be takes from the mission system or whatever it doesnt have to be static.. :D

The point was the list is transferred to the client, no matter where it comes from.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...