Jump to content
Sign in to follow this  
1para{god-father}

Stop Side changing ?

Recommended Posts

Is there a way to stop players changing sides during a mission ?

 

i.e  If i join OPFOR , I cannot disconnect and join Bluefor  until mission is restarted ?

 

Thanks

 

 

Share this post


Link to post
Share on other sites

Each player has a unique uid (tied to either their computer or steam account, I'm not quite sure which). See getPlayerUID.

 

Perhaps upon disconnect you can store a player's uid and side on server missionNamespace, and upon reconnect kill/warn the player if they switches side.

 

Variables stored in missionNamespace are reset upon mission restart so it should work.

Share this post


Link to post
Share on other sites

I believe wasteland does this, and you should take a look at their mission files. Although they might also implement through an addon, I've never looked.

Share this post


Link to post
Share on other sites

Top of my head, untested:

 

initServer.sqf

connPlayerArr = [];
playersArr = [];

initPlayerServer.sqf

params ["_p", "_jip"];
private _pName = name _p;
private _checkSide = [_pName, side _p];

if !(_pName in playersArr) then {	
	// First time connection, lets add the player to the arrays 
	playersArr pushBack _pName;
	connPlayerArr pushBack _checkSide;
	//hint format ["%1 is not in playersArr.\n\nAdded %1 to playersArr.\n\nAdded %2 to connPlayerArr.", _pName, _checkSide]; // debug

} else {	
	// Return player
	private _i = playersArr find _pName; // get the index
	private _side = connPlayerArr select _i select 1;
	//hint format ["%1 is a return player.\n\nplayerArr index: %2\n\nOld side: %3.\n\nNew side: %4", _pName, _i, _side, side _p]; // debug
	
	// Check if he switched sides
	if (side _p != _side)  then {
		// Player switched sides. Code goes here....
	} else {
		// Player did not switch sides.
		(format ["Welcome back %1", name _p]) remoteExec ["hint", _p, false];
	};
};
  • Like 1

Share this post


Link to post
Share on other sites

Top of my head, untested:

initServer.sqf

connPlayerArr = [];
initPlayerServer.sqf

params ["_p", "_jip"];private _check = [name _p, side _p];if !(_check in connPlayerArr)) then {	// First time connection, lets add the player to connPlayerArr 	connPlayerArr pushBack _check;} else {	// Return player	private _i = connPlayerArr find _check; // get the index	// Check if he switched sides	if !((_check select 1) isEqualTo (connPlayerArr (select _i) select 1))  then {		// Player switched sides. Code goes here....	} else {		// Player did not switch sides.		(format ["Welcome back %1", name _p]) remoteExec ["hint", _p, false];	};};
This is not going to do it, the logic is flawed here ^^^^^. Joining player that changed side will always be added to the array, and the one that didnt will be checked if he is on the same side which obviouly he is.

Edit: I hate you new forum and formatting

Share this post


Link to post
Share on other sites

You're right KK. Updated my OP. Code could probably be more efficient but it should work now.

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  

×