Jump to content
Sign in to follow this  
T. Miller

"(side _x == west)" problems

Recommended Posts

Hey I'm trying to create side only local-markers.

To do this I'd have to call the code for every BLUFOR unit.

Therefore I'm trying to create a IF THEN structure to call this code.

{
if (side _x == west) then {
	//code
};
} foreach playableUnits;

Sadly enough the code never gets called (Yes, the code I filled in there to test it díd work).

This means something is wrong with (side _x == west).

I also tried ((side _x) == west).

I only tested it in the editor.

Share this post


Link to post
Share on other sites

There is no playableUnits in SP editor. Use switchableUnits, or (playableUnits + switchableUnits).

Share this post


Link to post
Share on other sites

Do it through public variable. playableUnits has list of alive player-controller units so if you're going to create markers while player is dead, it wouldn't work.

Server code, call on server whenever you need to create markers for everyone:

createMarkersPlease = true;
publicVariable "createMarkersPlease";

// If player is hosting the game, they should also get the markers
if(!isDedicated) then {call createMarkersPleaseFunc};

Client code:

"createMarkersPlease" addPublicVariableEventHandler {
   call createMarkersPleaseFunc;
};

createMarkersPleaseFunc = {
   if(playerSide == blufor) then {
       //... createMarkerLocal ...
   };
};

Share this post


Link to post
Share on other sites
There is no playableUnits in SP editor. Use switchableUnits, or (playableUnits + switchableUnits).

I tested it in Multiplayer too now with playableUnits, still didn't work.

Do it through public variable. playableUnits has list of alive player-controller units so if you're going to create markers while player is dead, it wouldn't work.

Server code, call on server whenever you need to create markers for everyone:

createMarkersPlease = true;
publicVariable "createMarkersPlease";

// If player is hosting the game, they should also get the markers
if(!isDedicated) then {call createMarkersPleaseFunc};

Client code:

"createMarkersPlease" addPublicVariableEventHandler {
   call createMarkersPleaseFunc;
};

createMarkersPleaseFunc = {
   if(playerSide == blufor) then {
       //... createMarkerLocal ...
   };
};

Since all players only have one life (and move to BIS spectator if they die) it wouldnt be a problem to use playableUnits.

Let me post all the relevent code:

init.sqf

_nil=[]execVM "enemyMarkerBlufor.sqf";
_nil=[]execVM "enemyMarkerOpfor.sqf";

enemyMarkerBlufor.sqf :

{
if ((side _x) == west) then {
	spawn {
		_OHVT_Mk createMarkerLocal ["HVT", getMarkerPos "MarkerSpawn"];
		_OHVT_Mk setMarkerShapeLocal ["ICON"];
		_OHVT_Mk setMarkerTypeLocal ["o_unknown"];
		_OHVT_Mk setMarkerColorLocal "ColorEAST";

		while {alive O_VIP} do {
			_OHVT_Mk setMarkerPosLocal getPos O_VIP;
			_interval = 5   //"round (random 270) + 30;" maybe
			sleep _interval;
		}; 
	};
};
} foreach playableUnits;

enemyMarkerOpfor.sqf :

{
if ((side _x) == east) then {
	spawn {
		_BHVT_Mk createMarkerLocal ["HVT", getMarkerPos "MarkerSpawn"];
		_BHVT_Mk setMarkerShapeLocal ["ICON"];
		_BHVT_Mk setMarkerTypeLocal ["b_unknown"];
		_BHVT_Mk setMarkerColorLocal "ColorWEST";

		while {alive B_VIP} do {
			_BHVT_Mk setMarkerPosLocal getPos B_VIP;
			_interval = 5   //"round (random 270) + 30;" maybe
			sleep _interval;
		}; 
	};
};
} foreach playableUnits;

Explanation :

Using the lines in the init to call the script when player joins. Should I maybe use 'initplayerlocal.sqf' to skip all this, together with replacing '((side _x) == west)' with '(player == west)'? Maybe use 'initserver.sqf, probably not though.

If I'd do it the way you posted, where would I call what code? (Also keep in mind that I'm testing this on a hosted server, and won't be played off of that.)

Guess the client code would look like this:

createEnemyMarkerFunc = {
if (playerSide == west) then {
	_OHVT_Mk createMarkerLocal ["HVT", getMarkerPos "MarkerSpawn"];
	_OHVT_Mk setMarkerShapeLocal ["ICON"];
	_OHVT_Mk setMarkerTypeLocal ["o_unknown"];
	_OHVT_Mk setMarkerColorLocal "ColorEAST";

	while {alive O_VIP} do {
		_OHVT_Mk setMarkerPosLocal getPos O_VIP;
		_interval = round (random 270) + 30;
		sleep _interval;
	};
};

if (playerSide == east) then {
	_BHVT_Mk createMarkerLocal ["HVT", getMarkerPos "MarkerSpawn"];
	_BHVT_Mk setMarkerShapeLocal ["ICON"];
	_BHVT_Mk setMarkerTypeLocal ["b_unknown"];
	_BHVT_Mk setMarkerColorLocal "ColorWEST";

	while {alive B_VIP} do {
		_BHVT_Mk setMarkerPosLocal getPos B_VIP;
		_interval = round (random 270) + 30;
		sleep _interval;
	}; 
};
};

Where would I call the server code, and what would that be in this case?

Edited by dyzalonius

Share this post


Link to post
Share on other sites

Just a minor thing to consider for the future - unrelated to your current issue: Be aware that

"side _x == West" is FALSE when _x has performed a TK/team vehicle damage. side _x will then be "ENEMY" (meaning AI WEST players will shoot at this player). To get the true side you can workaround by using "side group _x", because the side of the player's group never changes (even if he is in a one-man-group).

Share this post


Link to post
Share on other sites
Just a minor thing to consider for the future - unrelated to your current issue: Be aware that

"side _x == West" is FALSE when _x has performed a TK/team vehicle damage. side _x will then be "ENEMY" (meaning AI WEST players will shoot at this player). To get the true side you can workaround by using "side group _x", because the side of the player's group never changes (even if he is in a one-man-group).

I figured this when I was making it and checking the WIKI for sides, but I don't think this would be an issue. Thanks anyway though!

Share this post


Link to post
Share on other sites

Something like.....

//initPlayerLocal.sqf

//Get HVT values based on players side
_playerSideID = ( side player ) call BIS_fnc_sideID;
_HVT = [ B_VIP, O_VIP ] select _playerSideID;
_HVT_Mk_Type = [ "b_unknown", "o_unknown" ] select _playerSideID;
_HVT_Mk_Color = [ "ColorWEST", "ColorEast" ] select _playerSideID;

//Create marker
_HVT_Mk = createMarkerLocal [ "HVT", getMarkerPos "MarkerSpawn" ];
_HVT_Mk setMarkerShapeLocal "ICON";
_HVT_Mk setMarkerTypeLocal _HVT_Mk_Type;
_HVT_Mk setMarkerColorLocal _HVT_Mk_Color;

//While HVT is alive update marker position
while { alive _HVT } do {
_HVT_Mk setMarkerPosLocal ( getPosATL _HVT );
sleep 5; //Whatever interval you want
};

deleteMarkerLocal _HVT_Mk;

Share this post


Link to post
Share on other sites
Something like.....

//initPlayerLocal.sqf

//Get HVT values based on players side
_playerSideID = ( side player ) call BIS_fnc_sideID;
_HVT = [ B_VIP, O_VIP ] select _playerSideID;
_HVT_Mk_Type = [ "b_unknown", "o_unknown" ] select _playerSideID;
_HVT_Mk_Color = [ "ColorWEST", "ColorEast" ] select _playerSideID;

//Create marker
_HVT_Mk = createMarkerLocal [ "HVT", getMarkerPos "MarkerSpawn" ];
_HVT_Mk setMarkerShapeLocal "ICON";
_HVT_Mk setMarkerTypeLocal _HVT_Mk_Type;
_HVT_Mk setMarkerColorLocal _HVT_Mk_Color;

//While HVT is alive update marker position
while { alive _HVT } do {
_HVT_Mk setMarkerPosLocal ( getPosATL _HVT );
sleep 5; //Whatever interval you want
};

deleteMarkerLocal _HVT_Mk;

Thanks a lot, this works!

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  

×