private void OnApproved(Message packet) { try { using (Approval approval = Approval.Deserialize(packet.read)) { ConsoleSystem.LogWarning($"[VirtualServer]: Вы подключились к: {(approval.official ? "[Oficial] " : "")}" + approval.hostname); BaseClient.Connection.encryptionLevel = approval.encryption; BaseClient.Connection.decryptIncoming = true; if (BaseServer.write.Start()) { BaseServer.write.PacketID(Message.Type.Approved); Approval.Serialize(BaseServer.write, approval); BaseServer.Send(); } BaseServer.SetEncryptionLevel(approval.encryption); } } catch (Exception ex) { ConsoleSystem.LogError("[VirtualServer]: Исключение в OnApproved(): " + ex.Message); } }
public static void Show() { ConsoleSystem.LogWarning("[TimeDebugger]: Total debug times:"); double TotalTime = 0; string maxLenName = ""; foreach (var row in ListWorkTimes) { if (maxLenName.Length < row.Key.Length) { maxLenName = row.Key; } } foreach (var row in ListWorkTimes) { TotalTime += row.Value; string line = row.Key + ":"; for (int i = 0; i < maxLenName.Length - row.Key.Length; ++i) { line += ' '; } ConsoleSystem.LogWarning($"{line} [{row.Value:F3} sec]"); } ConsoleSystem.LogWarning($"[TimeDebugger]: Total work time: [{TotalTime:F3} sec]"); }
void IDisposable.Dispose() { if (_disposed) { return; } _disposed = true; if (OnEnd != null) { OnEnd(); } if (Enabled && _stopwatch.Elapsed.TotalMilliseconds > _warningMs) { var flag = _gcCount != GC.CollectionCount(0); object[] totalSeconds = { _warningName, null, null, null }; totalSeconds[1] = _stopwatch.Elapsed.TotalSeconds; totalSeconds[2] = _stopwatch.Elapsed.TotalMilliseconds; totalSeconds[3] = !flag ? string.Empty : " [GARBAGE COLLECT]"; ConsoleSystem.LogWarning(string.Format("TimeWarning: {0} took {1:0.00} seconds ({2:0} ms){3}", totalSeconds)); } var timeWarning = this; Pool.Free(ref timeWarning); }
public static bool Silent(PlayerProjectileAttack attack) { if (Instance.TargetPlayer != null) { EHumanBone typeHit = OpCodes.GetTargetHit(0, Settings.Aimbot_Range_Manual_AutoHeadshot); var hitPosition = Instance.TargetPlayer.Position + new Vector3(0, 50, 0); var distance = Vector3.Distance(LocalPlayer.EyePos, hitPosition); var distance2 = Vector3.Distance(LocalPlayer.Position, attack.playerAttack.attack.hitPositionWorld); // ConsoleSystem.Log("Distance2 => " +distance2); // ConsoleSystem.Log("Distance => " +GetTimeout(FiredProjectiles[attack.playerAttack.projectileID], distance2)); float timeout = 0; if (distance2 < distance) { timeout = GetTimeout(FiredProjectiles[attack.playerAttack.projectileID], distance - distance2); } if (timeout <= 0) { timeout = 0.001f; } ConsoleSystem.LogWarning("[Silent] Sleep => " + timeout); var player = Instance.TargetPlayer; var attackCopy = attack.Copy(); SapphireEngine.Functions.Timer.SetTimeout(() => SendRangeAttack(player, typeHit, attackCopy, hitPosition), timeout); return(true); } return(false); }
internal void ConnectedPacket(Connection connection) { if (connection.GetPacketsPerSecond(0) >= Server.MaxPacketsPerSecond) { this.Kick(connection, "Kicked: Packet Flooding"); ConsoleSystem.LogWarning(string.Concat(connection.ToString(), " was kicked for packet flooding")); return; } connection.AddPacketsPerSecond(0); this.read.Start(connection); byte num = this.read.PacketID(); if (this.HandleRaknetPacket(num, connection)) { return; } num = (byte)(num - 140); Message message = base.StartMessage((Message.Type)num, connection); if (this.onMessage != null) { this.onMessage(message); } message.Clear(); Pool.Free(ref message); }
internal void ConnectedPacket(Connection connection) { if (connection.GetPacketsPerSecond(0) >= MaxPacketsPerSecond) { Kick(connection, "Kicked: Packet Flooding"); ConsoleSystem.LogWarning(string.Concat(connection.ToString(), " was kicked for packet flooding")); return; } connection.AddPacketsPerSecond(0); read.Start(connection); var num = read.PacketId(); if (HandleRaknetPacket(num, connection)) { return; } num = (byte)(num - 140); var message = StartMessage((Message.Type)num, connection); if (OnMessage != null) { OnMessage(message); } message.Clear(); Pool.Free(ref message); }
private void OnApproved(Message packet) { try { using (var approval = Approval.Deserialize(packet.read)) { ConsoleSystem.LogWarning( $"[VirtualServer]: Подключились к: {(approval.official ? "[Oficial] " : "")}" + approval.hostname); if (_quitAfterConnected) { BaseClient.Disconnect("", true); Framework.Quit(); } BaseClient.Connection.encryptionLevel = approval.encryption; BaseClient.Connection.decryptIncoming = true; if (BaseClient.write.Start()) { BaseClient.write.PacketId(Message.Type.Ready); BaseClient.write.Send(new SendInfo(BaseClient.Connection)); } packet.connection.encryptOutgoing = true; } } catch (Exception ex) { ConsoleSystem.LogError("[VirtualServer]: Исключение в OnApproved(): " + ex.Message); } }
public static void Run(uint uid, ERPCMethodType method, Message message) { if (ListRPCMethods.TryGetValue(method, out var methods)) { if (BaseNetworkable.ListNetworkables.TryGetValue(uid, out var networkable)) { var type = networkable.GetType(); var rpcmethod = methods.FirstOrDefault(p => p.Key == type || p.Key.IsSubclassOf(type)).Value; if (rpcmethod != null) { try { using (new TimeDebugger($"{method}", 0.001f)) { rpcmethod.Invoke(networkable, message); } } catch (Exception ex) { ConsoleSystem.LogError("[Data.Base.Network Run] Exception: " + ex.Message + System.Environment.NewLine + ex.StackTrace); } } } else { ConsoleSystem.LogWarning("[Data.Base.Network Run] Dont have networkable uid: " + uid); } } else { ConsoleSystem.LogWarning("[Data.Base.Network Run] Dont have released method: " + method + " from " + BaseNetworkable.ListNetworkables?[uid]); } }
public void IN_OnNetworkMessage(Message packet) { switch (packet.type) { case Message.Type.Approved: OnApproved(packet); break; case Message.Type.EAC: EACServer.OnMessageReceived(packet); SendPacket(BaseServer, packet); break; case Message.Type.DisconnectReason: SendPacket(BaseServer, packet); if (BaseServer != null && BaseServer.connections.Count > 0) { packet.read.Position = 1L; string reasone = packet.read.String(); BaseServer?.Kick(BaseServer.connections[0], reasone); ConsoleSystem.LogWarning("[VirtualServer]: От игрового сервера получена причина дисконнекта: " + reasone); } break; case Message.Type.Entities: packet.read.UInt32(); using (Entity entity = Entity.Deserialize(packet.read)) { if (EntityManager.OnEntity(entity) == false) { if (BaseServer.write.Start()) { BaseServer.write.PacketID(Message.Type.Entities); BaseServer.write.UInt32(TakeEntityNUM); entity.WriteToStream(BaseServer.write); BaseServer.write.Send(new SendInfo(BaseServer.connections[0])); } } } break; case Message.Type.EntityDestroy: EntityManager.OnEntityDestroy(packet); SendPacket(BaseServer, packet); break; case Message.Type.EntityPosition: EntityManager.OnEntityPosition(packet); SendPacket(BaseServer, packet); break; default: if (NetworkManager.Instance.IN_NetworkMessage(packet) == false) { SendPacket(BaseServer, packet); } break; } }
public void IN_OnDisconnected(string reason) { if (BaseServer != null && BaseServer.connections.Count > 0) { BaseServer?.Kick(BaseServer.connections[0], reason); ConsoleSystem.LogWarning("[VirtualServer]: Соеденение с игровым сервером разорвано: " + reason); } }
void OnRPC_MoveItem(Message packet) { uint itemid = packet.read.UInt32(); if (Item.ListItemsInWorld.TryGetValue(itemid, out Item itemTarget)) { if (itemTarget.Container == null || itemTarget.Container.EntityOwner == this) { uint newContainerUID = packet.read.UInt32(); if (ItemContainer.ListContainers.TryGetValue(newContainerUID, out ItemContainer containerTarget)) { if (containerTarget.EntityOwner == this) { int slot = packet.read.Int8(); int amount = packet.read.UInt16(); // TODO: Need release split system if (itemTarget.Container != containerTarget) { if (itemTarget.Container != null) { ItemContainer lastContainer = itemTarget.Container; int lastPositon = itemTarget.PositionInContainer; lastContainer.RemoveItemFromContainer(itemTarget); if (containerTarget.ListSlots.TryGetValue(slot, out Item itemInNewPosition)) { containerTarget.RemoveItemFromContainer(itemInNewPosition); lastContainer.AddItemToContainer(itemInNewPosition, lastPositon); } lastContainer.OnItemConainerUpdate(); } if (containerTarget.AddItemToContainer(itemTarget, slot)) { containerTarget.OnItemConainerUpdate(); } } else if (itemTarget.Container.ChangeItemSlotFromContainer(itemTarget, slot)) { itemTarget.Container.OnItemConainerUpdate(); } } else { ConsoleSystem.LogWarning("[BasePlayer.OnRPC_MoveItem]: Detected movie item to enemy container!"); } } } else { ConsoleSystem.LogWarning("[BasePlayer.OnRPC_MoveItem]: Detected movie enemy item to container!"); } } }
public void Dispose() { this.TotalSecondEndTime = DateTime.Now.Subtract(this.DateStartTime).TotalSeconds; ListWorkTimes[this.Name] = (ListWorkTimes.ContainsKey(this.Name) ? ListWorkTimes[this.Name] + this.TotalSecondEndTime : this.TotalSecondEndTime); if (this.TotalSecondEndTime > this.WarningTime) { ConsoleSystem.LogWarning($"[TimeDebugger]: <{this.Name}> work: [{this.TotalSecondEndTime:F3} sec] > [{this.WarningTime} sec]"); } }
private static void PrintLogType(LogType logType, string message, bool log = false) { if (global.logprint) { switch (logType) { case LogType.Error: { ConsoleSystem.LogError(message); return; } case LogType.Warning: { ConsoleSystem.LogWarning(message); return; } case LogType.Log: { ConsoleSystem.Log(message); return; } } } if (log && !ConsoleSystem.LogCallbackWritesToConsole) { try { ((logType != LogType.Log ? Console.Error : Console.Out)).WriteLine("Print{0}:{1}", logType, message); } catch (Exception exception) { Console.Error.WriteLine("PrintLogType Log Exception\n:{0}", exception); } } if (ConsoleSystem.RegisteredLogCallback) { try { ConsoleSystem.LogCallback(message, string.Empty, logType); } catch (Exception exception1) { Console.Error.WriteLine("PrintLogType Exception\n:{0}", exception1); } } }
public static Peer CreateServer(string ip, int port, int maxConnections) { var peer = new Peer(); peer._ptr = Native.NET_Create(); if (Native.NET_StartServer(peer._ptr, ip, port, maxConnections) == 0) { return(peer); } peer.Close(); var text = StringFromPointer(Native.NET_LastStartupError(peer._ptr)); ConsoleSystem.LogWarning(string.Concat("Couldn't create server on port ", port, " (", text, ")")); return(null); }
// Token: 0x06000037 RID: 55 RVA: 0x00002C50 File Offset: 0x00000E50 public static Peer CreateConnection(string hostname, int port, int retries, int retryDelay, int timeout) { var peer = new Peer(); peer._ptr = Native.NET_Create(); if (Native.NET_StartClient(peer._ptr, hostname, port, retries, retryDelay, timeout) == 0) { return(peer); } var text = StringFromPointer(Native.NET_LastStartupError(peer._ptr)); ConsoleSystem.LogWarning(string.Concat("Couldn't connect to server ", hostname, ":", port, " (", text, ")")); peer.Close(); return(null); }
public void OUT_OnDisconnected(string reason, Connection conn) { if (BaseClient?.IsConnected() == true) { ConsoleSystem.LogWarning("[VirtualServer]: Соеденение с игровым клиентом разорвано: " + reason); BaseClient?.Disconnect(reason, false); if (BaseClient != null & BaseClient.Connection != null) { BaseClient.Connection.decryptIncoming = false; BaseClient.Connection.encryptOutgoing = false; } NetworkManager.Instance.OnDisconnected(); ConnectionInformation = null; LastEntityNUM = 0; } EACServer.OnLeaveGame(conn); }
protected void HandleMessage() { this.read.Start(base.Connection); byte b = this.read.PacketID(); if (this.HandleRaknetPacket(b)) { return; } b -= 140; if (b > 22) { ConsoleSystem.LogWarning("Invalid Packet (higher than " + Message.Type.EAC + ")"); this.Disconnect(string.Concat(new object[] { "Invalid Packet (", b, ") ", this.peer.incomingBytes, "b" }), true); return; } Message message = base.StartMessage((Message.Type)b, base.Connection); if (this.onMessage != null) { try { using (TimeWarning.New("onMessage", 0.1f)) { this.onMessage(message); } } catch (Exception ex) { ConsoleSystem.LogError(ex.Message); } } message.Clear(); Pool.Free <Message>(ref message); }
public static void Load() { if (File.Exists(PathFileBase)) { Dictionary <string, string> lines_from_file = new Dictionary <string, string>(); var lines = File.ReadAllLines(PathFileBase); for (int i = 0; i < lines.Length; ++i) { if (lines[i].Length >= 2) { int indexSpliter = lines[i].IndexOf('='); if (indexSpliter > 0) { string key = lines[i].Substring(0, indexSpliter).ToLower(); key = key.Trim(); string value = string.Empty; if (indexSpliter + 1 < lines[i].Length) { value = lines[i].Remove(0, indexSpliter + 1); value = value.Trim(); } lines_from_file[key] = value; } } } var props = typeof(DefaultMessages).GetProperties(BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public); for (int i = 0; i < props.Length; ++i) { var prop_name = props[i].Name.ToLower(); if (lines_from_file.ContainsKey(prop_name)) { props[i].SetValue(null, lines_from_file[prop_name], new object[0]); } } ConsoleSystem.Log("[Data.Base.Message] Loaded!"); } else { ConsoleSystem.LogWarning("[Data.Base.Message] Not found file: " + PathFileBase); } }
protected void HandleMessage() { read.Start(Connection); var b = read.PacketId(); if (HandleRaknetPacket(b)) { return; } b -= 140; if (b > 23) { ConsoleSystem.LogWarning("Invalid Packet (higher than " + Message.Type.EAC + ")"); Disconnect(string.Concat("Invalid Packet (", b, ") ", _peer.IncomingBytes, "b"), true); return; } var message = StartMessage((Message.Type)b, Connection); if (OnMessage != null) { try { using (TimeWarning.New("onMessage", 0.1f)) { OnMessage(message); } } catch (Exception ex) { ConsoleSystem.LogError(ex.Message); } } message.Clear(); Pool.Free(ref message); }
internal static void OnServerCommand(string command) { Arg arg = Arg.FromServer(command); if (arg.Invalid) { ConsoleSystem.LogWarning($"Invalid console command: {command}"); return; } if (ListCommandMethods.TryGetValue(arg.Command, out CommandMethod cmdMethod) == false) { ConsoleSystem.LogWarning($"Unknown console command: {arg.Command}"); return; } cmdMethod.Call.Invoke(null, arg); if (string.IsNullOrEmpty(arg.Reply) == false) { ConsoleSystem.Log(arg.Reply); } }
internal static void OnClientCommand(Message packet) { string command = packet.read.String(); if (packet.connection == null || !packet.connection.connected) { ConsoleSystem.LogWarning(string.Concat("Client without connection tried to run command: ", command)); return; } Arg arg = Arg.FromClient(command, packet.connection); if (arg.Invalid) { ConsoleSystem.LogWarning($"Invalid console command from [{packet.ToPlayer().SteamID}/{packet.ToPlayer().Username}]: {command}"); return; } if (ListCommandMethods.TryGetValue(arg.Command, out CommandMethod cmdMethod) == false) { ConsoleSystem.LogWarning($"Unknown console command from [{packet.ToPlayer().SteamID}/{packet.ToPlayer().Username}]: {arg.Command}"); return; } if (cmdMethod.Attribute.IsAdmin && arg.IsAdmin == false) { SendClientReply(packet.connection, "You don't have permission to run this command"); return; } cmdMethod.Call.Invoke(null, arg); if (string.IsNullOrEmpty(arg.Reply) == false) { SendClientReply(packet.connection, arg.Reply); } }
public override void OnAwake() { Instance = this; var init = new Facepunch.Steamworks.ServerInit(BuildingInformation.SteamworksModDir, BuildingInformation.SteamworksGameDesc) { GamePort = (ushort)Settings.GamePort, IpAddress = IPAddress.Parse(Settings.ServerIP), Secure = Settings.Secure, VersionString = Settings.GameVersion.ToString(), }; BaseSteamServer = new Facepunch.Steamworks.Server(BuildingInformation.SteamworksAppID, init); if (BaseSteamServer.IsValid) { BaseSteamServer.LogOnAnonymous(); Timer.SetInterval(OnUpdateServerInformation, 10f); } else { BaseSteamServer.Dispose(); BaseSteamServer = null; ConsoleSystem.LogWarning("[SteamworksManager]: Steamworks is not initialized!"); } }
void System.IDisposable.Dispose() { if (this.disposed) { return; } this.disposed = true; if (TimeWarning.OnEnd != null) { TimeWarning.OnEnd(); } if (TimeWarning.Enabled && this.stopwatch.Elapsed.TotalMilliseconds > this.warningMS) { bool flag = this.gcCount != GC.CollectionCount(0); object[] totalSeconds = new object[] { this.warningName, null, null, null }; totalSeconds[1] = this.stopwatch.Elapsed.TotalSeconds; totalSeconds[2] = this.stopwatch.Elapsed.TotalMilliseconds; totalSeconds[3] = (!flag ? string.Empty : " [GARBAGE COLLECT]"); ConsoleSystem.LogWarning(String.Format("TimeWarning: {0} took {1:0.00} seconds ({2:0} ms){3}", totalSeconds)); } TimeWarning timeWarning = this; Pool.Free <TimeWarning>(ref timeWarning); }
public void IN_OnDisconnected(string reason) { ConsoleSystem.LogWarning("[VirtualServer]: Соеденение с игровым сервером разорвано: " + reason); }
public void Warning(string s) { ConsoleSystem.LogWarning("[Rust Essentials] " + s); logToFile(s, "warning"); }
internal bool HandleRaknetPacket(byte type) { if (type >= 140) { return(false); } OnRakNetPacket?.Invoke(type); switch (type) { case 16: ConnectionAccepted = true; if (Connection.guid != 0uL) { ConsoleSystem.Log("Multiple PacketType.CONNECTION_REQUEST_ACCEPTED"); } Connection.guid = _peer.IncomingGuid; return(true); case 17: Disconnect("Connection Attempt Failed", false); return(true); case 20: Disconnect("Server is Full", false); return(true); case 21: if (Connection != null && Connection.guid != _peer.IncomingGuid) { return(true); } Disconnect(DisconnectReason, false); return(true); case 22: if (Connection == null && Connection.guid != _peer.IncomingGuid) { return(true); } Disconnect("Timed Out", false); return(true); case 23: if (Connection == null && Connection.guid != _peer.IncomingGuid) { return(true); } Disconnect("Connection Banned", false); return(true); } if (Connection != null && _peer.IncomingGuid != Connection.guid) { ConsoleSystem.LogWarning(string.Concat("[CLIENT] Unhandled Raknet packet ", type, " from unknown source ", _peer.IncomingAddress)); return(true); } ConsoleSystem.LogWarning("Unhandled Raknet packet " + type); return(true); }
public static void HurtKilled(DamageEvent damage) { ulong num = 0uL; string text = ""; ulong num2 = 0uL; string text2 = ""; PlayerClient client = damage.victim.client; PlayerClient client2 = damage.attacker.client; bool flag = !(damage.victim.idMain is Character); bool flag2 = !(damage.attacker.idMain is Character); UserData userData = (client != null) ? Users.GetBySteamID(client.userID) : null; UserData userData2 = (client2 != null) ? Users.GetBySteamID(client2.userID) : null; if (userData == null) { } ClanData clanData = (userData2 != null) ? userData2.Clan : null; if (!flag2 || !(client2 == null)) { if (client2 != null) { text2 = damage.attacker.client.netUser.displayName; } else { text2 = Helper.NiceName(damage.attacker.character.name); Config.Get("NAMES." + ((userData == null) ? Core.Languages[0] : userData.Language), text2, ref text2, true); } if (flag) { if (!(damage.victim.idMain is SleepingAvatar) || !Economy.FeeSleeper) { return; } SleepingAvatar sleepingAvatar = damage.victim.idMain as SleepingAvatar; if (sleepingAvatar == null) { return; } UserData bySteamID = Users.GetBySteamID(sleepingAvatar.ownerID); if (bySteamID == null) { return; } ulong balance = Economy.GetBalance(bySteamID.SteamID); text = bySteamID.Username; if (Economy.FeeMurder) { num = (ulong)Math.Abs(balance * Economy.FeeMurderPercent / 100f); } if (Economy.PayMurder) { num2 = (ulong)Math.Abs(balance * Economy.PayMurderPercent / 100f); } if (num2 > 0uL && Clans.Enabled && clanData != null) { if (clanData.Level.BonusMembersPayMurder > 0u) { num2 += num2 * (ulong)clanData.Level.BonusMembersPayMurder / 100uL; } if (clanData.Tax > 0u) { ulong num3 = num2 * (ulong)clanData.Tax / 100uL; clanData.Balance += num3; num2 -= num3; } } if (num2 > 0uL) { Economy.BalanceAdd(client2.userID, num2); } if (num > 0uL) { Economy.BalanceSub(bySteamID.SteamID, num); } } else if (client != null) { text = damage.victim.client.netUser.displayName; ulong balance2 = Economy.GetBalance(client.userID); if (client2 == null) { if (Economy.FeeDeath) { num = (ulong)Math.Abs(balance2 * Economy.FeeDeathPercent / 100f); } } else if (!(client2 == client) && !flag2) { if (client2 != client && !flag2) { Economy.Get(client2.userID).PlayersKilled++; if (Economy.FeeMurder) { num = (ulong)Math.Abs(balance2 * Economy.FeeMurderPercent / 100f); } if (Economy.PayMurder) { num2 = (ulong)Math.Abs(balance2 * Economy.PayMurderPercent / 100f); } } } else if (Economy.FeeSuicide) { num = (ulong)Math.Abs(balance2 * Economy.FeeSuicidePercent / 100f); } if (num2 > 0uL && Clans.Enabled && clanData != null) { if (clanData.Level.BonusMembersPayMurder > 0u) { num2 += num2 * (ulong)clanData.Level.BonusMembersPayMurder / 100uL; } if (clanData.Tax > 0u) { ulong num4 = num2 * (ulong)clanData.Tax / 100uL; clanData.Balance += num4; num2 -= num4; } } if (num2 > 0uL) { Economy.BalanceAdd(client2.userID, num2); } if (num > 0uL) { Economy.BalanceSub(client.userID, num); } Economy.Get(client.userID).Deaths++; } else if (client2 != null) { text = Helper.NiceName(damage.victim.character.name); if (text.Equals("Chicken", StringComparison.OrdinalIgnoreCase)) { if (Economy.CostChicken != 0uL) { num2 = Economy.CostChicken; } Economy.Get(client2.userID).AnimalsKilled++; } else if (text.Equals("Rabbit", StringComparison.OrdinalIgnoreCase)) { if (Economy.CostRabbit != 0uL) { num2 = Economy.CostRabbit; } Economy.Get(client2.userID).AnimalsKilled++; } else if (text.Equals("Boar", StringComparison.OrdinalIgnoreCase)) { if (Economy.CostBoar != 0uL) { num2 = Economy.CostBoar; } Economy.Get(client2.userID).AnimalsKilled++; } else if (text.Equals("Stag", StringComparison.OrdinalIgnoreCase)) { if (Economy.CostStag != 0uL) { num2 = Economy.CostStag; } Economy.Get(client2.userID).AnimalsKilled++; } else if (text.Equals("Wolf", StringComparison.OrdinalIgnoreCase)) { if (Economy.CostWolf != 0uL) { num2 = Economy.CostWolf; } Economy.Get(client2.userID).AnimalsKilled++; } else if (text.Equals("Bear", StringComparison.OrdinalIgnoreCase)) { if (Economy.CostBear != 0uL) { num2 = Economy.CostBear; } Economy.Get(client2.userID).AnimalsKilled++; } else if (text.Equals("Mutant Wolf", StringComparison.OrdinalIgnoreCase)) { if (Economy.CostMutantWolf != 0uL) { num2 = Economy.CostMutantWolf; } Economy.Get(client2.userID).MutantsKilled++; } else if (text.Equals("Mutant Bear", StringComparison.OrdinalIgnoreCase)) { if (Economy.CostMutantBear != 0uL) { num2 = Economy.CostMutantBear; } Economy.Get(client2.userID).MutantsKilled++; } else { ConsoleSystem.LogWarning("[WARNING] Economy: Creature '" + text + "' not have cost of death."); } Config.Get("NAMES." + ((userData2 == null) ? Core.Languages[0] : userData2.Language), text, ref text, true); if (num2 > 0uL && Clans.Enabled && clanData != null) { if (clanData.Level.BonusMembersPayMurder > 0u) { num2 += num2 * (ulong)clanData.Level.BonusMembersPayMurder / 100uL; } if (clanData.Tax > 0u) { ulong num5 = num2 * (ulong)clanData.Tax / 100uL; clanData.Balance += num5; num2 -= num5; } } if (num2 > 0uL) { Economy.BalanceAdd(client2.userID, num2); } } if (client2 != null && num2 > 0uL) { string text3 = Config.GetMessage("Economy.PlayerDeath.Pay", client2.netUser, null); if (flag) { text3 = Config.GetMessage("Economy.SleeperDeath.Pay", client2.netUser, null); } text3 = text3.Replace("%DEATHPAY%", num2.ToString("N0") + Economy.CurrencySign); text3 = text3.Replace("%VICTIM%", text); Broadcast.Message(client2.netPlayer, text3, null, 0f); } if (client != null && num > 0uL) { string text4 = Config.GetMessage("Economy.PlayerDeath.Fee", client.netUser, null); if (client2 == client || flag2) { text4 = Config.GetMessage("Economy.PlayerSuicide.Fee", client.netUser, null); } text4 = text4.Replace("%DEATHFEE%", num.ToString("N0") + Economy.CurrencySign); text4 = text4.Replace("%KILLER%", text2); text4 = text4.Replace("%VICTIM%", text); Broadcast.Message(client.netPlayer, text4, null, 0f); } } }
public void IN_OnNetworkMessage(Message packet) { // if (packet.type != Message.Type.Entities && packet.type != Message.Type.Tick && // packet.type != Message.Type.EAC // && packet.type != Message.Type.EntityPosition && packet.type != Message.Type.GroupEnter && // packet.type != Message.Type.GroupDestroy && packet.type != Message.Type.GroupLeave) // { // // if (packet.type == Message.Type.RPCMessage) // { // UInt32 UID = packet.read.EntityID(); // UInt32 rpcId = packet.read.UInt32(); // packet.read.UInt64(); // ConsoleSystem.Log($"IN RPC => {pooledStrings[rpcId]} - {rpcId}"); // }else if (packet.type == Message.Type.ConsoleCommand) // { //// ConsoleSystem.Log($"IN COMMAND => {packet.read.String()}"); // }else // ConsoleSystem.Log($"IN => {packet.type}"); // } switch (packet.type) { case Message.Type.Approved: OnApproved(packet); break; case Message.Type.RequestUserInformation: ConnectionInformation = new UserInformation { Branch = "", ConnectionProtocol = 2155, Os = "editor", PacketProtocol = 228, SteamId = _steamId, Username = _username, SteamToken = _token }; if (BaseClient.write.Start()) { BaseClient.write.PacketId(Message.Type.GiveUserInformation); ConnectionInformation.Write(BaseClient); BaseClient.Send(); } break; case Message.Type.ConsoleCommand: string command = packet.read.String(); if (command == "sfk.gosleep") { BaseClient.Disconnect("", true); ConsoleSystem.Log("[GOSLEEP]"); Framework.Quit(); } break; case Message.Type.DisconnectReason: packet.read.Position = 1L; var reasone = packet.read.String(); ConsoleSystem.LogWarning("[VirtualServer]: От игрового сервера получена причина дисконнекта: " + reasone); break; } }
public static void HurtKilled(DamageEvent damage) { ulong amount = 0L; string key = ""; ulong costChicken = 0L; string displayName = ""; PlayerClient client = damage.victim.client; PlayerClient client2 = damage.attacker.client; bool flag = !(damage.victim.idMain is Character); bool flag2 = !(damage.attacker.idMain is Character); UserData data = (client != null) ? Users.GetBySteamID(client.userID) : null; UserData data2 = (client2 != null) ? Users.GetBySteamID(client2.userID) : null; if (data == null) { } ClanData data3 = (data2 != null) ? data2.Clan : null; if (!flag2 || (client2 != null)) { if (client2 != null) { displayName = damage.attacker.client.netUser.displayName; } else { displayName = Helper.NiceName(damage.attacker.character.name); Config.Get("NAMES." + ((data == null) ? Core.Languages[0] : data.Language), displayName, ref displayName, true); } if (flag) { if (!(damage.victim.idMain is SleepingAvatar) || !FeeSleeper) { return; } SleepingAvatar idMain = damage.victim.idMain as SleepingAvatar; if (idMain == null) { return; } UserData bySteamID = Users.GetBySteamID(idMain.ownerID); if (bySteamID == null) { return; } ulong balance = GetBalance(bySteamID.SteamID); key = bySteamID.Username; if (FeeMurder) { amount = (ulong)Math.Abs((float)((balance * FeeMurderPercent) / 100f)); } if (PayMurder) { costChicken = (ulong)Math.Abs((float)((balance * PayMurderPercent) / 100f)); } if (((costChicken > 0L) && Clans.Enabled) && (data3 != null)) { if (data3.Level.BonusMembersPayMurder > 0) { costChicken += (costChicken * data3.Level.BonusMembersPayMurder) / ((ulong)100L); } if (data3.Tax > 0) { ulong num4 = (costChicken * data3.Tax) / ((ulong)100L); data3.Balance += num4; costChicken -= num4; } } if (costChicken > 0L) { BalanceAdd(client2.userID, costChicken); } if (amount > 0L) { BalanceSub(bySteamID.SteamID, amount); } } else if (client != null) { key = damage.victim.client.netUser.displayName; ulong num5 = GetBalance(client.userID); if (client2 == null) { if (FeeDeath) { amount = (ulong)Math.Abs((float)((num5 * FeeDeathPercent) / 100f)); } } else if ((client2 != client) && !flag2) { if ((client2 != client) && !flag2) { UserEconomy economy1 = Get(client2.userID); economy1.PlayersKilled++; if (FeeMurder) { amount = (ulong)Math.Abs((float)((num5 * FeeMurderPercent) / 100f)); } if (PayMurder) { costChicken = (ulong)Math.Abs((float)((num5 * PayMurderPercent) / 100f)); } } } else if (FeeSuicide) { amount = (ulong)Math.Abs((float)((num5 * FeeSuicidePercent) / 100f)); } if (((costChicken > 0L) && Clans.Enabled) && (data3 != null)) { if (data3.Level.BonusMembersPayMurder > 0) { costChicken += (costChicken * data3.Level.BonusMembersPayMurder) / ((ulong)100L); } if (data3.Tax > 0) { ulong num6 = (costChicken * data3.Tax) / ((ulong)100L); data3.Balance += num6; costChicken -= num6; } } if (costChicken > 0L) { BalanceAdd(client2.userID, costChicken); } if (amount > 0L) { BalanceSub(client.userID, amount); } UserEconomy economy2 = Get(client.userID); economy2.Deaths++; } else if (client2 != null) { key = Helper.NiceName(damage.victim.character.name); if (key.Equals("Chicken", StringComparison.OrdinalIgnoreCase)) { if (CostChicken != 0L) { costChicken = CostChicken; } UserEconomy economy3 = Get(client2.userID); economy3.AnimalsKilled++; } else if (key.Equals("Rabbit", StringComparison.OrdinalIgnoreCase)) { if (CostRabbit != 0L) { costChicken = CostRabbit; } UserEconomy economy4 = Get(client2.userID); economy4.AnimalsKilled++; } else if (key.Equals("Boar", StringComparison.OrdinalIgnoreCase)) { if (CostBoar != 0L) { costChicken = CostBoar; } UserEconomy economy5 = Get(client2.userID); economy5.AnimalsKilled++; } else if (key.Equals("Stag", StringComparison.OrdinalIgnoreCase)) { if (CostStag != 0L) { costChicken = CostStag; } UserEconomy economy6 = Get(client2.userID); economy6.AnimalsKilled++; } else if (key.Equals("Wolf", StringComparison.OrdinalIgnoreCase)) { if (CostWolf != 0L) { costChicken = CostWolf; } UserEconomy economy7 = Get(client2.userID); economy7.AnimalsKilled++; } else if (key.Equals("Bear", StringComparison.OrdinalIgnoreCase)) { if (CostBear != 0L) { costChicken = CostBear; } UserEconomy economy8 = Get(client2.userID); economy8.AnimalsKilled++; } else if (key.Equals("Mutant Wolf", StringComparison.OrdinalIgnoreCase)) { if (CostMutantWolf != 0L) { costChicken = CostMutantWolf; } UserEconomy economy9 = Get(client2.userID); economy9.MutantsKilled++; } else if (key.Equals("Mutant Bear", StringComparison.OrdinalIgnoreCase)) { if (CostMutantBear != 0L) { costChicken = CostMutantBear; } UserEconomy economy10 = Get(client2.userID); economy10.MutantsKilled++; } else { ConsoleSystem.LogWarning("[WARNING] Economy: Creature '" + key + "' not have cost of death."); } Config.Get("NAMES." + ((data2 == null) ? Core.Languages[0] : data2.Language), key, ref key, true); if (((costChicken > 0L) && Clans.Enabled) && (data3 != null)) { if (data3.Level.BonusMembersPayMurder > 0) { costChicken += (costChicken * data3.Level.BonusMembersPayMurder) / ((ulong)100L); } if (data3.Tax > 0) { ulong num7 = (costChicken * data3.Tax) / ((ulong)100L); data3.Balance += num7; costChicken -= num7; } } if (costChicken > 0L) { BalanceAdd(client2.userID, costChicken); } } if ((client2 != null) && (costChicken > 0L)) { string text = Config.GetMessage("Economy.PlayerDeath.Pay", client2.netUser, null); if (flag) { text = Config.GetMessage("Economy.SleeperDeath.Pay", client2.netUser, null); } text = text.Replace("%DEATHPAY%", costChicken.ToString("N0") + CurrencySign).Replace("%VICTIM%", key); Broadcast.Message(client2.netPlayer, text, null, 0f); } if ((client != null) && (amount > 0L)) { string str4; str4 = str4 = Config.GetMessage("Economy.PlayerDeath.Fee", client.netUser, null); if ((client2 == client) || flag2) { str4 = Config.GetMessage("Economy.PlayerSuicide.Fee", client.netUser, null); } str4 = str4.Replace("%DEATHFEE%", amount.ToString("N0") + CurrencySign).Replace("%KILLER%", displayName).Replace("%VICTIM%", key); Broadcast.Message(client.netPlayer, str4, null, 0f); } } }
internal bool HandleRaknetPacket(byte type) { if (type >= 140) { return(false); } OnRakNetPacket?.Invoke(type); switch (type) { case 16: base.ConnectionAccepted = true; if (base.Connection.guid != 0uL) { Console.WriteLine("Multiple PacketType.CONNECTION_REQUEST_ACCEPTED"); } base.Connection.guid = this.peer.incomingGUID; return(true); case 17: this.Disconnect("Connection Attempt Failed", false); return(true); case 20: this.Disconnect("Server is Full", false); return(true); case 21: if (base.Connection != null && base.Connection.guid != this.peer.incomingGUID) { return(true); } this.Disconnect(Client.disconnectReason, false); return(true); case 22: if (base.Connection == null && base.Connection.guid != this.peer.incomingGUID) { return(true); } this.Disconnect("Timed Out", false); return(true); case 23: if (base.Connection == null && base.Connection.guid != this.peer.incomingGUID) { return(true); } this.Disconnect("Connection Banned", false); return(true); } if (base.Connection != null && this.peer.incomingGUID != base.Connection.guid) { ConsoleSystem.LogWarning(string.Concat(new object[] { "[CLIENT] Unhandled Raknet packet ", type, " from unknown source ", this.peer.incomingAddress })); return(true); } ConsoleSystem.LogWarning("Unhandled Raknet packet " + type); return(true); }