2
0
Fork 0
mirror of https://github.com/GTA-ASM/SanAndreasUnity synced 2025-03-05 07:37:17 +00:00

Remove authority when ped exits vehicle

This commit is contained in:
in0finite 2019-05-05 23:49:21 +02:00
parent 45897ebd9d
commit 461a3087b8
2 changed files with 17 additions and 0 deletions
Assets/Scripts
Behaviours/Ped/States
Networking

View file

@ -71,6 +71,12 @@ namespace SanAndreasUnity.Behaviours.Peds.States
if (this.CurrentVehicleSeat.IsDriver)
this.CurrentVehicle.StopControlling();
if (m_isServer && this.CurrentVehicleSeat.IsDriver)
{
// remove authority
Net.NetManager.RemoveAuthority(this.CurrentVehicle.gameObject);
}
// send message to clients
if (m_isServer)
{

View file

@ -171,6 +171,17 @@ namespace SanAndreasUnity.Net
}
public static void RemoveAuthority(GameObject go)
{
NetStatus.ThrowIfNotOnServer();
var netIdentity = go.GetComponentOrThrow<NetworkIdentity>();
if (netIdentity.clientAuthorityOwner != null)
netIdentity.RemoveClientAuthority(netIdentity.clientAuthorityOwner);
}
public static void ChangeScene(string newScene)
{
NetworkManager.singleton.ServerChangeScene(newScene);