Skip to content

Commit

Permalink
destroy player's vehicles when he disconnects
Browse files Browse the repository at this point in the history
  • Loading branch information
in0finite committed May 31, 2020
1 parent a6713c2 commit 5fe0a8f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
24 changes: 19 additions & 5 deletions Assets/Scripts/Networking/PlayerRequests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ public override void OnStartLocalPlayer()
Local = this;
}

void OnDisable()
{
// destroy player's vehicles
if (NetStatus.IsServer)
{
this.DestroyPlayersVehicles();
}
}


public bool CanPlayerSpawnVehicle()
{
Expand Down Expand Up @@ -116,14 +125,19 @@ void CmdRequestSuicide()
void CmdRequestToDestroyMyVehicles()
{
F.RunExceptionSafe( () => {
m_myVehicles.RemoveDeadObjects();
foreach (var v in m_myVehicles)
{
Destroy(v.gameObject);
}
this.DestroyPlayersVehicles();
});
}

void DestroyPlayersVehicles()
{
m_myVehicles.RemoveDeadObjects();
foreach (var v in m_myVehicles)
{
Destroy(v.gameObject);
}
}

public void RequestTeleport(Vector3 pos, Quaternion rot)
{
this.CmdRequestTeleport(pos, rot);
Expand Down
4 changes: 4 additions & 0 deletions Docs/Multiplayer.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

- remove spamming logs:

- wheel sync list: flush it before adding to it

- when player disconnects, destroy his vehicles

- test situation when player connects, and there are peds sitting in vehicles

***
Expand Down
4 changes: 2 additions & 2 deletions Docs/TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@

- Does 'O' button changes quality level ?

- Reduce physics time step to 30 - make it configurable in options

- Play sounds: horn ; empty weapon slot ; ped damage ; footsteps in run and sprint states ;

- Script execution order: HUD before pause menu and windows ; fps counter after all ;

- Add option to change fixed delta time ?

- Optimize Console.Update() - don't do trim excess for every log message

- don't fade high LOD meshes
Expand Down

0 comments on commit 5fe0a8f

Please sign in to comment.