Added /slap - /slap <player> [dmg].
^ Seems buggy ATM, only smacks you in one direction and seems to ignore tile collision.
This commit is contained in:
parent
098841e7e9
commit
17c6fa8e87
2 changed files with 37 additions and 25 deletions
|
|
@ -465,6 +465,37 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
public static void Slap(CommandArgs args)
|
public static void Slap(CommandArgs args)
|
||||||
{
|
{
|
||||||
|
var msgargs = Regex.Split(args.Message, "(?<=^[^\"]*(?:\"[^\"]*\"[^\"]*)*) (?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)");
|
||||||
|
for (int i = 0; i < msgargs.Length; i++)
|
||||||
|
msgargs[i] = (msgargs[i].TrimStart('"')).TrimEnd('"');
|
||||||
|
if (msgargs.Length == 1)
|
||||||
|
Tools.SendMessage(args.PlayerID, "Invalid syntax! Proper syntax: /slap <player> [dmg]", new float[] { 255f, 0f, 0f });
|
||||||
|
else if (msgargs.Length == 2)
|
||||||
|
{
|
||||||
|
int player = Tools.FindPlayer(msgargs[1]);
|
||||||
|
if (player == -1)
|
||||||
|
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);
|
||||||
|
Tools.Broadcast(Tools.FindPlayer(args.PlayerID) + " slapped " + Tools.FindPlayer(player) + " for 5 damage.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (msgargs.Length == 3)
|
||||||
|
{
|
||||||
|
int player = Tools.FindPlayer(msgargs[1]);
|
||||||
|
int damage = 5;
|
||||||
|
int.TryParse(msgargs[2], out damage);
|
||||||
|
if (player == -1)
|
||||||
|
Tools.SendMessage(args.PlayerID, "Invalid player!", new float[] { 255f, 0f, 0f });
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TShock.SendDataAll(26, -1, "", player, (float)((new Random()).Next(1, 40)), (float)damage, (float)0);
|
||||||
|
Tools.Broadcast(Tools.FindPlayer(args.PlayerID) + " slapped " + Tools.FindPlayer(player) + " for " + damage.ToString() + " damage.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Tools.SendMessage(args.PlayerID, "Invalid syntax! Proper syntax: /slap <player> [dmg]", new float[] { 255f, 0f, 0f });
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -273,7 +273,6 @@ namespace TShockAPI
|
||||||
tileThreshold[i] = 0;
|
tileThreshold[i] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//writestuff();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -418,6 +417,12 @@ namespace TShockAPI
|
||||||
NetMessage.SendData(44, i, -1, "", plr, (float)1, (float)9999999, (float)0);
|
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?)
|
//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)
|
||||||
{
|
{
|
||||||
|
|
@ -465,29 +470,5 @@ 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