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
/// </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"></param>
/// <param name="args">Arguments</param>
public void SendCustomEvent(int hash,List<object> args)
{
if (!IsReady)
@ -234,6 +234,11 @@ namespace RageCoop.Server
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)
{
if (!IsReady)

View File

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

View File

@ -146,7 +146,7 @@ namespace RageCoop.Server
public ServerObject[] GetAllObjects()
{
return ServerObjects.Values.ToArray();
}
}
/// <summary>
/// Not thread safe
@ -224,5 +224,17 @@ namespace RageCoop.Server
// Server.Logger?.Trace($"Removing ped:{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>
/// NPC data won't be sent to a player if their distance is greater than this value. -1 for unlimited.
/// </summary>
public float NpcStreamingDistance { get; set; } = 500;
public float NpcStreamingDistance { get; set; } = 500 ;
/// <summary>
/// Player's data won't be sent to another player if their distance is greater than this value. -1 for unlimited.
/// </summary>