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:
parent
45897ebd9d
commit
461a3087b8
2 changed files with 17 additions and 0 deletions
Assets/Scripts
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue