Jump to content
  • 0

Calling a server side script in client init.sqf


Madman2077

Question

Alright, gentlemen, here's the deal. I have a marker that I want to spawn on the map. This marker wil change on every restart and doing that client side will cause them to have to re-download the entire mission every time.

 

So lets say I have marker.sqf in my dayz_server.pbo and I am calling it in the init.sqf as \z\addons\dayz_server\marker.sqf...

It will return a "script not found" error when the client tries to load in and will not execute the script.

 

When I execute the script server side it will only work for people who load in while the server is first starting up. Everyone who comes after will not get the marker.

 

My question therefore is; can I call a script that is located server side through the client?

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Thanks Csus, looked into that and it worked for me!

 

For anyone else having an issue like this, here is a quick explanation of how the publicVariable works in my case:

 

 

So first of all I moved my marker.sqf clientside and made changed it to this:

//Marker on Map
_MARKERNAME = createMarker ["MARKERNAME", [roamposx, roamposy]];
_MARKERNAME setMarkerText "Card House";
_MARKERNAME setMarkerType "mil_circle";
_MARKERNAME setMarkerColor "ColorPink";
_MARKERNAME setMarkerBrush "Solid";
MARKERNAME = _MARKERNAME ;

Then I defined those 2 variables (roamposx and roamposy) in server_functions.sqf (server side)

 

Added them below the following (around line 38)

server_deaths = 				compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_playerDeaths.sqf";

so they looked like this

//Card house location variables
roamposx = 						7116.9463;		//Define position for x
roamposy =						7641.1069;		//Define position for y

After defining the variables they had to be made public so the clients could use them. To do so I added this below

publicVariable "roamposx";
publicVariable "roamposy";

This worked out perfect. Every joining client could now use those variables for the position of the marker and changing the location between restarts now only requires a server side modification. Makes it a little more conveniant for the players as they do not have to download your mission file again on every restart.

Link to comment
Share on other sites

  • 0

The other way would be to add it serverside with a loop. DZMS uses this method.

 

This way there are no mission-sided files, and everyone sees the marker. Join In Progress players see it when it refreshes in 25 seconds.

//Lets start the timer
_run = true;
while {_run} do
{
    [25,5] call DZMSSleep; // sleep 25 seconds
	//If the marker exists (meaning the mission is active) lets delete it and re-add it
	if (!(getMarkerColor "DZMSMajMarker" == "")) then {
		deleteMarker "DZMSMajMarker";
		deleteMarker "DZMSMajDot";
		//Re-Add the markers
		_nul = createMarker ["DZMSMajMarker", DZMSMajCoords];
		"DZMSMajMarker" setMarkerColor "ColorRed";
		"DZMSMajMarker" setMarkerShape "ELLIPSE";
		"DZMSMajMarker" setMarkerBrush "Grid";
		"DZMSMajMarker" setMarkerSize [175,175];
		_zap = createMarker ["DZMSMajDot", DZMSMajCoords];
		"DZMSMajDot" setMarkerColor "ColorBlack";
		"DZMSMajDot" setMarkerType "Vehicle";
		"DZMSMajDot" setMarkerText DZMSMajName;
	};
	//Lets do the same for the minor mission
	if (!(getMarkerColor "DZMSMinMarker" == "")) then {
		deleteMarker "DZMSMinMarker";
		deleteMarker "DZMSMinDot";
		//Re-Add the markers
		_nil = createMarker ["DZMSMinMarker", DZMSMinCoords];
		"DZMSMinMarker" setMarkerColor "ColorRed";
		"DZMSMinMarker" setMarkerShape "ELLIPSE";
		"DZMSMinMarker" setMarkerBrush "Grid";
		"DZMSMinMarker" setMarkerSize [150,150];
		_zip = createMarker ["DZMSMinDot", DZMSMinCoords];
		"DZMSMinDot" setMarkerColor "ColorBlack";
		"DZMSMinDot" setMarkerType "Vehicle";
		"DZMSMinDot" setMarkerText DZMSMinName;
	};
	//Now we wait another 25 seconds
};
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...