Jump to content
  • 0

How to run scripts server side?


SadBoy1981

Question

I have some scripts, they run server side and i run it from server monitor (Infistar,WAI,DZAI,DZMS and my custom buildings)

But when i try to run other scripts, i get rpr error, script not found, but i know, script is in correct place.

 

How can i run my custom scripts in dayz_server.pbo and not in mission folder?

Link to comment
Share on other sites

12 answers to this question

Recommended Posts

  • 0

I have some scripts, they run server side and i run it from server monitor (Infistar,WAI,DZAI,DZMS and my custom buildings)

But when i try to run other scripts, i get rpr error, script not found, but i know, script is in correct place.

 

How can i run my custom scripts in dayz_server.pbo and not in mission folder?

what exactly script u wanna run through server side?

Link to comment
Share on other sites

  • 0

Scripts on your server in the server.pbo do not go to the client so the client cannot run them on the client.

 

What you can do from the client is to get the server to run the server side scripts when the client asks it to via publicVariableServer which will send a message to the server with the variable contents you sent.  The server needs an event handler to listen for the message and this fires a script when the server sees a change to the variable.  The script executes on the server.

 

Alternatively, any code you put in your ARMA2OA\mpmissions\[mapname]\ folder will get sent to all clients when the map loads if that was what you were meaning.

Link to comment
Share on other sites

  • 0

Scripts on your server in the server.pbo do not go to the client so the client cannot run them on the client.

 

What you can do from the client is to get the server to run the server side scripts when the client asks it to via publicVariableServer which will send a message to the server with the variable contents you sent.  The server needs an event handler to listen for the message and this fires a script when the server sees a change to the variable.  The script executes on the server.

 

Alternatively, any code you put in your ARMA2OA\mpmissions\[mapname]\ folder will get sent to all clients when the map loads if that was what you were meaning.

I dont want, that players download my custom scripts from mission files, and then i see my work on other servers cose they just copy them from %appdata%

Link to comment
Share on other sites

  • 0

So the other option is to send the script code from the server as a publicvariableclient call to a specific client where the SteamID matches yours and the event handler on your client takes the code in the public variable, compiles and runs it.  The code only exists on your machine and the server that way. 

 

Read up on public variables and event handlers to get a better idea.

Link to comment
Share on other sites

  • 0

So the other option is to send the script code from the server as a publicvariableclient call to a specific client where the SteamID matches yours and the event handler on your client takes the code in the public variable, compiles and runs it.  The code only exists on your machine and the server that way. 

 

Read up on public variables and event handlers to get a better idea.

do you have some example? Not sure i can do it myself

Link to comment
Share on other sites

  • 0

Sorry, the only code I have for this is the code for our new A3 mod which is not yet ready for release.

 

Have a look at sending variables to clients and remember that variables can also contain full sqf functions and you should be able to put it together with a bit of testing. The techneque is also JIP (Join in Progress) compatible.

Link to comment
Share on other sites

  • 0

Sorry, the only code I have for this is the code for our new A3 mod which is not yet ready for release.

 

Have a look at sending variables to clients and remember that variables can also contain full sqf functions and you should be able to put it together with a bit of testing. The techneque is also JIP (Join in Progress) compatible.

Thanks, i will try =)

Link to comment
Share on other sites

  • 0

Sorry, the only code I have for this is the code for our new A3 mod which is not yet ready for release.

 

Have a look at sending variables to clients and remember that variables can also contain full sqf functions and you should be able to put it together with a bit of testing. The techneque is also JIP (Join in Progress) compatible.

 

As example.

If i have this marker code:

_this = createMarker ["126_64", [12650.1, 8910.1, 0]]; 
_this setMarkerShape "RECTANGLE";
_this setMarkerColor "ColorBlue";
_this  setMarkerAlpha 0.9;
_this setMarkerSize [50, 50];
_marker_0 = _this;

and i want to run it server side. Where and how to run it.

 

If i just put code in \z\addons\dayz_server\marker.sqf

and runt it from  init.sqf or server_monitor.sqf or server_functions.sqf

[] execVM "\z\addons\dayz_server\marker.sqf 

   then wont work

 

From where and how to do this?

Link to comment
Share on other sites

  • 0

If you want to keep part of your codes server side, you have to use the publicVariable command.

eg.

 

This code should run on each client:

"YourPV" addPublicVariableEventHandler {
	_txt = _this select 1;
	cutText [format["Text: %1",_txt],"PLAIN DOWN"];
};

Then you have to call the this code server side, like this:

YourPV = "Some text";
publicVariable "YourPV";

With this simple example, you run the code above on each client on your server.

However, larger codes which you want to broadcast through the publicVariable command, can increase your network trafic (cf. https://community.bistudio.com/wiki/publicVariable)

Link to comment
Share on other sites

  • 0

If you want to keep part of your codes server side, you have to use the publicVariable command.

eg.

 

This code should run on each client:

"YourPV" addPublicVariableEventHandler {
	_txt = _this select 1;
	cutText [format["Text: %1",_txt],"PLAIN DOWN"];
};

Then you have to call the this code server side, like this:

YourPV = "Some text";
publicVariable "YourPV";

With this simple example, you run the code above on each client on your server.

However, larger codes which you want to broadcast through the publicVariable command, can increase your network trafic (cf. https://community.bistudio.com/wiki/publicVariable)

damn, anyway i dont uderstand where to put this code and how to call it

Link to comment
Share on other sites

  • 0

what you are after. I wouldn't recommend it tho as it increases network traffic. What you should probably do is break your code and put some core functions server side, keep the large crap client side, that way anyone "stealing" your work won't be able to use it.

There's obviously more to this, but I can not help you with it at current stage, but it should be more than enough to get you going.

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...