Jump to content
ribera1945e

[help]Change the side of the playable unit with a parameter.

Recommended Posts

Hi guys.
I want to change the side of a playable unit with a parameter, but my script doesn't work.

 

playerTeamSide.sqf:

if (!isServer) exitWith {};

private ["_side", "_playerGroup", "_newGroup"];

if (playerTeamSide == 1) then {
	_side = EAST;
	} else {
	_side = INDEPENDENT;
	};

_playerGroup = allGroups select { side _x == WEST; };

{
	_newGroup = createGroup _side;
	units group _x joinSilent _newGroup;
} forEach _playerGroup;

It seems that the group is not stored in _x.

What should I do?

Share this post


Link to post
Share on other sites

_playerGroup = allGroups select { side _x == WEST };     // no extra ; for the condition, but no a real problem here.

 

units _x joinSilent _newGroup;     //_x is already a group

Share this post


Link to post
Share on other sites
1 hour ago, pierremgi said:

_playerGroup = allGroups select { side _x == WEST };     // no extra ; for the condition, but no a real problem here.

 

units _x joinSilent _newGroup;     //_x is already a group

It work!
Thanks you.

Share this post


Link to post
Share on other sites

However, the side is not applied correctly on a dedicated server...
Is there something I overlooked?

Share this post


Link to post
Share on other sites

No reason for that. But I can't help more. I remarked you named your sqf playerTeamSide.sqf and you have also a global variable playerTeamSide... Not a problem but confusing. 

You are running the code on server but we don't know where playerTeamside (variable) comes from.

And when are you running this code? You need to pay attention for a couple of things for dedicated server:

- player (command) doesn't work on dedicated because there is no player at all here.

- the initialization order is important.

- if you disable slot in lobby, the unit (playable but not yet played) doesn't exist (as variable or object), until a joining player chooses the slot and enters the mission.

 

So, to make it short, you should say when you want this code to be run (condition, for whom,..). Your goal remains unclear. As present code, it seems useless to alter the side of all west units if you can do that in editor.

then, I'll suggest you to place it in initPlayerLocal.sqf instead of running it on server, depending on what you want exactly.

  • Like 2

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

×