Jump to content

run scripts server side


SadBoy1981

Recommended Posts

Localhost is when You start a mission ingame (also if You load a mission and klick preview in the mission editor) and Your client then also works as a host/server.

A dedicated is, well a dedicated Server, startet via the server executable.

For more information, read this great Article from KillzoneKid:

Or use the official BIS Arma wiki pages as source of information:

https://community.bistudio.com/wiki/isServer

Or use the official BIS Arma wiki pages as source of information:

https://community.bistudio.com/wiki/isServer

https://community.bistudio.com/wiki/isDedicated

https://community.bistudio.com/wiki/hasInterface

https://community.bistudio.com/wiki/isMultiplayer

Link to comment
Share on other sites

Can you share some example how to do that!

 

 

It's quite easy really.  You just create an addon PBO and call scripts from it.  In your fn_init.sqf in the PBO make it look like this:


// ADDONS
scrpt1 = compileFinal preprocessFileLineNumbers "\a3_epoch_addons\scripts\scrpt1.sqf";
scrpt2 = compileFinal preprocessFileLineNumbers "\a3_epoch_addons\scripts\scrpt2.sqf";
scrpt3 = compileFinal preprocessFileLineNumbers "\a3_epoch_addons\scripts\scrpt3.sqf";

publicVariable "scrpt1";
publicVariable "scrpt2";
publicVariable "scrpt3";

diag_log "Epoch Addons compiled";

Then in your mission file create a file called onPlayerRespawn.sqf.  Inside that file, place this:

if (!isDedicated and hasInterface) then 
{
	waitUntil {alive vehicle player};	
	waitUntil {typeOF player != "VirtualMan_EPOCH"};

	
		

	waitUntil{!isNil "Scrpt1"};
	[] spawn Scrpt1;
	waitUntil{!isNil "Scrpt2"};
	[] spawn Scrpt2;
	waitUntil{!isNil "Scrpt3"};
	[] spawn Scrpt3;
};

That way the public variables get put back onto players on respawn events.  The onPlayerRespawn.sqf does NOT need to be called from any other files.  Just place it in your mission's root folder.  Note that for every new pubvar you create you will have to add an exception to the pubvar.txt BE filter, like !="scrpt1" !="scrpt2" !="scrpt3"

 

There are certain things though that have to remain client side, like the status bar, but many things can be moved server side.  Basically anything that adds a function or action to the player can go server side and be called from a public variable.  Depending on the size and complexity of the script it may take some recoding to make it work.  Anything that is more complex than a single file or two probably wouldn't be practical just because of all the re-writing that would be necessary.  Now R3F....that's doable, but it would take a lot of time and trial and error since there's so many scripts and variables.  

 

One word of caution though.  Anytime you introduce a public variable, it's...well...public, which means it could potentially be accessed by other players for dishonest purposes.  So I'd avoid setting anything to a public variable that can potentially have negative player effects if the wrong person got ahold of the variables.  

Link to comment
Share on other sites

Broadcasting code isn't a good idea from a performance perspective. First, sending multiple PVs to multiple clients is not performance friendly and increases network traffic, and PVing code is even less so. Put them together and you're on your way to adding more desync to your server.

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