Added MaxSlots (Kicks player if full)
This commit is contained in:
parent
1429595c5b
commit
73f17b0260
4 changed files with 835 additions and 824 deletions
|
|
@ -3,8 +3,8 @@ using System.Collections.Generic;
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Terraria;
|
||||
using System.Text.RegularExpressions;
|
||||
using Terraria;
|
||||
|
||||
namespace TShockAPI
|
||||
{
|
||||
|
|
@ -112,7 +112,6 @@ namespace TShockAPI
|
|||
commands.Add(new Command("item", "cheat", new CommandDelegate(Item)));
|
||||
commands.Add(new Command("give", "cheat", new CommandDelegate(Give)));
|
||||
commands.Add(new Command("heal", "cheat", new CommandDelegate(Heal)));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -262,6 +261,7 @@ namespace TShockAPI
|
|||
Tools.NewNPC((int)ConfigurationManager.NPCList.EYE, x, y, ply);
|
||||
Tools.Broadcast(Tools.FindPlayer(ply) + " has spawned an eye!");
|
||||
}
|
||||
|
||||
public static void Skeletron(CommandArgs args)
|
||||
{
|
||||
int x = args.PlayerX;
|
||||
|
|
@ -648,7 +648,7 @@ namespace TShockAPI
|
|||
Tools.SendMessage(args.PlayerID, "Invalid player!", new float[] { 255f, 0f, 0f });
|
||||
else
|
||||
{
|
||||
TShock.SendDataAll(26, -1, "", player, (float)((new Random()).Next(1, 20)), (float)5, (float)0);
|
||||
NetMessage.SendData(26, -1, -1, "", player, (float)((new Random()).Next(1, 20)), (float)5, (float)0);
|
||||
Tools.Broadcast(Tools.FindPlayer(args.PlayerID) + " slapped " + Tools.FindPlayer(player) + " for 5 damage.");
|
||||
}
|
||||
}
|
||||
|
|
@ -661,7 +661,7 @@ namespace TShockAPI
|
|||
Tools.SendMessage(args.PlayerID, "Invalid player!", new float[] { 255f, 0f, 0f });
|
||||
else
|
||||
{
|
||||
TShock.SendDataAll(26, -1, "", player, (float)((new Random()).Next(-1, 1)), (float)damage, (float)0);
|
||||
NetMessage.SendData(26, -1, -1, "", player, (float)((new Random()).Next(-1, 1)), (float)damage, (float)0);
|
||||
Tools.Broadcast(Tools.FindPlayer(args.PlayerID) + " slapped " + Tools.FindPlayer(player) + " for " + damage.ToString() + " damage.");
|
||||
}
|
||||
}
|
||||
|
|
@ -674,6 +674,7 @@ namespace TShockAPI
|
|||
ConfigurationManager.spawnProtect = (ConfigurationManager.spawnProtect == false);
|
||||
Tools.SendMessage(args.PlayerID, "Spawn is now " + (ConfigurationManager.spawnProtect ? "protected" : "open") + ".");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion Command Methods
|
||||
}
|
||||
}
|
||||
|
|
@ -8,6 +8,7 @@ namespace TShockAPI
|
|||
class ConfigFile
|
||||
{
|
||||
public ConfigFile() { }
|
||||
|
||||
public int InvasionMultiplier = 1;
|
||||
public int DefaultMaximumSpawns = 4;
|
||||
public int DefaultSpawnRate = 700;
|
||||
|
|
@ -26,5 +27,6 @@ namespace TShockAPI
|
|||
public bool SpawnProtection = true;
|
||||
public int SpawnProtectionRadius = 5;
|
||||
public string DistributationAgent = "facepunch";
|
||||
public int MaxSlots = 8;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace TShockAPI
|
||||
|
|
@ -33,6 +33,7 @@ namespace TShockAPI
|
|||
public static int spawnProtectRadius = 5;
|
||||
public static string distributationAgent = "facepunch";
|
||||
public static int authToken = 0;
|
||||
public static int maxSlots = 8;
|
||||
|
||||
public enum NPCList : int
|
||||
{
|
||||
|
|
@ -65,6 +66,7 @@ namespace TShockAPI
|
|||
spawnProtect = cfg.SpawnProtection;
|
||||
spawnProtectRadius = cfg.SpawnProtectionRadius;
|
||||
distributationAgent = cfg.DistributationAgent;
|
||||
maxSlots = cfg.MaxSlots;
|
||||
Terraria.NPC.maxSpawns = defaultMaxSpawns;
|
||||
Terraria.NPC.defaultSpawnRate = defaultSpawnRate;
|
||||
}
|
||||
|
|
@ -99,6 +101,7 @@ namespace TShockAPI
|
|||
cfg.KickExplosives = true;
|
||||
cfg.SpawnProtection = true;
|
||||
cfg.SpawnProtectionRadius = 5;
|
||||
cfg.MaxSlots = maxSlots;
|
||||
|
||||
string json = JsonConvert.SerializeObject(cfg, Formatting.Indented);
|
||||
TextWriter tr = new StreamWriter(FileTools.SaveDir + "config.json");
|
||||
|
|
|
|||
|
|
@ -443,6 +443,17 @@ namespace TShockAPI
|
|||
void OnJoin(int ply, AllowEventArgs handler)
|
||||
{
|
||||
if (Main.netMode != 2) { return; }
|
||||
|
||||
int count = 1;
|
||||
for (int i = 0; i < Main.player.Length; i++)
|
||||
count += Main.player[i].active ? 1 : 0;
|
||||
|
||||
if (count > ConfigurationManager.maxSlots)
|
||||
{
|
||||
Tools.Kick(ply, "Server is full");
|
||||
return;
|
||||
}
|
||||
|
||||
string ip = Tools.GetRealIP((Convert.ToString(Netplay.serverSock[ply].tcpClient.Client.RemoteEndPoint)));
|
||||
if (FileTools.CheckBanned(ip))
|
||||
{
|
||||
|
|
@ -674,12 +685,6 @@ namespace TShockAPI
|
|||
NetMessage.SendData(44, i, -1, "", plr, (float)1, (float)9999999, (float)0);
|
||||
}
|
||||
|
||||
public static void SendDataAll(int type, int ignore = -1, string text = "", int num = 0, float f1 = 0f, float f2 = 0f, float f3 = 0f)
|
||||
{
|
||||
for (int i = 0; i < Main.player.Length; i++)
|
||||
NetMessage.SendData(type, i, ignore, text, num, f1, f2, f3);
|
||||
}
|
||||
|
||||
//TODO : Notify the player if there is more than one match. (or do we want a First() kinda thing?)
|
||||
public static int GetNPCID(string name, bool exact = false)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue