Jump to content
schadler17

Spawning carrier duplicates on JIP?

Recommended Posts

I'm thinking my carrier script duplicates everytime someone JIP's into the game.

I've spawned an object where I want the carrier and added the [this] execVM "script"; command to spawn it.

 

Only problem is, I think when someone JIP's, it duplicates the carrier objects, resulting in about 630 objects on the map on a full server, sometimes overlapping, let alone everything else.

_LHDspawn = _this select 0;
_LHDdir = getdir _LHDspawn;
_LHDspawnpoint = getposasl _LHDspawn;
deletevehicle _LHDspawn;
_parts = 
[
	"Land_LHD_house_1",
	"Land_LHD_house_2",
	"Land_LHD_elev_R",
	"Land_LHD_1",
	"Land_LHD_2",
	"Land_LHD_3",
	"Land_LHD_4",
	"Land_LHD_5",
	"Land_LHD_6"
];
{
	_dummy = _x createvehicle _LHDspawnpoint;
	_dummy setdir _LHDdir;
	_dummy setpos _LHDspawnpoint;
}foreach _parts;

I've added if (!isServer) exitWith {}; to the beginning of it, but I'm not sure if that will work 100%. Any ideas?

Share this post


Link to post
Share on other sites

(!isServer) means that the code  will be executed only by players PC.

 

In that way the code wilbe executed on every player connected. (multiple times).

 

You need to run this code server side only or set some dependency to run only one time client side.

Share this post


Link to post
Share on other sites

Are you spawning the carrier at mission start? And the server check at the top should fix it yes, but if you spawn it at mission start all you need to do is move the script execution into the initServer.sqf.

Share this post


Link to post
Share on other sites

Are you spawning the carrier at mission start? And the server check at the top should fix it yes, but if you spawn it at mission start all you need to do is move the script execution into the initServer.sqf.

 

 Yeah, I have an object with the init line to start the script.

 

Adding the if (!isServer) line should stop it from running on JIPs, and only once on the server, correct?

Share this post


Link to post
Share on other sites

Yea it should ensure that only the server runs it on missions start, you could do it your way or in the object init:

if (isServer) then {/*script execution*/};

Share this post


Link to post
Share on other sites

Nope.

 

Server side is

if (isServer) then {

code....
};

Look the wiki on Killzone kid egzample

 

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

 

He is putting if !(isServer) exithWith {}; at the beginning of his script, therefore, ensuring that only the server can proceed with the rest of the script.

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

×