Some tweaks
This commit is contained in:
@ -124,7 +124,8 @@ namespace RageCoop.Client
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Player Latency in second.
|
/// Player Latency in second.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float Latency { get; internal set; }
|
public float Latency { get; set; }
|
||||||
|
|
||||||
|
public bool DisplayNameTag { get; set; } = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ namespace RageCoop.Client.Scripting
|
|||||||
public override void OnStart()
|
public override void OnStart()
|
||||||
{
|
{
|
||||||
API.RegisterCustomEventHandler(CustomEvents.SetAutoRespawn,SetAutoRespawn);
|
API.RegisterCustomEventHandler(CustomEvents.SetAutoRespawn,SetAutoRespawn);
|
||||||
|
API.RegisterCustomEventHandler(CustomEvents.SetDisplayNameTag,SetDisplayNameTag);
|
||||||
API.RegisterCustomEventHandler(CustomEvents.NativeCall,NativeCall);
|
API.RegisterCustomEventHandler(CustomEvents.NativeCall,NativeCall);
|
||||||
API.RegisterCustomEventHandler(CustomEvents.ServerPropSync, ServerObjectSync);
|
API.RegisterCustomEventHandler(CustomEvents.ServerPropSync, ServerObjectSync);
|
||||||
API.RegisterCustomEventHandler(CustomEvents.DeleteServerProp, DeleteServerProp);
|
API.RegisterCustomEventHandler(CustomEvents.DeleteServerProp, DeleteServerProp);
|
||||||
@ -27,6 +28,12 @@ namespace RageCoop.Client.Scripting
|
|||||||
API.Events.OnVehicleDeleted+=(s, p) => { API.SendCustomEvent(CustomEvents.OnVehicleDeleted, p.ID); };
|
API.Events.OnVehicleDeleted+=(s, p) => { API.SendCustomEvent(CustomEvents.OnVehicleDeleted, p.ID); };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SetDisplayNameTag(CustomEventReceivedArgs e)
|
||||||
|
{
|
||||||
|
var p = PlayerList.GetPlayer((int)e.Args[0]);
|
||||||
|
if(p != null) { p.DisplayNameTag=(bool)e.Args[1]; }
|
||||||
|
}
|
||||||
|
|
||||||
private void UpdatePedBlip(CustomEventReceivedArgs e)
|
private void UpdatePedBlip(CustomEventReceivedArgs e)
|
||||||
{
|
{
|
||||||
var p = Ped.FromHandle((int)e.Args[0]);
|
var p = Ped.FromHandle((int)e.Args[0]);
|
||||||
@ -51,7 +58,12 @@ namespace RageCoop.Client.Scripting
|
|||||||
{
|
{
|
||||||
var vehicleModel = (Model)e.Args[1];
|
var vehicleModel = (Model)e.Args[1];
|
||||||
vehicleModel.Request(1000);
|
vehicleModel.Request(1000);
|
||||||
var veh = World.CreateVehicle(vehicleModel, (Vector3)e.Args[2], (float)e.Args[3]);
|
Vehicle veh= World.CreateVehicle(vehicleModel, (Vector3)e.Args[2], (float)e.Args[3]);
|
||||||
|
while (veh==null)
|
||||||
|
{
|
||||||
|
veh = World.CreateVehicle(vehicleModel, (Vector3)e.Args[2], (float)e.Args[3]);
|
||||||
|
System.Threading.Thread.Sleep(10);
|
||||||
|
}
|
||||||
veh.CanPretendOccupants=false;
|
veh.CanPretendOccupants=false;
|
||||||
var v = new SyncedVehicle()
|
var v = new SyncedVehicle()
|
||||||
{
|
{
|
||||||
@ -104,7 +116,7 @@ namespace RageCoop.Client.Scripting
|
|||||||
}
|
}
|
||||||
private void SetNameTag(CustomEventReceivedArgs e)
|
private void SetNameTag(CustomEventReceivedArgs e)
|
||||||
{
|
{
|
||||||
var p = EntityPool.GetPedByID((int)e.Args[0]);
|
var p =PlayerList.GetPlayer((int)e.Args[0]);
|
||||||
if(p!= null)
|
if(p!= null)
|
||||||
{
|
{
|
||||||
p.DisplayNameTag=(bool)e.Args[1];
|
p.DisplayNameTag=(bool)e.Args[1];
|
||||||
|
@ -32,7 +32,7 @@ namespace RageCoop.Client
|
|||||||
|
|
||||||
Function.Call(Hash._SET_PED_CAN_PLAY_INJURED_ANIMS, false);
|
Function.Call(Hash._SET_PED_CAN_PLAY_INJURED_ANIMS, false);
|
||||||
MainPed.SetConfigFlag((int)PedConfigFlags.CPED_CONFIG_FLAG_DisableHurt, true);
|
MainPed.SetConfigFlag((int)PedConfigFlags.CPED_CONFIG_FLAG_DisableHurt, true);
|
||||||
MainPed.SetConfigFlag((int)PedConfigFlags.CPED_CONFIG_FLAG_DisableMelee, true);
|
// MainPed.SetConfigFlag((int)PedConfigFlags.CPED_CONFIG_FLAG_DisableMelee, true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,12 +46,11 @@ namespace RageCoop.Client
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region PLAYER -- ONLY
|
#region PLAYER -- ONLY
|
||||||
internal string Username = "N/A";
|
|
||||||
internal Blip PedBlip = null;
|
internal Blip PedBlip = null;
|
||||||
internal BlipColor BlipColor = (BlipColor)255;
|
internal BlipColor BlipColor = (BlipColor)255;
|
||||||
internal BlipSprite BlipSprite = (BlipSprite)0;
|
internal BlipSprite BlipSprite = (BlipSprite)0;
|
||||||
internal float BlipScale=1;
|
internal float BlipScale=1;
|
||||||
internal bool DisplayNameTag { get; set; } = true;
|
internal PlayerData Player;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -84,14 +83,10 @@ namespace RageCoop.Client
|
|||||||
{
|
{
|
||||||
if (IsPlayer)
|
if (IsPlayer)
|
||||||
{
|
{
|
||||||
if (Username=="N/A")
|
if (Player==null)
|
||||||
{
|
{
|
||||||
var p = PlayerList.GetPlayer(this);
|
Player = PlayerList.GetPlayer(this);
|
||||||
if (p!=null)
|
return;
|
||||||
{
|
|
||||||
Username=p.Username;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
RenderNameTag();
|
RenderNameTag();
|
||||||
}
|
}
|
||||||
@ -123,20 +118,10 @@ namespace RageCoop.Client
|
|||||||
else if (((byte)BlipColor != 255) && PedBlip==null)
|
else if (((byte)BlipColor != 255) && PedBlip==null)
|
||||||
{
|
{
|
||||||
PedBlip=MainPed.AddBlip();
|
PedBlip=MainPed.AddBlip();
|
||||||
|
|
||||||
if (IsPlayer)
|
if (IsPlayer)
|
||||||
{
|
{
|
||||||
Main.QueueAction(() =>
|
PedBlip.Name=Player.Username;
|
||||||
{
|
|
||||||
if (Username=="N/A")
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
PedBlip.Name=Username;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
PedBlip.Color=BlipColor;
|
PedBlip.Color=BlipColor;
|
||||||
PedBlip.Sprite=BlipSprite;
|
PedBlip.Sprite=BlipSprite;
|
||||||
@ -159,6 +144,17 @@ namespace RageCoop.Client
|
|||||||
{
|
{
|
||||||
SetClothes();
|
SetClothes();
|
||||||
}
|
}
|
||||||
|
var b = MainPed.AttachedBlip;
|
||||||
|
if (b==null || b.Color!=BlipColor || b.Sprite!=BlipSprite)
|
||||||
|
{
|
||||||
|
PedBlip=MainPed.AddBlip();
|
||||||
|
PedBlip.Color=BlipColor;
|
||||||
|
PedBlip.Sprite =BlipSprite;
|
||||||
|
if (IsPlayer)
|
||||||
|
{
|
||||||
|
b.Name=Player.Username;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CheckCurrentWeapon();
|
CheckCurrentWeapon();
|
||||||
}
|
}
|
||||||
@ -206,12 +202,12 @@ namespace RageCoop.Client
|
|||||||
|
|
||||||
private void RenderNameTag()
|
private void RenderNameTag()
|
||||||
{
|
{
|
||||||
if (!DisplayNameTag || (MainPed==null) || !MainPed.IsVisible || !MainPed.IsInRange(Game.Player.Character.Position, 20f))
|
if (!Player.DisplayNameTag || (MainPed==null) || !MainPed.IsVisible || !MainPed.IsInRange(Game.Player.Character.Position, 20f))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
string renderText = IsOutOfSync ? "~r~AFK" : Username;
|
string renderText = IsOutOfSync ? "~r~AFK" : Player.Username;
|
||||||
Vector3 targetPos = MainPed.Bones[Bone.IKHead].Position + new Vector3(0, 0, 0.35f);
|
Vector3 targetPos = MainPed.Bones[Bone.IKHead].Position + new Vector3(0, 0, 0.35f);
|
||||||
|
|
||||||
Function.Call(Hash.SET_DRAW_ORIGIN, targetPos.X, targetPos.Y, targetPos.Z, 0);
|
Function.Call(Hash.SET_DRAW_ORIGIN, targetPos.X, targetPos.Y, targetPos.Z, 0);
|
||||||
@ -263,13 +259,6 @@ namespace RageCoop.Client
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Function.Call(Hash.SET_PED_CAN_EVASIVE_DIVE, MainPed.Handle, false);
|
|
||||||
Function.Call(Hash.SET_PED_DROPS_WEAPONS_WHEN_DEAD, MainPed.Handle, false);
|
|
||||||
Function.Call(Hash.SET_PED_CAN_BE_TARGETTED, MainPed.Handle, true);
|
|
||||||
Function.Call(Hash.SET_PED_CAN_BE_TARGETTED_BY_PLAYER, MainPed.Handle, Game.Player, true);
|
|
||||||
Function.Call(Hash.SET_PED_GET_OUT_UPSIDE_DOWN_VEHICLE, MainPed.Handle, false);
|
|
||||||
Function.Call(Hash.SET_CAN_ATTACK_FRIENDLY, MainPed.Handle, true, true);
|
|
||||||
Function.Call(Hash._SET_PED_CAN_PLAY_INJURED_ANIMS, false);
|
|
||||||
|
|
||||||
MainPed.BlockPermanentEvents = true;
|
MainPed.BlockPermanentEvents = true;
|
||||||
MainPed.CanWrithe=false;
|
MainPed.CanWrithe=false;
|
||||||
@ -279,8 +268,16 @@ namespace RageCoop.Client
|
|||||||
MainPed.IsFireProof=false;
|
MainPed.IsFireProof=false;
|
||||||
MainPed.IsExplosionProof=false;
|
MainPed.IsExplosionProof=false;
|
||||||
|
|
||||||
|
Function.Call(Hash.SET_PED_DROPS_WEAPONS_WHEN_DEAD, MainPed.Handle, false);
|
||||||
|
Function.Call(Hash.SET_PED_CAN_BE_TARGETTED, MainPed.Handle, true);
|
||||||
|
Function.Call(Hash.SET_PED_CAN_BE_TARGETTED_BY_PLAYER, MainPed.Handle, Game.Player, true);
|
||||||
|
Function.Call(Hash.SET_PED_GET_OUT_UPSIDE_DOWN_VEHICLE, MainPed.Handle, false);
|
||||||
|
Function.Call(Hash.SET_CAN_ATTACK_FRIENDLY, MainPed.Handle, true, true);
|
||||||
|
Function.Call(Hash._SET_PED_CAN_PLAY_INJURED_ANIMS, false);
|
||||||
|
Function.Call(Hash.SET_PED_CAN_EVASIVE_DIVE, MainPed.Handle, false);
|
||||||
|
|
||||||
|
|
||||||
MainPed.SetConfigFlag((int)PedConfigFlags.CPED_CONFIG_FLAG_DrownsInWater,false);
|
MainPed.SetConfigFlag((int)PedConfigFlags.CPED_CONFIG_FLAG_DrownsInWater,false);
|
||||||
MainPed.SetConfigFlag((int)PedConfigFlags.CPED_CONFIG_FLAG_DisableMelee, true);
|
|
||||||
MainPed.SetConfigFlag((int)PedConfigFlags.CPED_CONFIG_FLAG_DisableHurt, true);
|
MainPed.SetConfigFlag((int)PedConfigFlags.CPED_CONFIG_FLAG_DisableHurt, true);
|
||||||
MainPed.SetConfigFlag((int)PedConfigFlags.CPED_CONFIG_FLAG_DisableExplosionReactions, true);
|
MainPed.SetConfigFlag((int)PedConfigFlags.CPED_CONFIG_FLAG_DisableExplosionReactions, true);
|
||||||
MainPed.SetConfigFlag((int)PedConfigFlags.CPED_CONFIG_FLAG_AvoidTearGas, false);
|
MainPed.SetConfigFlag((int)PedConfigFlags.CPED_CONFIG_FLAG_AvoidTearGas, false);
|
||||||
|
@ -54,7 +54,7 @@ namespace RageCoop.Server
|
|||||||
public bool EnableAutoRespawn {
|
public bool EnableAutoRespawn {
|
||||||
get { return _autoRespawn; }
|
get { return _autoRespawn; }
|
||||||
set {
|
set {
|
||||||
Server.BaseScript.SetAutoRespawn(this,value);
|
BaseScript.SetAutoRespawn(this,value);
|
||||||
_autoRespawn=value;
|
_autoRespawn=value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -155,9 +155,9 @@ namespace RageCoop.Server.Scripting
|
|||||||
/// Get a list of all Clients
|
/// Get a list of all Clients
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>All clients as a dictionary indexed by NetID</returns>
|
/// <returns>All clients as a dictionary indexed by NetID</returns>
|
||||||
public Dictionary<long, Client> GetAllClients()
|
public Dictionary<string, Client> GetAllClients()
|
||||||
{
|
{
|
||||||
return new(Server.Clients);
|
return new(Server.ClientsByName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -25,7 +25,7 @@ namespace RageCoop.Server.Scripting
|
|||||||
public override void OnStop()
|
public override void OnStop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
public void SetAutoRespawn(Client c,bool toggle)
|
public static void SetAutoRespawn(Client c,bool toggle)
|
||||||
{
|
{
|
||||||
c.SendCustomEvent(CustomEvents.SetAutoRespawn, toggle );
|
c.SendCustomEvent(CustomEvents.SetAutoRespawn, toggle );
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,7 @@ namespace RageCoop.Server
|
|||||||
|
|
||||||
internal readonly Dictionary<Command, Action<CommandContext>> Commands = new();
|
internal readonly Dictionary<Command, Action<CommandContext>> Commands = new();
|
||||||
internal readonly Dictionary<long,Client> Clients = new();
|
internal readonly Dictionary<long,Client> Clients = new();
|
||||||
|
internal readonly Dictionary<string, Client> ClientsByName = new();
|
||||||
|
|
||||||
private Dictionary<int,FileTransfer> InProgressFileTransfers=new();
|
private Dictionary<int,FileTransfer> InProgressFileTransfers=new();
|
||||||
private Resources Resources;
|
private Resources Resources;
|
||||||
@ -617,7 +618,8 @@ namespace RageCoop.Server
|
|||||||
Username=packet.Username,
|
Username=packet.Username,
|
||||||
Player = player
|
Player = player
|
||||||
}
|
}
|
||||||
);;
|
);
|
||||||
|
ClientsByName.Add(packet.Username, tmpClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger?.Debug($"Handshake sucess, Player:{packet.Username} PedID:{packet.PedID}");
|
Logger?.Debug($"Handshake sucess, Player:{packet.Username} PedID:{packet.PedID}");
|
||||||
@ -690,6 +692,7 @@ namespace RageCoop.Server
|
|||||||
_worker.QueueJob(() => API.Events.InvokePlayerDisconnected(localClient));
|
_worker.QueueJob(() => API.Events.InvokePlayerDisconnected(localClient));
|
||||||
Logger?.Info($"Player {localClient.Username} disconnected! ID:{localClient.Player.ID}");
|
Logger?.Info($"Player {localClient.Username} disconnected! ID:{localClient.Player.ID}");
|
||||||
Clients.Remove(localClient.NetID);
|
Clients.Remove(localClient.NetID);
|
||||||
|
ClientsByName.Remove(localClient.Username);
|
||||||
Security.RemoveConnection(localClient.Connection.RemoteEndPoint);
|
Security.RemoveConnection(localClient.Connection.RemoteEndPoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user