Jump to content
Cigs4

Disconnect UAV from dead

Recommended Posts

Hello Guys,


Here's the problem:


Playing on a dedicated server, my team is small and uses UAV's for recon. What is happening is that when the member responsible for the UAV and who has the terminal connected to it is shot and dies, that UAV is stuck to that player and, even if he respawns, it is no longer possible to connect to that UAV.
I would like a code that disconnects a dead player's terminal from an UAV.
I tried this:

while {true} do {
	{_x connectTerminalToUAV objNull} forEach AllDeadMan;
};
sleep 6;


But no success...
Can someone help me, please??

Thanks in advance.

Share this post


Link to post
Share on other sites

You could use EntityKilled EH to disconnect the unit:

 

addMissionEventHandler ["EntityKilled", 
{ 
params ["_unit", "_killer", "_instigator", "_useEffects"]; 


_uav = getConnectedUAV _unit;

if(!isnull _uav) then
{

_unit connectTerminalToUAV objNull;

};


}];

 

 

code not tested

  • Thanks 1

Share this post


Link to post
Share on other sites

Works perfectly !!! Thanks a lot, gc8.
And thank you also, Maff!
👍

Share this post


Link to post
Share on other sites

May I ask how you identify the player and reconnect the uav on respawn (in dedicated)?

Do you check the player's class in the onPlayerRespawn.sqf, ie:
 

if (typeOf player == "B_Soldier_UAV_F") then { uav1 connectTerminalToUAV player; };

?

Share this post


Link to post
Share on other sites
16 hours ago, Melody_Mike said:

May I ask how you identify the player and reconnect the uav on respawn (in dedicated)?

Do you check the player's class in the onPlayerRespawn.sqf, ie:
 


if (typeOf player == "B_Soldier_UAV_F") then { uav1 connectTerminalToUAV player; };

?

 

Edited my code a bit for that:

 

addMissionEventHandler ["EntityKilled", 
{ 
params ["_unit", "_killer", "_instigator", "_useEffects"]; 


_uav = getConnectedUAV _unit;

if(!isnull _uav) then
{

_unit connectTerminalToUAV objNull;

_unit setVariable ["controlledUAV", _uav ]; // Store last used UAV

};


}];

 

then in onPlayerRespawn.sqf

 

_uav = player getVariable ["controlledUAV", objNull ];

if(isalive _uav) then // Probably also good to check that none has taken the UAV while player is respawning
{
player connectTerminalToUAV _uav;

};

 

 

something like that, code not tested

 

Note: That's all client code

 

 

Share this post


Link to post
Share on other sites
On 12/15/2020 at 8:10 AM, Melody_Mike said:

May I ask how you identify the player and reconnect the uav on respawn (in dedicated)?

Do you check the player's class in the onPlayerRespawn.sqf, ie:
 


if (typeOf player == "B_Soldier_UAV_F") then { uav1 connectTerminalToUAV player; };

?

UAV disconnect on killed/respawned in dedicated?

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

×