/kill - Suicide or if admin, kill other people.
This commit is contained in:
parent
eea8afdcf2
commit
00ce4ff2c4
2 changed files with 64 additions and 19 deletions
|
|
@ -49,7 +49,10 @@ namespace TShockAPI
|
||||||
TShock.admincommandList.Add("maxspawns", new CommandDelegate(MaxSpawns));
|
TShock.admincommandList.Add("maxspawns", new CommandDelegate(MaxSpawns));
|
||||||
TShock.admincommandList.Add("spawnrate", new CommandDelegate(SpawnRate));
|
TShock.admincommandList.Add("spawnrate", new CommandDelegate(SpawnRate));
|
||||||
TShock.admincommandList.Add("time", new CommandDelegate(Time));
|
TShock.admincommandList.Add("time", new CommandDelegate(Time));
|
||||||
|
TShock.admincommandList.Add("kill", new CommandDelegate(Kill));
|
||||||
|
TShock.admincommandList.Add("help", new CommandDelegate(Help));
|
||||||
TShock.commandList.Add("help", new CommandDelegate(Help));
|
TShock.commandList.Add("help", new CommandDelegate(Help));
|
||||||
|
TShock.commandList.Add("kill", new CommandDelegate(Kill));
|
||||||
}
|
}
|
||||||
#region Command Methods
|
#region Command Methods
|
||||||
public static void Kick(CommandArgs args)
|
public static void Kick(CommandArgs args)
|
||||||
|
|
@ -441,6 +444,26 @@ namespace TShockAPI
|
||||||
else
|
else
|
||||||
Tools.SendMessage(args.PlayerID, "Invalid syntax! Proper syntax: /time <day/night>", new float[] { 255f, 0f, 0f });
|
Tools.SendMessage(args.PlayerID, "Invalid syntax! Proper syntax: /time <day/night>", new float[] { 255f, 0f, 0f });
|
||||||
}
|
}
|
||||||
|
public static void Kill(CommandArgs args)
|
||||||
|
{
|
||||||
|
bool isadmin = Tools.IsAdmin(args.PlayerID);
|
||||||
|
var msgargs = Regex.Split(args.Message, "(?<=^[^\"]*(?:\"[^\"]*\"[^\"]*)*) (?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)");
|
||||||
|
if (msgargs.Length == 2 && isadmin)
|
||||||
|
{
|
||||||
|
int player = -1;
|
||||||
|
player = Tools.FindPlayer((msgargs[1].TrimEnd('"')).TrimStart('"'));
|
||||||
|
//Main.player[player].KillMe(99999, 1);
|
||||||
|
Tools.SendMessage(args.PlayerID, "You just killed " + Tools.FindPlayer(player) + "!");
|
||||||
|
Tools.SendMessage(player, Tools.FindPlayer(args.PlayerID) + " just killed you!");
|
||||||
|
TShock.KillMe(player);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//Main.player[args.PlayerID].KillMe(99999, 1);
|
||||||
|
Tools.SendMessage(args.PlayerID, "You just suicided.");
|
||||||
|
TShock.KillMe(args.PlayerID);
|
||||||
|
}
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -215,25 +215,16 @@ namespace TShockAPI
|
||||||
if (msg.StartsWith("/"))
|
if (msg.StartsWith("/"))
|
||||||
{
|
{
|
||||||
Commands.CommandArgs args = new Commands.CommandArgs(msg, x, y, ply);
|
Commands.CommandArgs args = new Commands.CommandArgs(msg, x, y, ply);
|
||||||
if (msg.StartsWith("/help"))
|
var commands = commandList;
|
||||||
{
|
if (Tools.IsAdmin(ply))
|
||||||
commandList["help"].Invoke(args);
|
commands = admincommandList;
|
||||||
handler.Handled = true;
|
|
||||||
}
|
Commands.CommandDelegate command;
|
||||||
else if (Tools.IsAdmin(ply))
|
if (commands.TryGetValue(msg.Split(' ')[0].TrimStart('/'), out command))
|
||||||
{
|
command.Invoke(args);
|
||||||
Commands.CommandDelegate command;
|
else
|
||||||
if (admincommandList.TryGetValue(msg.Split(' ')[0].TrimStart('/'), out command))
|
Tools.SendMessage(ply, "Invalid command or no permissions! Try /help.", new float[] { 255f, 0f, 0f });
|
||||||
command.Invoke(args);
|
handler.Handled = true;
|
||||||
else
|
|
||||||
Tools.SendMessage(ply, "Invalid command! Try /help.", new float[] { 255f, 0f, 0f });
|
|
||||||
handler.Handled = true;
|
|
||||||
}
|
|
||||||
else if (!Tools.IsAdmin(ply) && msg != "/help")
|
|
||||||
{
|
|
||||||
Tools.SendMessage(ply, "You don't have permissions to do that!", new float[] { 255f, 0f, 0f });
|
|
||||||
handler.Handled = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -284,6 +275,7 @@ namespace TShockAPI
|
||||||
tileThreshold[i] = 0;
|
tileThreshold[i] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//writestuff();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -422,6 +414,12 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void KillMe(int plr)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < Main.player.Length; i++)
|
||||||
|
NetMessage.SendData(44, i, -1, "", plr, (float)1, (float)9999999, (float)0);
|
||||||
|
}
|
||||||
|
|
||||||
//TODO : Notify the player if there is more than one match. (or do we want a First() kinda thing?)
|
//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)
|
public static int GetNPCID(string name, bool exact = false)
|
||||||
{
|
{
|
||||||
|
|
@ -469,5 +467,29 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void writestuff()
|
||||||
|
{
|
||||||
|
NPC npc = new NPC();
|
||||||
|
string[] npclist = new string[44];
|
||||||
|
int h = 0;
|
||||||
|
for (int i = 1; i < 44; i++)
|
||||||
|
{
|
||||||
|
npc.SetDefaults(i);
|
||||||
|
//npclist[h++] = string.Format("{0} - {1} - {2} - {3} - {4} - {5} - {6} - {7}", i, npc.name, npc.townNPC, npc.boss, npc.noGravity, npc.lifeMax, npc.damage, npc.defense);
|
||||||
|
npclist[h++] = string.Format("{0}\t-\t{1}\t-\t{2}\t-\t{3}\t-\t{4}\t-\t{5}\t-\t{6}\t-\t{7}", i, npc.name, npc.townNPC, npc.boss, npc.noGravity, npc.lifeMax, npc.damage, npc.defense);
|
||||||
|
}
|
||||||
|
File.WriteAllLines("npclist.txt", npclist);
|
||||||
|
Item item = new Item();
|
||||||
|
string[] itemlist = new string[236];
|
||||||
|
h = 0;
|
||||||
|
for (int i = 1; i < 236; i++)
|
||||||
|
{
|
||||||
|
item.SetDefaults(i);
|
||||||
|
//itemlist[h++] = string.Format("{0} - {1} - {2} - {3}", i, item.name, item.maxStack, item.rare);
|
||||||
|
itemlist[h++] = string.Format("{0}\t-\t{1}\t-\t{2}\t-\t{3}", i, item.name, item.maxStack, item.rare);
|
||||||
|
}
|
||||||
|
File.WriteAllLines("itemlist.txt", itemlist);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue