private static bool OnSignKill(int x, int y, string text, int who) { if (!text.ToLower().StartsWith(config.DefineSignCommands.ToLower())) { return(false); } var sPly = ScPlayers[who]; var tPly = TShock.Players[who]; if (sPly == null || tPly == null) { return(false); } var sign = ScSigns.Check(x, y, text, sPly.TsPlayer); if (sPly.DestroyMode && ScUtils.CanBreak(sPly.TsPlayer)) { sPly.DestroyMode = false; //Cooldown removal return(false); } try { sign.ExecuteCommands(sPly); } catch (Exception ex) { SendErrorToPlayer(sPly, tPly, ex.Message); } return(true); }
private static bool OnSignOpen(int x, int y, string text, int who) { if (!text.ToLower().StartsWith(config.DefineSignCommands.ToLower())) return false; var tPly = TShock.Players[who]; var sign = ScSigns.Check(x, y, text, tPly); if (!ScUtils.CanRead(tPly, sign)) return true; return false; }
private static bool OnSignNew(int x, int y, string text, int who, int signIndex) { if (!text.StartsWith(config.DefineSignCommands, StringComparison.CurrentCultureIgnoreCase)) { return(false); } var tPly = TShock.Players[who]; var sPly = ScPlayers[who]; var point = new Point(x, y); if (tPly == null || sPly == null) { return(false); } if (!ScUtils.CanCreate(tPly)) { SendErrorToPlayer(sPly, tPly, "You do not have the permission to create a Sign Commands sign."); return(true); } ScSign sign; try { sign = new ScSign(text, tPly, point); } catch (Exception ex) { SendErrorToPlayer(sPly, tPly, ex.Message); return(true); } if (!ScUtils.CanEdit(tPly, sign)) { SendErrorToPlayer(sPly, tPly, "This sign is protected from modifications."); return(true); } Task.Factory.StartNew(() => { Thread.Sleep(10); // actually register the new command sign only, if the player had the permission to change the sign text. // This ensures that tshock (by regions) and other plugins protecting this sign have a chance to prevent the change. string newText = Main.sign[signIndex].text; bool textWasApplied = (newText == text); if (textWasApplied) { ScSigns.AddItem(point, sign); } }); return(false); }
public static bool OnSignHit(int x, int y, string text, int who) { if (!text.ToLower().StartsWith(config.DefineSignCommands.ToLower())) return false; var tPly = TShock.Players[who]; var sPly = ScPlayers[who]; var sign = ScSigns.Check(x, y, text, tPly); if (tPly == null || sPly == null) return false; var canBreak = ScUtils.CanBreak(tPly); if (sPly.DestroyMode && canBreak) return false; if (config.ShowDestroyMessage && canBreak && sPly.AlertDestroyCooldown == 0) { tPly.SendInfoMessage("To destroy this sign, Type \"/destroysign\"."); sPly.AlertDestroyCooldown = 10; } try { sign.ExecuteCommands(sPly); } catch (Exception ex) { SendErrorToPlayer(sPly, tPly, ex.Message); } return true; }