Jump to content
Sign in to follow this  
wolffy.au

BIS_fnc_spawnCrew, CreateVehicleLocal and Dedicated Servers

Recommended Posts

Hi all,

Long story, so heres the short of it. I've created a mission, thats coded completely server side and works perfectly when I only have up to 10 players. 10+ players, and server CPU hits 100% and all kinds of things go bad.

So I started looking into the use of compositions (which use the CreateVehicleLocal command) and the use of BIS_fnc_spawnCrew.

Problem is - even with the creation of the composition within an isServer check - the spawnCrew function appears to know the vehicles are available, but spawns them standing outside the vehicles. Its almost like, it things the vehicle positions are already full.

Here's the code I'm using to test - I spawn it from a GameLogic object. Please note, the code below is supposed to create the aesthetic stuff and AI client-side.

If this explanation doesn't make sense, its because my brain has turned to mush trying to figure this out...

// 
if(isServer) exitWith{};

_obj = _this select 0;
_pos = position _obj;
_dist = 10;

"SearchLight_RUS" createVehicleLocal _pos;

_grp = createGroup east;

waitUntil {!isNil "bis_fnc_init"}; 

_list = _pos nearObjects ["LandVehicle", _dist];
{
if (count crew _x == 0) then {
	[_x, _grp] call BIS_fnc_spawnCrew;
};
} forEach _list;

1 player on dedicated server appears to be working, but a second player JIP will cause a Crewman to be created next to them.

Is what I'm trying to do completely down the wrong track?

Edited by Wolffy.au

Share this post


Link to post
Share on other sites

Well, your isServer check is telling the script to run on every client EXCEPT for the server. Which is the opposite of what you want. You're also trying to use exitWith to exit a script, which it's not designed to do, it exits a code block.

Try this:

[color="SeaGreen"]if (isServer) then {[/color]

_obj = _this select 0;
_pos = position _obj;
_dist = 10;

"SearchLight_RUS" createVehicle _pos;

_grp = createGroup east;

waitUntil {!isNil "bis_fnc_init"}; 

_list = _pos nearObjects ["LandVehicle", _dist];
{
if (count crew _x == 0) then {
	[_x, _grp] call BIS_fnc_spawnCrew;
};
} forEach _list;

[color="SeaGreen"]};[/color]

Share this post


Link to post
Share on other sites
Well, your isServer check is telling the script to run on every client EXCEPT for the server. Which is the opposite of what you want.

I understand what you are saying, but that takes me back to where I started. If I create all my objects on the server, I flatline the CPU.

What I was trying to achieve, was the use of the createVehicleLocal script on each individual client, taking away the need for the server to update each of the clients regarding static objects.

You're also trying to use exitWith to exit a script, which it's not designed to do, it exits a code block.

Thanks for that, I'll convert the IF statement as you've done above and see if that assists in the issue.

Share this post


Link to post
Share on other sites

_list = _pos nearObjects ["LandVehicle", _dist];

Its more likely this could be causing your problem. NearObjects can cause serious problems with excessive usage.

The exitwith is fine. Its just exiting the scope to nothing. ie. Death.

Unless it the script is call'd.

Share this post


Link to post
Share on other sites
_list = _pos nearObjects ["LandVehicle", _dist];

Its more likely this could be causing your problem. NearObjects can cause serious problems with excessive usage.

Heya Rommel - this might explain why I can gradually get people to join and the mission works fine. What I'll try is getting 10 players on the server and not leave Briefing screen until CPU has dropped.

So off the back of that, is creation of all vehicles and AI units the best way to approach this? Should I even bother trying to use CreateVehicleLocal?

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
Sign in to follow this  

×