This commit is contained in:
Sardelka 2022-07-11 11:59:32 +08:00
parent cda4f702a1
commit b2911017d0
4 changed files with 9 additions and 11 deletions

View File

@ -302,7 +302,7 @@ namespace RageCoop.Client
SyncedPed c = EntityPool.GetPedByID(packet.ID);
if (c==null)
{
Main.Logger.Debug($"Creating character for incoming sync:{packet.ID}");
// Main.Logger.Debug($"Creating character for incoming sync:{packet.ID}");
EntityPool.ThreadSafe.Add(c=new SyncedPed(packet.ID));
}
PedDataFlags flags = packet.Flag;
@ -414,7 +414,7 @@ namespace RageCoop.Client
if (p==null)
{
if (packet.Exploded) { return; }
Main.Logger.Debug($"Creating new projectile: {(WeaponHash)packet.WeaponHash}");
// Main.Logger.Debug($"Creating new projectile: {(WeaponHash)packet.WeaponHash}");
EntityPool.ThreadSafe.Add(p=new SyncedProjectile(packet.ID));
}
p.Position=packet.Position;

View File

@ -30,7 +30,7 @@ namespace RageCoop.Client.Scripting
API.RegisterCustomEventHandler(CustomEvents.DeleteServerBlip, DeleteServerBlip);
API.RegisterCustomEventHandler(CustomEvents.CreateVehicle, CreateVehicle);
API.RegisterCustomEventHandler(CustomEvents.UpdatePedBlip, UpdatePedBlip);
API.RegisterCustomEventHandler(CustomEvents.IsHost, (e) => { _isHost=(bool)e.Args[0]; Main.Logger.Debug("Host:"+_isHost); });
API.RegisterCustomEventHandler(CustomEvents.IsHost, (e) => { _isHost=(bool)e.Args[0]; });
API.RegisterCustomEventHandler(CustomEvents.WeatherTimeSync, WeatherTimeSync);
Task.Run(() =>
{
@ -47,15 +47,10 @@ namespace RageCoop.Client.Scripting
int weather2 = default(int);
float percent2 = default(float);
Function.Call(Hash._GET_WEATHER_TYPE_TRANSITION, &weather1, &weather2, &percent2);
Main.Logger.Debug("Sending: "+ string.Format("{0},{1},{2},{3},{4},{5}", time.Hours, time.Minutes, time.Seconds, weather1, weather2, percent2));
API.SendCustomEvent(CustomEvents.WeatherTimeSync, time.Hours, time.Minutes, time.Seconds, weather1, weather2, percent2);
}
});
}
else
{
Main.Logger.Debug("not host");
}
Thread.Sleep(1000);
}
@ -76,7 +71,7 @@ namespace RageCoop.Client.Scripting
private void UpdatePedBlip(CustomEventReceivedArgs e)
{
var p = Ped.FromHandle((int)e.Args[0]);
var p = Entity.FromHandle((int)e.Args[0]);
if (p == null) { return; }
if (p.Handle==Game.Player.Character.Handle)
{
@ -102,7 +97,7 @@ namespace RageCoop.Client.Scripting
while (veh==null)
{
veh = World.CreateVehicle(vehicleModel, (Vector3)e.Args[2], (float)e.Args[3]);
System.Threading.Thread.Sleep(10);
Thread.Sleep(10);
}
veh.CanPretendOccupants=false;
var v = new SyncedVehicle()

View File

@ -121,6 +121,7 @@ namespace RageCoop.Client
if (IsPlayer)
{
Main.Logger.Debug("blip:"+Player.Username);
PedBlip.Name=Player.Username;
}
PedBlip.Color=BlipColor;
@ -147,11 +148,13 @@ namespace RageCoop.Client
var b = MainPed.AttachedBlip;
if (b==null || b.Color!=BlipColor || b.Sprite!=BlipSprite)
{
PedBlip?.Delete();
PedBlip=MainPed.AddBlip();
PedBlip.Color=BlipColor;
PedBlip.Sprite =BlipSprite;
if (IsPlayer)
{
Main.Logger.Debug("blip:"+Player.Username);
b.Name=Player.Username;
}
}

View File

@ -135,7 +135,7 @@ namespace RageCoop.Client
SyncedPed c = new SyncedPed(p);
Main.LocalPlayerID=c.OwnerID=c.ID;
Add(c);
Main.Logger.Debug($"My player ID is:{c.ID}");
Main.Logger.Debug($"Local player ID is:{c.ID}");
PlayerList.SetPlayer(c.ID, Main.Settings.Username );
return true;
}