public void Kick(string reason, bool announce = true) { if (kicking) { return; } state = SlotState.KICK; if (announce) { if (assignedSlot >= 0) { ProgramLog.Log("{0} @ {1}: disconnecting for: {2}", RemoteAddress, assignedSlot, reason); var player = Main.player[assignedSlot]; if (player != null) { player.DisconnectReason = reason; } } else { ProgramLog.Log("{0}: disconnecting for: {1}", RemoteAddress, reason); } } if (!kicking) { var msg = NewNetMessage.PrepareThreadInstance(); msg.Disconnect(reason); KickAfter(msg.Output); } }
public override void Process(ClientConnection conn, byte[] readBuffer, int length, int num) { if (conn.State == SlotState.ACCEPTED) { SlotManager.Schedule(conn, conn.DesiredQueue); return; } int whoAmI = conn.SlotIndex; if (Terraria.Netplay.Clients[whoAmI].State() == SlotState.ASSIGNING_SLOT) { Terraria.Netplay.Clients[whoAmI].SetState(SlotState.SENDING_WORLD); } var ctx = new HookContext() { Connection = conn, Player = conn.Player }; var args = new HookArgs.WorldRequestMessage() { SpawnX = Main.spawnTileX, SpawnY = Main.spawnTileY }; HookPoints.WorldRequestMessage.Invoke(ref ctx, ref args); //NewNetMessage.SendData(7, whoAmI); var msg = NewNetMessage.PrepareThreadInstance(); msg.WorldData(args.SpawnX, args.SpawnY); msg.Send(whoAmI); }
public override void Process(int whoAmI, byte[] readBuffer, int length, int num) { int playerIndex = (int)ReadByte(readBuffer); if (playerIndex != whoAmI && Entry.EnableCheatProtection) { Terraria.Netplay.Clients[whoAmI].Kick("Cheating detected (PLAYER_HEALTH_UPDATE forgery)."); return; } if (playerIndex == Main.myPlayer && !Main.ServerSideCharacter) { return; } //if (Main.netMode == 2) //{ // playerIndex = whoAmI; //} var plr = Main.player[playerIndex]; plr.statLife = (int)ReadInt16(readBuffer); plr.statLifeMax = (int)ReadInt16(readBuffer); if (plr.statLifeMax < 100) { plr.statLifeMax = 100; } plr.dead = (plr.statLife <= 0); NewNetMessage.SendData((int)Packet.PLAYER_HEALTH_UPDATE, -1, whoAmI, String.Empty, playerIndex, 0f, 0f, 0f, 0); }
public override void Process(int whoAmI, byte[] readBuffer, int length, int num) { int num137 = (int)ReadInt16(readBuffer); int num138 = (int)ReadInt16(readBuffer); int num139 = (int)ReadInt16(readBuffer); byte b10 = ReadByte(readBuffer); if (num137 >= 200 && Entry.EnableCheatProtection) { NewNetMessage.BootPlayer(whoAmI, "Cheating attempt detected: Invalid kick-out"); return; } if (Main.netMode == 1) { Main.npc[num137].homeless = (b10 == 1); Main.npc[num137].homeTileX = num138; Main.npc[num137].homeTileY = num139; return; } if (b10 == 0) { WorldGen.kickOut(num137); return; } WorldGen.moveRoom(num138, num139, num137); return; }
public override void Process(int whoAmI, byte[] readBuffer, int length, int num) { int playerIndex = (int)ReadByte(readBuffer); if (playerIndex != whoAmI && Entry.EnableCheatProtection) { Terraria.Netplay.Clients[whoAmI].Kick("Cheating detected (PLAYER_MANA_UPDATE forgery)."); return; } playerIndex = whoAmI; int statMana = (int)ReadInt16(readBuffer); int statManaMax = (int)ReadInt16(readBuffer); Main.player[playerIndex].statMana = statMana; Main.player[playerIndex].statManaMax = statManaMax; //if (Main.player[playerIndex].HasHackedData()) //{ // Main.player[playerIndex].Kick("No Hacked Mana is allowed."); //} NewNetMessage.SendData((int)Packet.PLAYER_MANA_UPDATE, -1, whoAmI, String.Empty, playerIndex); }
public static int Schedule(ClientConnection conn, int priority) { int id; lock (syncRoot) { if (priority > 2 || priority < 0) { // bypass queue id = AssignSlotOrQueue(conn, 3); } else { id = AssignSlotOrQueue(conn, priority); } } // we send here, so as to prevent a deadlock between our lock // and the connection's sendqueue lock if (id == -1) { var msg = NewNetMessage.PrepareThreadInstance(); msg.SendTileLoading(1, WaitingMessage(conn)); conn.Send(msg.Output); } else if (id >= 0) { var msg = NewNetMessage.PrepareThreadInstance(); msg.ConnectionResponse(id); conn.Send(msg.Output); } return(id); }
public static void CheckSection(int who, Vector2 position, int fluff = 1) { int sectionX = Netplay.GetSectionX((int)(position.X / 16f)); int sectionY = Netplay.GetSectionY((int)(position.Y / 16f)); int num = 0; for (int i = sectionX - 1; i < sectionX + 2; i++) { for (int j = sectionY - 1; j < sectionY + 2; j++) { if (i >= 0 && i < Main.maxSectionsX && j >= 0 && j < Main.maxSectionsY && !Terraria.Netplay.Clients[who].TileSections[i, j]) { num++; } } } if (num > 0) { int num2 = num; NewNetMessage.SendData(9, who, -1, Lang.inter[44], num2, 0f, 0f, 0f, 0); Terraria.Netplay.Clients[who].StatusText2 = "is receiving tile data"; Terraria.Netplay.Clients[who].StatusMax += num2; for (int k = sectionX - 1; k < sectionX + 2; k++) { for (int l = sectionY - 1; l < sectionY + 2; l++) { if (k >= 0 && k < Main.maxSectionsX && l >= 0 && l < Main.maxSectionsY && !Terraria.Netplay.Clients[who].TileSections[k, l]) { NewNetMessage.SendSection(who, k, l, false); NewNetMessage.SendData(11, who, -1, String.Empty, k, (float)l, (float)k, (float)l, 0); } } } } }
public override void Process(int whoAmI, byte[] readBuffer, int length, int num) { int num51 = (int)ReadInt16(readBuffer); int num52 = (int)ReadByte(readBuffer); if (Main.item[num51].owner != whoAmI) { return; } Main.item[num51].owner = num52; if (num52 == Main.myPlayer) { Main.item[num51].keepTime = 15; } else { Main.item[num51].keepTime = 0; } if (Main.netMode == 2) { Main.item[num51].owner = 255; Main.item[num51].keepTime = 15; NewNetMessage.SendData(22, -1, -1, String.Empty, num51, 0f, 0f, 0f, 0); return; } return; }
public override void Process(int whoAmI, byte[] readBuffer, int length, int num) { int num75 = (int)ReadInt16(readBuffer); int num76 = (int)ReadInt16(readBuffer); float num77 = ReadSingle(readBuffer); int num78 = (int)(ReadByte(readBuffer) - 1); byte b5 = ReadByte(readBuffer); if (num76 >= 0) { Main.npc[num75].StrikeNPC(num76, num77, num78, b5 == 1, false); } else { Main.npc[num75].life = 0; Main.npc[num75].HitEffect(0, 10.0); Main.npc[num75].active = false; } NewNetMessage.SendData(28, -1, whoAmI, String.Empty, num75, (float)num76, num77, (float)num78, (int)b5); if (Main.npc[num75].life <= 0) { NewNetMessage.SendData(23, -1, -1, String.Empty, num75, 0f, 0f, 0f, 0); return; } Main.npc[num75].netUpdate = true; }
public override void Process(int whoAmI, byte[] readBuffer, int length, int num) { int playerIndex = ReadByte(readBuffer); if (playerIndex != whoAmI && Entry.EnableCheatProtection) { Terraria.Netplay.Clients[whoAmI].Kick("Cheating detected (PLAYER_BUFFS forgery)."); return; } playerIndex = whoAmI; if (playerIndex == Main.myPlayer) { return; } var player = Main.player[playerIndex]; for (int i = 0; i < 10; i++) { player.buffType[i] = (int)ReadByte(readBuffer); if (player.buffType[i] > 0) { player.buffTime[i] = 60; } else { player.buffTime[i] = 0; } } NewNetMessage.SendData((int)Packet.PLAYER_BUFFS, -1, whoAmI, String.Empty, playerIndex); }
public override void Process(int whoAmI, byte[] readBuffer, int length, int num) { int playerIndex = (int)ReadByte(readBuffer); if (playerIndex != whoAmI && Entry.EnableCheatProtection) { Terraria.Netplay.Clients[whoAmI].Kick("Cheating detected (ENTER_ZONE forgery)."); return; } playerIndex = whoAmI; Player player9 = Main.player[playerIndex]; //Todo refactor BitsByte bitsByte11 = ReadByte(readBuffer); player9.zonw = bitsByte11[0]; player9.zoneMeteor = bitsByte11[1]; player9.zoneDungeon = bitsByte11[2]; player9.zoneJungle = bitsByte11[3]; player9.zoneHoly = bitsByte11[4]; player9.zoneSnow = bitsByte11[5]; player9.zoneBlood = bitsByte11[6]; player9.zoneCandle = bitsByte11[7]; NewNetMessage.SendData(36, -1, whoAmI, String.Empty, playerIndex, 0f, 0f, 0f, 0); }
public override void Process(int whoAmI, byte[] readBuffer, int length, int num) { byte playerId = ReadByte(readBuffer); if (playerId != whoAmI && Entry.EnableCheatProtection) { Terraria.Netplay.Clients[whoAmI].Kick("Cheating detected (CHEST_UNLOCK forgery)."); return; } byte action = ReadByte(readBuffer); var x = (int)ReadInt16(readBuffer); var y = (int)ReadInt16(readBuffer); if (action == 1) { Chest.Unlock(x, y); NewNetMessage.SendData(52, -1, whoAmI, String.Empty, playerId, action, x, y, 0); NewNetMessage.SendTileSquare(-1, x, y, 2); } else if (action == 2) { WorldGen.UnlockDoor(x, y); NewNetMessage.SendData(52, -1, whoAmI, String.Empty, playerId, action, x, y, 0); NewNetMessage.SendTileSquare(-1, x, y, 2); } }
public override void Process(int whoAmI, byte[] readBuffer, int length, int num) { int num48 = (int)ReadInt16(readBuffer); var position = ReadVector2(readBuffer); var velocity = ReadVector2(readBuffer); int stack2 = (int)ReadInt16(readBuffer); int pre = (int)ReadByte(readBuffer); int num49 = (int)ReadByte(readBuffer); int num50 = (int)ReadInt16(readBuffer); { if (num50 == 0) { if (num48 < 400) { Main.item[num48].active = false; NewNetMessage.SendData(21, -1, -1, String.Empty, num48, 0f, 0f, 0f, 0); return; } return; } else { bool flag7 = false; if (num48 == 400) { flag7 = true; } if (flag7) { Item item2 = new Item(); item2.netDefaults(num50); num48 = Item.NewItem((int)position.X, (int)position.Y, item2.width, item2.height, item2.type, stack2, true, 0, false); } Item item3 = Main.item[num48]; item3.netDefaults(num50); item3.Prefix(pre); item3.stack = stack2; item3.position = position; item3.velocity = velocity; item3.active = true; item3.owner = Main.myPlayer; if (flag7) { NewNetMessage.SendData(21, -1, -1, String.Empty, num48, 0f, 0f, 0f, 0); if (num49 == 0) { Main.item[num48].ownIgnore = whoAmI; Main.item[num48].ownTime = 100; } Main.item[num48].FindOwner(num48); return; } NewNetMessage.SendData(21, -1, whoAmI, String.Empty, num48, 0f, 0f, 0f, 0); return; } } }
protected void FreeSectionBuffer() { if (sectionBuffer != null) { var buf = sectionBuffer; sectionBuffer = null; FreeSectionBuffer(buf); } }
public void Send(Player player) { #if TDSMServer var msg = NewNetMessage.PrepareThreadInstance(); msg.PlayerData(player.whoAmI); msg.BuildPlayerUpdate(player.whoAmI); msg.Broadcast(); #endif }
public override void Process(int whoAmI, byte[] readBuffer, int length, int num) { int x = ReadInt16(readBuffer); int y = ReadInt16(readBuffer); var player = Main.player[whoAmI]; if (Math.Abs(player.position.X / 16 - x) >= 7 || Math.Abs(player.position.Y / 16 - y) >= 7) { return; } int chestIndex = Chest.FindChest(x, y); var ctx = new HookContext { Connection = player.Connection, Player = player, Sender = player, }; var args = new HookArgs.ChestOpenReceived { X = x, Y = y, ChestIndex = chestIndex, }; HookPoints.ChestOpenReceived.Invoke(ref ctx, ref args); if (ctx.CheckForKick()) { return; } if (ctx.Result == HookResult.IGNORE) { return; } if (ctx.Result == HookResult.DEFAULT && chestIndex > -1) { var user = Chest.UsingChest(chestIndex); if (user >= 0 && user != whoAmI) { return; } for (int i = 0; i < Chest.maxItems; i++) { NewNetMessage.SendData(32, whoAmI, -1, String.Empty, chestIndex, (float)i); } NewNetMessage.SendData(33, whoAmI, -1, String.Empty, chestIndex); Main.player[whoAmI].chest = chestIndex; return; } }
public override void Process(int whoAmI, byte[] readBuffer, int length, int num) { var npcId = ReadInt16(readBuffer); var type = ReadByte(readBuffer); var time = ReadInt16(readBuffer); Main.npc[npcId].AddBuff(type, time, true); NewNetMessage.SendData(54, -1, -1, String.Empty, npcId); }
public override void Process(int whoAmI, byte[] readBuffer, int length, int num) { ReadByte(readBuffer); int playerIndex = whoAmI; int talkNPC = (int)ReadInt16(readBuffer); Main.player[playerIndex].talkNPC = talkNPC; NewNetMessage.SendData(40, -1, whoAmI, String.Empty, playerIndex); }
public override void Process(int whoAmI, byte[] readBuffer, int length, int num) { int start = num - 1; int playerIndex = ReadByte(readBuffer); if (playerIndex != whoAmI && Entry.EnableCheatProtection) { Terraria.Netplay.Clients[whoAmI].Kick("Cheating detected (KILL_PLAYER forgery)."); return; } var player = Main.player[whoAmI]; var ctx = new HookContext { Connection = (Terraria.Netplay.Clients[whoAmI] as ServerSlot).conn, Sender = player, Player = player, }; var args = new HookArgs.ObituaryReceived { Direction = (int)ReadByte(readBuffer) - 1, Damage = ReadInt16(readBuffer), PvpFlag = ReadByte(readBuffer) }; //string obituary; //if (!ParseString(readBuffer, num + 1, length - num - 1 + start, out obituary)) //{ // tdsm.api.Callbacks.Netplay.slots[whoAmI].Kick("Invalid characters in obituary message."); // return; //} args.Obituary = " " + ReadString(readBuffer); HookPoints.ObituaryReceived.Invoke(ref ctx, ref args); if (ctx.CheckForKick()) { return; } if (ctx.Result == HookResult.IGNORE) { return; } ProgramLog.Log("{0} @ {1}: [Death] {2}{3}", player.IPAddress, whoAmI, player.Name ?? "<null>", args.Obituary); player.KillMe(args.Damage, args.Direction, args.PvpFlag == 1, args.Obituary); NewNetMessage.SendData(44, -1, whoAmI, args.Obituary, whoAmI, args.Direction, args.Damage, args.PvpFlag); }
public override void Process(int whoAmI, byte[] readBuffer, int length, int num) { var chestId = (int)ReadInt16(readBuffer); var x = (int)ReadInt16(readBuffer); var y = (int)ReadInt16(readBuffer); if (Main.netMode == 1) { if (chestId < 0 || chestId >= 1000) { return; } var chest = Main.chest[chestId]; if (chest == null) { chest = new Chest(false); chest.x = x; chest.y = y; Main.chest[chestId] = chest; } else if (chest.x != x || chest.y != y) { return; } chest.name = ReadString(readBuffer); } else { if (chestId < -1 || chestId >= 1000) { return; } if (chestId == -1) { chestId = Chest.FindChest(x, y); if (chestId == -1) { return; } } var chest = Main.chest[chestId]; if (chest.x != x || chest.y != y) { return; } NewNetMessage.SendData(Packet.CHEST_NAME_UPDATE, whoAmI, -1, chest.name, chestId, (float)x, (float)y, 0f, 0); } }
public override void Process(int whoAmI, byte[] readBuffer, int length, int num) { int x = (int)ReadInt16(readBuffer); int y = (int)ReadInt16(readBuffer); Wiring.HitSwitch(x, y); if (Main.netMode == 2) { NewNetMessage.SendData(59, -1, whoAmI, String.Empty, x, (float)y, 0f, 0f, 0); return; } return; }
public override void Process(int whoAmI, byte[] readBuffer, int length, int num) { int num144 = (int)ReadInt16(readBuffer); int num145 = (int)ReadInt16(readBuffer); byte b11 = ReadByte(readBuffer); WorldGen.paintTile(num144, num145, b11, false); if (Main.netMode == 2) { NewNetMessage.SendData(63, -1, whoAmI, "", num144, (float)num145, (float)b11, 0f, 0); return; } return; }
public override void Process(int whoAmI, byte[] readBuffer, int length, int num) { int num146 = (int)ReadInt16(readBuffer); int num147 = (int)ReadInt16(readBuffer); byte b12 = ReadByte(readBuffer); WorldGen.paintWall(num146, num147, b12, false); if (Main.netMode == 2) { NewNetMessage.SendData(64, -1, whoAmI, "", num146, (float)num147, (float)b12, 0f, 0); return; } return; }
public override void Process(int whoAmI, byte[] readBuffer, int length, int num) { int playerIndex = ReadByte(readBuffer); if (playerIndex != whoAmI && Entry.EnableCheatProtection) { Terraria.Netplay.Clients[whoAmI].Kick("Cheating detected (PLAYER_PVP_CHANGE forgery)."); return; } var pvp = ReadByte(readBuffer) == 1; var player = Main.player[whoAmI]; var ctx = new HookContext { Connection = player.Connection, Player = player, Sender = player, }; var args = new HookArgs.PvpSettingReceived { PvpFlag = pvp, }; HookPoints.PvpSettingReceived.Invoke(ref ctx, ref args); if (ctx.CheckForKick()) { return; } if (ctx.Result == HookResult.IGNORE) { return; } if (ctx.Result == HookResult.RECTIFY) { NewNetMessage.SendData(30, whoAmI, -1, String.Empty, whoAmI); return; } player.hostile = pvp; string message = (player.hostile) ? " has enabled PvP!" : " has disabled PvP!"; NewNetMessage.SendData(30, -1, whoAmI, String.Empty, whoAmI); NewNetMessage.SendData(25, -1, -1, player.Name + message, 255, (float)Main.teamColor[player.team].R, (float)Main.teamColor[player.team].G, (float)Main.teamColor[player.team].B); }
public new void SpamUpdate() { if (!Netplay.spamCheck) { this.SpamProjectile = 0f; this.SpamDeleteBlock = 0f; this.SpamAddBlock = 0f; this.SpamWater = 0f; return; } if (this.SpamProjectile > this.SpamProjectileMax && Entry.EnableCheatProtection) { NewNetMessage.BootPlayer(this.Id, "Cheating attempt detected: Projectile spam"); } if (this.SpamAddBlock > this.SpamAddBlockMax && Entry.EnableCheatProtection) { NewNetMessage.BootPlayer(this.Id, "Cheating attempt detected: Add tile spam"); } if (this.SpamDeleteBlock > this.SpamDeleteBlockMax && Entry.EnableCheatProtection) { NewNetMessage.BootPlayer(this.Id, "Cheating attempt detected: Remove tile spam"); } if (this.SpamWater > this.SpamWaterMax && Entry.EnableCheatProtection) { NewNetMessage.BootPlayer(this.Id, "Cheating attempt detected: Liquid spam"); } this.SpamProjectile -= 0.4f; if (this.SpamProjectile < 0f) { this.SpamProjectile = 0f; } this.SpamAddBlock -= 0.3f; if (this.SpamAddBlock < 0f) { this.SpamAddBlock = 0f; } this.SpamDeleteBlock -= 5f; if (this.SpamDeleteBlock < 0f) { this.SpamDeleteBlock = 0f; } this.SpamWater -= 0.2f; if (this.SpamWater < 0f) { this.SpamWater = 0f; } }
public override void Process(int whoAmI, byte[] readBuffer, int length, int num) { int playerIndex = (int)ReadByte(readBuffer); if (playerIndex != whoAmI && Entry.EnableCheatProtection) { Terraria.Netplay.Clients[whoAmI].Kick("Cheating detected (RECEIVING_PLAYER_JOINED forgery)."); return; } playerIndex = whoAmI; num++; Player player = Main.player[playerIndex]; //if (player.SpawnX >= 0 && player.SpawnY >= 0) //{ // player.OldSpawnX = player.SpawnX; // player.OldSpawnY = player.SpawnY; //} player.SpawnX = ReadInt16(readBuffer); player.SpawnY = ReadInt16(readBuffer); player.Spawn(); //ProgramLog.Debug.Log ("sx: {0}, sy: {1}, tx: {2}, ty: {3}", player.SpawnX, player.SpawnY, player.TeleSpawnX, player.TeleSpawnY); player.respawnTimer = Int32.MaxValue; if (Terraria.Netplay.Clients[whoAmI].State() >= SlotState.SENDING_TILES) { if (Terraria.Netplay.Clients[whoAmI].State() == SlotState.SENDING_TILES) { Terraria.Netplay.Clients[whoAmI].SetState(SlotState.PLAYING); NewNetMessage.OnPlayerJoined(whoAmI); // this also forwards the message } else { NewNetMessage.SendData(12, -1, whoAmI, String.Empty, whoAmI, 0f, 0f, 0f, 0); } NewNetMessage.SendData(74, whoAmI, -1, Main.player[whoAmI].name, Main.anglerQuest, 0f, 0f, 0f, 0); } Server.AddUniqueConnection(player.Name, player.IPAddress.Split(':')[0]); }
public override void Process(int whoAmI, byte[] readBuffer, int length, int num) { byte doorAction = ReadByte(readBuffer); int x = (int)ReadInt16(readBuffer); int y = (int)ReadInt16(readBuffer); int doorDirection = (ReadByte(readBuffer) == 0) ? -1 : 1; if (doorAction == 0) { WorldGen.OpenDoor(x, y, doorDirection); } else if (doorAction == 1) { WorldGen.CloseDoor(x, y, true); } NewNetMessage.SendData(19, -1, whoAmI, String.Empty, (int)doorAction, (float)x, (float)y, (float)((doorDirection == 1) ? 1 : 0), 0); }
public override void Process(int whoAmI, byte[] readBuffer, int length, int num) { int playerId = ReadByte(readBuffer); byte action = ReadByte(readBuffer); if (playerId != whoAmI && Entry.EnableCheatProtection) { Terraria.Netplay.Clients[whoAmI].Kick("SummonSkeletron Player Forgery."); return; } if (action == 1) { var player = Main.player[whoAmI]; var ctx = new HookContext { Connection = player.Connection, Sender = player, Player = player, }; var args = new HookArgs.PlayerTriggeredEvent { Type = WorldEventType.BOSS, Name = "Skeletron", }; HookPoints.PlayerTriggeredEvent.Invoke(ref ctx, ref args); if (ctx.CheckForKick() || ctx.Result == HookResult.IGNORE) { return; } //ProgramLog.Users.Log ("{0} @ {1}: Skeletron summoned by {2}.", player.IPAddress, whoAmI, player.Name); //NewNetMessage.SendData (Packet.PLAYER_CHAT, -1, -1, string.Concat (player.Name, " has summoned Skeletron!"), 255, 255, 128, 150); NPC.SpawnSkeletron(); } else if (action == 2) { NewNetMessage.SendData(51, -1, whoAmI, String.Empty, playerId, action, 0f, 0f, 0); } }
public override void Process(int whoAmI, byte[] readBuffer, int length, int num) { int num59 = (int)ReadInt16(readBuffer); int num60 = (int)ReadByte(readBuffer); if (Main.netMode == 2) { num60 = whoAmI; } Player player7 = Main.player[num60]; Main.npc[num59].StrikeNPC(player7.inventory[player7.selectedItem].damage, player7.inventory[player7.selectedItem].knockBack, player7.direction, false, false); if (Main.netMode == 2) { NewNetMessage.SendData(24, -1, whoAmI, String.Empty, num59, (float)num60, 0f, 0f, 0); NewNetMessage.SendData(23, -1, -1, String.Empty, num59, 0f, 0f, 0f, 0); return; } }
/// <summary> /// Kicks a given Player from the server /// </summary> /// <param name="sender">Sending player</param> /// <param name="args">Arguments sent with command</param> public void Kick(ISender sender, ArgumentList args) { if (args.TryPop("-s")) { int s; args.ParseOne(out s); var slot = Terraria.Netplay.Clients[s]; #if TDSMServer if (slot.State() != SlotState.VACANT) { slot.Kick("You have been kicked by " + sender.SenderName + "."); var player = Main.player[s]; if (player != null && player.name != null) { NewNetMessage.SendData(25, -1, -1, player.name + " has been kicked by " + sender.SenderName + ".", 255); } } else { sender.Message("Kick slot is empty"); } #else NetMessage.SendData(2, slot.Id, -1, "Kicked from server.", 0, 0f, 0f, 0f, 0, 0, 0); #endif } else { Player player; args.ParseOne <Player>(out player); if (player.name == null) { sender.Message("Kick player name is not set."); return; } player.Kick("You have been kicked by " + sender.SenderName + "."); NetMessage.SendData(25, -1, -1, player.name + " has been kicked by " + sender.SenderName + ".", 255); } }