public static void ShowFileToUser(TPPlayer player, string file, string players) { string foo = ""; using (var tr = new StreamReader(Path.Combine(TPulse.SavePath, file))) { while ((foo = tr.ReadLine()) != null) { foo = foo.Replace("%map%", Main.worldName); foo = foo.Replace("%players%", players); //foo = SanitizeString(foo); if (foo.Substring(0, 1) == "%" && foo.Substring(12, 1) == "%") //Look for a beginning color code. { string possibleColor = foo.Substring(0, 13); foo = foo.Remove(0, 13); float[] pC = { 0, 0, 0 }; possibleColor = possibleColor.Replace("%", ""); string[] pCc = possibleColor.Split(','); if (pCc.Length == 3) { try { player.SendMessage(foo, (byte)Convert.ToInt32(pCc[0]), (byte)Convert.ToInt32(pCc[1]), (byte)Convert.ToInt32(pCc[2])); continue; } catch (Exception e) { Log.Error(e.ToString()); } } } player.SendMessage(foo); } } }
private object PlayerSetMute(IParameterCollection parameters, bool mute) { var ret = PlayerFind(parameters); if (ret is RestObject) { return(ret); } TPPlayer player = (TPPlayer)ret; player.mute = mute; var verb = mute ? "muted" : "unmuted"; player.SendMessage("You have been remotely " + verb); return(RestResponse("Player " + player.Name + " was " + verb)); }
private object PlayerKill(RestVerbs verbs, IParameterCollection parameters) { var ret = PlayerFind(parameters); if (ret is RestObject) { return(ret); } TPPlayer player = (TPPlayer)ret; player.DamagePlayer(999999); var from = string.IsNullOrWhiteSpace(parameters["from"]) ? "Server Admin" : parameters["from"]; player.SendMessage(string.Format("{0} just killed you!", from)); return(RestResponse("Player " + player.Name + " was killed")); }
public bool CheckTilePermission(TPPlayer player, int tileX, int tileY) { if (!player.Group.HasPermission(Permissions.canbuild)) { if (((DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond) - player.BPm) > 2000){ player.SendMessage("You do not have permission to build!", Color.Red); player.BPm=DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond; } return true; } if (!player.Group.HasPermission(Permissions.editspawn) && !Regions.CanBuild(tileX, tileY, player) && Regions.InArea(tileX, tileY)) { if (((DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond) - player.RPm) > 2000) { player.SendMessage("This region is protected from changes.", Color.Red); player.RPm = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond; } return true; } if (Config.DisableBuild) { if (!player.Group.HasPermission(Permissions.editspawn)) { if (((DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond) - player.WPm) > 2000){ player.SendMessage("The world is protected from changes.", Color.Red); player.WPm=DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond; } return true; } } if (Config.SpawnProtection) { if (!player.Group.HasPermission(Permissions.editspawn)) { var flag = CheckSpawn(tileX, tileY); if (flag) { if (((DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond) - player.SPm) > 1000){ player.SendMessage("Spawn is protected from changes.", Color.Red); player.SPm=DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond; } return true; } } } return false; }
public bool CheckTilePermission( TPPlayer player, int tileX, int tileY, byte tileType, byte actionType ) { if (!player.Group.HasPermission(Permissions.canbuild)) { if (Config.AllowIce && actionType != 1) { foreach (Point p in player.IceTiles) { if (p.X == tileX && p.Y == tileY && (Main.tile[p.X, p.Y].type == 0 || Main.tile[p.X, p.Y].type == 127)) { player.IceTiles.Remove(p); return false; } } if (((DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond) - player.BPm) > 2000){ player.SendMessage("You do not have permission to build!", Color.Red); player.BPm=DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond; } return true; } if (Config.AllowIce && actionType == 1 && tileType == 127) { player.IceTiles.Add(new Point(tileX, tileY)); return false; } if (((DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond) - player.BPm) > 2000){ player.SendMessage("You do not have permission to build!", Color.Red); player.BPm=DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond; } return true; } if (!player.Group.HasPermission(Permissions.editspawn) && !Regions.CanBuild(tileX, tileY, player) && Regions.InArea(tileX, tileY)) { if (((DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond) - player.RPm) > 2000) { player.SendMessage("This region is protected from changes.", Color.Red); player.RPm = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond; } return true; } if (Config.DisableBuild) { if (!player.Group.HasPermission(Permissions.editspawn)) { if (((DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond) - player.WPm) > 2000){ player.SendMessage("The world is protected from changes.", Color.Red); player.WPm=DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond; } return true; } } if (Config.SpawnProtection) { if (!player.Group.HasPermission(Permissions.editspawn)) { var flag = CheckSpawn(tileX, tileY); if (flag) { if (((DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond) - player.SPm) > 2000){ player.SendMessage("Spawn is protected from changes.", Color.Red); player.SPm=DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond; } return true; } } } return false; }
public static bool HackedInventory(TPPlayer player) { bool check = false; Item[] inventory = player.TPlayer.inventory; Item[] armor = player.TPlayer.armor; for (int i = 0; i < NetItem.maxNetInventory; i++) { if (i < 49) { Item item = new Item(); if (inventory[i] != null && inventory[i].netID != 0) { item.netDefaults(inventory[i].netID); item.Prefix(inventory[i].prefix); item.AffixName(); if (inventory[i].stack > item.maxStack) { check = true; player.SendMessage( String.Format("Stack cheat detected. Remove item {0} ({1}) and then rejoin", item.name, inventory[i].stack), Color.Cyan); } } } else { Item item = new Item(); if (armor[i - 48] != null && armor[i - 48].netID != 0) { item.netDefaults(armor[i - 48].netID); item.Prefix(armor[i - 48].prefix); item.AffixName(); if (armor[i - 48].stack > item.maxStack) { check = true; player.SendMessage( String.Format("Stack cheat detected. Remove armor {0} ({1}) and then rejoin", item.name, armor[i - 48].stack), Color.Cyan); } } } } return check; }
public static bool CheckInventory(TPPlayer player) { PlayerData playerData = player.PlayerData; bool check = true; if (player.TPlayer.statLifeMax > playerData.maxHealth) { player.SendMessage("Error: Your max health exceeded (" + playerData.maxHealth + ") which is stored on server.", Color.Cyan); check = false; } Item[] inventory = player.TPlayer.inventory; Item[] armor = player.TPlayer.armor; for (int i = 0; i < NetItem.maxNetInventory; i++) { if (i < 49) { Item item = new Item(); Item serverItem = new Item(); if (inventory[i] != null && inventory[i].netID != 0) { if (playerData.inventory[i].netID != inventory[i].netID) { item.netDefaults(inventory[i].netID); item.Prefix(inventory[i].prefix); item.AffixName(); player.SendMessage(player.IgnoreActionsForInventory = "Your item (" + item.name + ") needs to be deleted.", Color.Cyan); check = false; } else if (playerData.inventory[i].prefix != inventory[i].prefix) { item.netDefaults(inventory[i].netID); item.Prefix(inventory[i].prefix); item.AffixName(); player.SendMessage(player.IgnoreActionsForInventory = "Your item (" + item.name + ") needs to be deleted.", Color.Cyan); check = false; } else if (inventory[i].stack > playerData.inventory[i].stack) { item.netDefaults(inventory[i].netID); item.Prefix(inventory[i].prefix); item.AffixName(); player.SendMessage( player.IgnoreActionsForInventory = "Your item (" + item.name + ") (" + inventory[i].stack + ") needs to have its stack size decreased to (" + playerData.inventory[i].stack + ").", Color.Cyan); check = false; } } } else { Item item = new Item(); Item serverItem = new Item(); if (armor[i - 48] != null && armor[i - 48].netID != 0) { if (playerData.inventory[i].netID != armor[i - 48].netID) { item.netDefaults(armor[i - 48].netID); item.Prefix(armor[i - 48].prefix); item.AffixName(); player.SendMessage(player.IgnoreActionsForInventory = "Your armor (" + item.name + ") needs to be deleted.", Color.Cyan); check = false; } else if (playerData.inventory[i].prefix != armor[i - 48].prefix) { item.netDefaults(armor[i - 48].netID); item.Prefix(armor[i - 48].prefix); item.AffixName(); player.SendMessage(player.IgnoreActionsForInventory = "Your armor (" + item.name + ") needs to be deleted.", Color.Cyan); check = false; } else if (armor[i - 48].stack > playerData.inventory[i].stack) { item.netDefaults(armor[i - 48].netID); item.Prefix(armor[i - 48].prefix); item.AffixName(); player.SendMessage( player.IgnoreActionsForInventory = "Your armor (" + item.name + ") (" + inventory[i].stack + ") needs to have its stack size decreased to (" + playerData.inventory[i].stack + ").", Color.Cyan); check = false; } } } } return check; }
private void SendHelp(TPPlayer player) { player.SendMessage("Friends: /friend cmd [args]", TextColor); player.SendMessage("Friends: Available commands", TextColor); player.SendMessage("Friends: add, del, list, help", TextColor); }