Facepunch / sbox-issues

177 stars 12 forks source link

Prevent objects from being destroyed when the owner disconnects. #4720

Closed badandbest closed 5 months ago

badandbest commented 9 months ago

For?

S&Box

What can't you do?

I'm unable to prevent an object from being destroyed when the owner disconnects.

This is bad for things the player needs to temporarily take control of ( e.g vehicles, held items ).

https://github.com/Facepunch/sbox-issues/assets/91832803/3ce52eb9-3e7c-495d-9540-ea62e0770bc8

How would you like it to work?

I'd want it to drop ownership instead of destroying it. IIRC Garry mentioned it would be a flag.

Edit: It'd be a good idea to also let the components know. Maybe an OnOwnerChanged( Connection )?

What have you tried?

I've tried dropping ownership in OnDisconnected but it still gets destroyed,

public void OnDisconnected( Connection client )
{
    foreach ( var player in Scene.GetAllComponents<Player>().Where( p => p.Network.OwnerId == client.Id ) )
    {
        player.Network.DropOwnership();
    }
}

Additional context

No response

MrBrax commented 9 months ago

there has to be a big rework with how ownership is handled, a client being able to take over anything is disastrous and just reminds me of gta online cheaters. there's gotta be an authoritative host to prevent abuse.

badandbest commented 9 months ago

there has to be a big rework with how ownership is handled, a client being able to take over anything is disastrous and just reminds me of gta online cheaters. there's gotta be an authoritative host to prevent abuse.

We have network authority now

MrBrax commented 9 months ago

there has to be a big rework with how ownership is handled, a client being able to take over anything is disastrous and just reminds me of gta online cheaters. there's gotta be an authoritative host to prevent abuse.

We have network authority now

indeed, just saw the commits. great improvement. i think selective rpc's are left now?

kurozael commented 5 months ago

You can now do this by setting the Orphaned Mode on the networked object.