Jump to content

Recommended Posts

Hey,

 

I am prepping a mission which will feature stativ UAV terminals for players to use. Their intent is to allow for connecting to jets turret gunners when using an action, and remove the uav terminal when leaving the uav interface. What I got so far is this:

 

initServer.sqf:

WaitUntil {!(isNil "turret6")}; //waiting for the spawn of the last turret in sequence
	[  
	 turret_controller_1,  
	 "Control turret 1",  
	 "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_hack_ca.paa",  
	 "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_hack_ca.paa",  
	 "_this distance _target < 2",  
	 "_caller distance _target < 2",  
	 {},  
	 {},  
	 {execVM "scripts\turret_control_1.sqf"},  
	 {},  
	 [],  
	 2,  
	 0,  
	 false,  
	 false  
	] remoteExec ["BIS_fnc_holdActionAdd", 0, turret_controller_1]; 

 

and turret_control_1.sqf:

player linkItem "B_UavTerminal";
player connectTerminalToUAV turret1;
player action ["SwitchToUAVGunner", getConnectedUAV player];
WaitUntil {!(isUAVConnected turret1)};
player unLinkItem "B_UavTerminal";

 

The simple script works perfectly in a Singleplayer environment. For some reason it does absolutely nothing when tested in Multiplayer.

 

Basically we enter the map, proceed to the "turret_controller_1" which receives the action and when pressing and holding the spacebar (as instructed by the BIS_fnc_holdActionAdd command), the player is not transferred to the gunner view at all. All it does is add in the terminal for the player. I have been trying to kind of debug this issue and I came to the conclusion that the terminal does not connect to the turret (as shown by the getConnectedUAV command). I have no idea as to why that is, but that's slightly infuriating.

 

I would be thankful for some guidance on this as I've been struggling to get those turrets to work for days now and there's always something new which does not work. I am leaning towards it happening because of some locality issue, but if that's the case, then I am the more in need of help.

 

Thanks a lot,

Adam

Share this post


Link to post
Share on other sites

Any ideas anyone? I have no damn clue what I am doing wrong as it's even working when I'm testing it on local MP server but not on a dedicated.

 

I will be very grateful for help with this 😞

Share this post


Link to post
Share on other sites

From the BIKI entry for player;

Quote

In MP player is different on each computer and on dedicated server it is objNull by default.

 

 

Give this a go;

Spoiler

//	initServer.sqf:
waitUntil {!(isNil "turret6")}; //waiting for the spawn of the last turret in sequence

[
	turret_controller_1,
	"Control turret 1",
	"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_hack_ca.paa",
	"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_hack_ca.paa",
	"_this distance _target < 2",
	"_caller distance _target < 2",
	{},
	{},
	{[_this select 1] execVM "scripts\turret_control_1.sqf"},	//	_this select 1 is _caller.
	{},
	[],
	2,
	0,
	false,
	false
] remoteExec ["BIS_fnc_holdActionAdd", 0, turret_controller_1];


//	turret_control_1.sqf:
params ["_player"];

_player linkItem "B_UavTerminal";
_player connectTerminalToUAV turret1;
_player action ["SwitchToUAVGunner", getConnectedUAV _player];

waitUntil {!(isUAVConnected turret1)};
_player unLinkItem "B_UavTerminal";

 

 

  • Like 1

Share this post


Link to post
Share on other sites

Hey @Maff

 

Unfortunately it does not change anything. When launched on a dedicated the terminal gets added but never connects to the actual turret 😞

 

23 minutes ago, target_practice said:

I thought code supplied to holdActionAdd was executed on the client that used the action.

 

That's exactly what I was thinking but for some reason it does not work still. 

 

Maybe I am missing some kind of step on the UAV connection, but on the other hand it works fine in SP, so not sure if that's the issue.

 

Edit:

The connectTerminalToUAV on the wiki also says:

Quote

Connect person with UAV terminal to UAV unit. UAV Terminal item needs to be assigned to GPS slot. If UAV is already connected to another terminal, this new connection will fail.

 

Maybe the UAV gets connected to some other terminal before I even attempt to do that? I don't think so, but I may try to work around that actually.

 

Edit2:

Nah, it's not that.

 

Furthermore when testing this in SP,  now the terminal does not get removed from the player's inventory after he has disconnected so that's another thing :/

Share this post


Link to post
Share on other sites

Ok, so apparently Releasing Controls from the UAV is not equal to disconnecting from it, so that is the reason for the terminal not being removed, but I swear it worked the other day...

 

Anyways, it still leaves the question as to why the player cannot connect to the terminal in MP in the first place. Still no luck...

Share this post


Link to post
Share on other sites

Hang on...

It has been a while since I played around with the UAV's but, when you have the UAV Terminal don't you get a scroll wheel action to open up the UAV Terminal and have control access to all drones for your side?

Share this post


Link to post
Share on other sites

Yes, that is true, but why do you ask?

 

The idea behind the script is that there is a stationary item that works as a kind of "controller" for the turret (uav) and when the action attached to this object fires, the player gets directly into the gunner seat of the turret. After that, when he releases connection the terminal ought to disappear from his inventory.

Share this post


Link to post
Share on other sites

Ygh, not yet, but from an initial look it seems like a dirty workaround and I am slightly afraid of going this way 😞

Share this post


Link to post
Share on other sites

Well okay, I gave it a try and it actually looked pretty promising, as the code is shorter and the overall process is much easier.

 

Again, works fine in SP but does literally nothing in MP when called using the aforementioned action. It just hints "done" and nothing happens.

 

Is it still the case of locality?

 

player remoteControl gunner turret1;
gunner turret1 switchCamera "Internal";
hint "done";

 

I am beyond clueless...

Help.

Share this post


Link to post
Share on other sites

I have tested the following in MP player hosted and it works.

I don't have access to, nor am I experienced with dedicated servers.

 

Spoiler

/*
	turret_controller_1 is a laptop object placed in the editor.
	turret1 is a non-empty Darter UAV hovering above the playable character.
*/

[
	turret_controller_1,
	"Control turret 1",
	"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_hack_ca.paa",
	"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_hack_ca.paa",
	"_this distance _target < 2",
	"_caller distance _target < 2",
	{},
	{},
	{ turret1 switchCamera "INTERNAL"; (_this select 1) remoteControl gunner turret1; }, // Keeping it simple for now.
	{},
	[],
	2,
	0,
	false,
	false
] remoteExec ["BIS_fnc_holdActionAdd", 0, turret_controller_1];

 

 

If that doesn't work out for you... I'm out of ideas.

 

  • Like 1

Share this post


Link to post
Share on other sites
player linkItem "B_UavTerminal";
waitUntil{ "B_UavTerminal" in assignedItems player };
diag_log "Terminal received";

player connectTerminalToUAV turret6;
waitUntil{ isUAVConnected turret6 };
diag_log "Connected";

player action ["SwitchToUAVGunner", getConnectedUAV player];
waitUntil{ isUAVConnected turret6 && ( cameraOn isEqualTo turret6 ) };
diag_log "In gunner: adding ev";

addMissionEventHandler [ "PlayerViewChanged", {
	params[ "_oldUnit", "_newUnit", "_vehicle", "_oldCamera", "_newCamera", "_uav" ];
	diag_log "PVC_fired";
	if ( _oldCamera isEqualTo turret6 && { ( _newCamera isEqualTo player ) } ) then {
		diag_log "disconnecting terminal";
		player connectTerminalToUAV objNull;
		diag_log "removing terminal";
		player unlinkItem "B_UavTerminal";
		diag_log "player disconnected";
		removeMissionEventHandler[ "PlayerViewChanged", _thisEventHandler ];
	};
}];

TEST_MISSION tested SP, MP and Dedicated. Left loads of debug in there for RPT.

  • Like 1

Share this post


Link to post
Share on other sites

Okay, so I have a few things to say..

 

First of all, thank you all for being so helpful! I have already realized that whenever I want to achieve any relatively simple effect in Arma, it always ends up being much more complicated that it initially seemed and I need to cry for help. It's great to know there are people willing to spend their time to help others - many thanks @Maff, @Larrow - that's really much appreciated.

 

Secondly, I should apologize, because in the end all this mess resulted from my mistake. In short: all of those attempts do work on a dedicated server, as I have just confirmed after about a 376th server restart. I should apologize mainly because I assumed that creating the turrets within the initServer.sqf would not be a problem for the script to run, primarily because it worked on SP + local MP and not on a Dedicated - I never thought that this could be the reason but I should have posted it in the original post nonetheless. The initServer.sqf also contains the below bit which creates the turret-uavs from scratch and places them on a Ship. The sole createVehicle process was the part that messed up the connectivity for whatever reason.

 

I actually noticed this after launching Larrow's test mission and comparing the two scenarios. In mine, the turret was placed by the script and in Larrow's it was already in the game. Even after copying Larrow's code directly to my mission it did not work so I started pulling my hair out until I realised what the cause could be.

/* MK49 Spartan - Rear-right */
//	turret1 = createVehicle ["B_SAM_System_01_F", [1507.26,8856.08,0.2]];
//	createVehicleCrew turret1;
	turret1 attachTo [Ship, [24.8,-155.5,12.6]];
	turret1 setDir 90;
	turret1 setBehaviour "CARELESS";
	turret1 setCombatMode "BLUE";
	turret1 disableAI "TARGET";
	turret1 disableAI "AUTOTARGET";
	turret1 setAutonomous false;
	turret1 setGroupId ["Turret 1"];

With that, I decided to just skip the createVehicle part and simply created a turret somewhere on the map in the editor. When the mission starts, I now only move it to the desired position and then connecting to it via any script works flawlessly in all environments. All scripts, that is Larrow's most elaborate code, Maff's suggestions pertaining to remoteControl and the previous attempts to fixing my code, as well as my original script. The only minor difference is that with remoteControl it seems that you cannot use the radar of the turret (Ctrl + R) and with my original script the line pertaining to the check, whether the terminal is already disconnected, is wrong - I will fix this later but that's not a biggie.

 

Sooo.... yeah. I am so sorry for wasting your time guys. It could have been over much sooner and that's only due to my mistake. I guess live and learn, eh..?

 

Thank you very much for helping again!

Adam

 

Share this post


Link to post
Share on other sites
On 8/20/2019 at 10:44 PM, Dj Rolnik said:

WaitUntil {!(isUAVConnected turret1)};

Your original code would never work if another player tries to connect from the same controller after someone has left, as the previous players terminal is still connected to the UAV.

If a player leaves the UAV by releasing controls( UAV action menu ) then isUAVConnected is always true, as releasing does not disconnect the terminal, so the waitUntil is never satisfied and the terminal is never deleted.

 

Try it from my test mission, remove the playerViewChanged EH from the script and add back in your waitUtil !isUAVconnected, join two clients, one uses the controller and then releases control, then try the other client. He will not be able to join due to first clients terminal is still connected.

You need to wait for release using playerViewChanged, then set connectTerminalToUAV to objNull to disconnect, and then delete the terminal.

 

I suppose this is all dependant on if you wish multiple clients to be able to use a controller, which I guess you do by the fact you try to clean up and disconnect.

  • Like 1

Share this post


Link to post
Share on other sites

Hey, 

 

Yes Larrow, you're right. My original attempt now just works in terms of connecting, but I did mess up the part with isUAVDisconnected. Apparently, according to the below thread, there is a command which returns the controller of the UAV, irrespective of whether it's connected, so I was thinking that this could work, but actually at this point your current version is just the way to go.

 

 

On 5/17/2014 at 6:29 PM, darkwanderer said:

The topic is a bit old, but for future reference - there's a command called uavControl, which returns array with NULL at position 0 if player is not currently controlling a UAV (even if he's connected) - just in case somebody needs that.

 

Thanks again Larrow - saving the day once more 🙂

 

Adam

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

×