Jump to content
Sign in to follow this  
blackmamb

Dedicated Server - set players to a random position during briefing

Recommended Posts

Hi everybody!

Here's my issue of today: I been making several totally randomized misions (big thanks to Shuko by the way, that SHK_pos is a marvel!) and seem to always run into the same issue, and I need somebody to think outside the box a bit cause I'm going nuts here.

Basically I need to move playable units to a randomized position at mission start. Though I'd like this to happen during the briefing screen (mostly cause I want group markers to be updated to those new positions during the briefing).

The issue I run into: the randomizing is handled by the server. Although (I think this is the reason) when the client read the sqm it initializes the player unit back to its original position. Positions seem to be updated to JIPs but not to players during the briefing screen. So the non-player units are teleported but the player is not.

I found quite a number of workarounds, but none that actually satisfies me.

I'm starting to have the same ideas again and again here.

Anybody solved this already?

Cheers.

Share this post


Link to post
Share on other sites

Maybe have the server pick a spot and move AI there then have the clients wait till player == player then publicVariableServer a go code to the server to move them now that they are live? As long as all of that happens before a sleep it should be during the briefing.

Share this post


Link to post
Share on other sites

Yeah, I'll try something along those lines (I tried using isPlayer, server side, but that doesn't seem to indicate when the players are ready). I'll tell you, this would be a lot easier if I could use CBA.

Share this post


Link to post
Share on other sites

Well. I forgot about that one. Shuko, you rule. Though I'll probably stick with my own script using SHK_pos (I already have enough markers to keep track of, thanks), but I get the basic Idea, which is basically what kylania wa saying.

I'll go this way then, thanks to both of you.

Share this post


Link to post
Share on other sites

Moving player units and creating markers reliably via scripting during the briefing phase is a huge pain. I spent hours trying to get it to work in a completely random-generated adversarial mission I made (called Cratesistance, which BlackMamba may be familiar with) and eventually ended up with just doing it all post-briefing. For example it seemed like public variables don't get sent during briefing at all, some players saw the markers and some didn't, some players got moved and some didn't. Waiting for the players to initialize didn't help, or at least I didn't find any reliable method for doing it.

One technique that I recall being promising though, was running the scripts from the init of an editor-placed unit. This is probably because unit inits are run on the server before the briefing phase starts.

Share this post


Link to post
Share on other sites

Well, I seem to have got it. Hopefully it will be tested on a real dedicated server, with more players than just me.

call compile preprocessfile "SHK_pos\shk_pos_init.sqf";

_groups = [GrpTK_CO,GrpTK_DC,GrpTK_ASL,GrpTK_BSL,GrpTK_CSL,GrpTK_A1,GrpTK_A2,GrpTK_A3,GrpTK_B1,GrpTK_B2,GrpTK_B3,GrpTK_C1,GrpTK_C2,GrpTK_C3,GrpTK_MMG1,GrpTK_MAT1,GrpTK_ST1,GrpTK_ENG1,GrpTK_MTR1,GrpTK_HAT1,GrpTK_HMG1,GrpTK_SAM1];

if (isServer) then {
centerPos = ["map_marker", false, "excl_marker"] call SHK_pos;
{
	_pos = [centerPos, [0,2000]] call SHK_pos;
	{
		_newPos = [(_pos select 0) + random 10,(_pos select 1) + random 10,0];
		_x setposATL _newPos;
		_x setVariable ["StartPos", _newPos, true];
	} foreach units _x;
} forEach _groups;
publicVariable "centerPos";
"town" setMarkerPos centerPos;
waituntil {!isnil "bis_fnc_init"};
waitUntil {[getMarkerPos "town",centerPos] call BIS_fnc_areEqual;};
call compile preprocessFileLineNumbers "scripts\Init_UPSMON.sqf";
};
if (!isDedicated) then {
if (!isnull player) then {
	waitUntil {!isNil "centerPos"};
	if (side player != resistance) then {
		_newPos = vehicle player getVariable "StartPos";
		player setPosATL _newPos;
	} else {
		_marker = createMarkerLocal ["Marker1", centerPos];
		_marker setMarkerShape "ELLIPSE";
		"Marker1" setMarkerSize [2500, 2500];
		"Marker1" setMarkerColor "ColorRed";
		"Marker1" setMarkerBrush "Border";
	};
};
};

There's some irrelevant stuff in here that has to do with the mission itself, but the global idea's there and it seems to work alright.

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  

×