Fix player position not correctly set

This commit is contained in:
Sardelka 2022-07-02 12:39:50 +08:00
parent 8ee188cf19
commit 0b2ec1d626
4 changed files with 26 additions and 7 deletions

View File

@ -209,7 +209,7 @@ namespace RageCoop.Server
/// Trigger a CustomEvent for this client /// Trigger a CustomEvent for this client
/// </summary> /// </summary>
/// <param name="hash">An unique identifier of the event, you can use <see cref="CustomEvents.Hash(string)"/> to get it from a string</param> /// <param name="hash">An unique identifier of the event, you can use <see cref="CustomEvents.Hash(string)"/> to get it from a string</param>
/// <param name="args"></param> /// <param name="args">Arguments</param>
public void SendCustomEvent(int hash,List<object> args) public void SendCustomEvent(int hash,List<object> args)
{ {
if (!IsReady) if (!IsReady)
@ -234,6 +234,11 @@ namespace RageCoop.Server
Server.Logger?.Error(ex); Server.Logger?.Error(ex);
} }
} }
/// <summary>
/// Trigger a CustomEvent for this client
/// </summary>
/// <param name="hash">An unique identifier of the event, you can use <see cref="CustomEvents.Hash(string)"/> to get it from a string</param>
/// <param name="args">Arguments</param>
public void SendCustomEvent(int hash,params object[] args) public void SendCustomEvent(int hash,params object[] args)
{ {
if (!IsReady) if (!IsReady)

View File

@ -599,16 +599,18 @@ namespace RageCoop.Server
// Add the player to Players // Add the player to Players
lock (Clients) lock (Clients)
{ {
var player = new ServerPed
{
ID= packet.PedID,
};
Entities.Add(player);
Clients.Add(connection.RemoteUniqueIdentifier, Clients.Add(connection.RemoteUniqueIdentifier,
tmpClient = new Client(this) tmpClient = new Client(this)
{ {
NetID = connection.RemoteUniqueIdentifier, NetID = connection.RemoteUniqueIdentifier,
Connection=connection, Connection=connection,
Username=packet.Username, Username=packet.Username,
Player = new() Player = player
{
ID= packet.PedID,
}
} }
);; );;
} }

View File

@ -224,5 +224,17 @@ namespace RageCoop.Server
// Server.Logger?.Trace($"Removing ped:{id}"); // Server.Logger?.Trace($"Removing ped:{id}");
if (Peds.ContainsKey(id)) { Peds.Remove(id); } if (Peds.ContainsKey(id)) { Peds.Remove(id); }
} }
internal void Add(ServerPed ped)
{
if (Peds.ContainsKey(ped.ID))
{
Peds[ped.ID]=ped;
}
else
{
Peds.Add(ped.ID, ped);
}
}
} }
} }

View File

@ -42,7 +42,7 @@
/// <summary> /// <summary>
/// NPC data won't be sent to a player if their distance is greater than this value. -1 for unlimited. /// NPC data won't be sent to a player if their distance is greater than this value. -1 for unlimited.
/// </summary> /// </summary>
public float NpcStreamingDistance { get; set; } = 500; public float NpcStreamingDistance { get; set; } = 500 ;
/// <summary> /// <summary>
/// Player's data won't be sent to another player if their distance is greater than this value. -1 for unlimited. /// Player's data won't be sent to another player if their distance is greater than this value. -1 for unlimited.
/// </summary> /// </summary>