public static void OnUnkownPacketSend(ref HookContext ctx, ref HookArgs.UnkownSendPacket args) { switch (args.PacketId) { case (int)Packets.CLIENT_MOD_GOD: { NetMessageExtension msg = new NetMessageExtension(); if (args.RemoteClient != -1) { var player = Main.players[args.RemoteClient]; if (player.HasClientMod) { if (Server.AllowTDCMRPG) { Server.notifyOps( String.Format("Failed attempt to {0} God Mode on an RPG Server.", true, (args.Number == 1) ? "give" : "remove")); return; } Server.notifyOps( String.Format("{0} {1} God Mode.", true, player.Name, (args.Number == 1) ? "has" : "doesn't have")); msg.GodTDCMClient(args.Number == 1); args.Message = msg; ctx.SetResult(HookResult.IGNORE); //Let TDSM know it's to ignore returning. } } break; } } }
void OnProjectile(ref HookContext ctx, ref HookArgs.ProjectileReceived args) { if (configBlockExplosives == false || args.Type==ProjectileType.ORB_OF_LIGHT || args.Type==ProjectileType.FLAMELASH ) { return; } else { Player player = ctx.Sender as Player; if (player == null) return; PlayerState state = null; if (!player.PluginData.Contains(this)) { state = new PlayerState(); player.PluginData[this] = state; states.Add(state); } else { state = (PlayerState)player.PluginData[this]; } ProjectileType type = args.Type; if (!(type == ProjectileType.ORB_OF_LIGHT || type == ProjectileType.FLAMELASH || type == ProjectileType.MISSILE_MAGIC)) { state.projectiles += 1; } if (state.projectiles >= 9) { ctx.SetResult(HookResult.IGNORE); state.projectiles -= 9; ProgramLog.Admin.Log("[" + base.Name + "]: Stopped projectile {0} spam from {1}.", type, player.Name ?? "<null>"); return; } if (player != null && (type == ProjectileType.DYNAMITE || type == ProjectileType.GRENADE || type == ProjectileType.BOMB || type == ProjectileType.BOMB_STICKY || type == ProjectileType.ARROW_HELLFIRE)) { ctx.SetResult(HookResult.IGNORE); player.sendMessage("You are not allowed to use explosives on this server.", 255, 255, 0, 0); ProgramLog.Admin.Log("[" + base.Name + "]: Cancelled Projectile Use of Player: " + ((Player)ctx.Sender).Name); } } }
void OnChestOpen(ref HookContext ctx, ref HookArgs.ChestOpenReceived args) { Player player = Server.GetPlayerByName(ctx.Sender.Name); if (IsInsideAnotherHouse(player.Name, (int)Main.chest[args.ChestIndex].x, (int)Main.chest[args.ChestIndex].y, CHECK_CHEST_LOCK) && !player.Op) { ctx.SetResult(HookResult.IGNORE); player.sendMessage("You cannot open this chest, it's locked and inside someone else's house", chatColor); } //base.onPlayerOpenChest(Event); }
void OnProjectileReceived(ref HookContext ctx, ref HookArgs.ProjectileReceived args) { Vector2 Position = new Vector2(args.X, args.Y); foreach (Region rgn in regionManager.Regions) { if (rgn.HasPoint(Position / 16)) { if (rgn.ProjectileList.Contains("*") || rgn.ProjectileList.Contains(args.Type.ToString()))// || //rgn.ProjectileList.Contains(args.Projectile.Name.ToLower().Replace(" ", ""))) { if (IsRestrictedForUser(ctx.Player, rgn, ProjectileUse)) { ctx.SetResult(HookResult.ERASE); ctx.Player.sendMessage("You cannot edit this area!", ChatColor.Red); return; } } } } }
void OnLiquidFlowReceived(ref HookContext ctx, ref HookArgs.LiquidFlowReceived args) { Vector2 Position = new Vector2(args.X, args.Y); foreach (Region rgn in regionManager.Regions) { if (rgn.HasPoint(Position)) { if (IsRestrictedForUser(ctx.Player, rgn, LiquidFlow)) { ctx.SetResult(HookResult.ERASE); ctx.Player.sendMessage("You cannot edit this area!", ChatColor.Red); return; } } } }
void OnChestOpen(ref HookContext ctx, ref HookArgs.ChestOpenReceived args) { foreach (Region rgn in regionManager.Regions) { if (rgn.HasPoint(new Vector2(args.X, args.Y))) { if (ctx.Sender is Player) { if (IsRestrictedForUser(ctx.Player, rgn, DoorChange)) { ctx.SetResult(HookResult.RECTIFY); ctx.Player.sendMessage("You cannot edit this object!", ChatColor.Red); return; } } } } }
public static void OnPlayerJoined(int plr) { var player = Main.players[plr]; var ctx = new HookContext { Connection = player.Connection, Player = player, Sender = player, }; var args = new HookArgs.PlayerEnteringGame { Slot = plr, }; HookPoints.PlayerEnteringGame.Invoke (ref ctx, ref args); if (ctx.CheckForKick ()) { return; } var msg = NetMessage.PrepareThreadInstance (); var motd = Program.properties.Greeting.Split('@'); for (int i = 0; i < motd.Length; i++) { if (motd[i] != null && motd[i].Trim().Length > 0) { msg.PlayerChat (255, motd[i], 0, 0, 255); } } string list = ""; for (int i = 0; i < 255; i++) { if (Main.players[i].Active) { if (list == "") list += Main.players[i].Name; else list = list + ", " + Main.players[i].Name; } } msg.PlayerChat (255, "Current players: " + list + ".", 255, 240, 20); msg.Send (plr); // send these before the login event, so messages from plugins come after var slot = NetPlay.slots[plr]; slot.announced = true; // to player msg.Clear(); msg.SendSyncOthersForPlayer (plr); ProgramLog.Users.Log ("{0} @ {1}: ENTER {2}", slot.remoteAddress, plr, player.Name); if (player.HasHackedData()) { player.Kick("No Hacked Health or Mana is allowed."); } // to other players msg.Clear(); msg.PlayerChat (255, player.Name + " has joined.", 255, 240, 20); msg.ReceivingPlayerJoined (plr); msg.SendSyncPlayerForOthers (plr); // broadcasts the preceding message too var args2 = new HookArgs.PlayerEnteredGame { Slot = plr, }; ctx.SetResult (HookResult.DEFAULT); HookPoints.PlayerEnteredGame.Invoke (ref ctx, ref args2); if (ctx.CheckForKick ()) { return; } }
void OnAlter(ref HookContext ctx, ref HookArgs.PlayerWorldAlteration args) { var player = ctx.Player; if (player == null || player.Name == null) { ProgramLog.Log ("<Mysql> Invalid player in onPlayerTileChange."); ctx.SetResult (HookResult.IGNORE); return; } if (s.isEnabled(ctx.Sender.Name) && ctx.Sender.Op) { var msg = getBlockHistory(args.X, args.Y, ctx.Sender); ProgramLog.Admin.Log ("<mysql> "+ctx.Sender.Name+" got tile history ("+args.X+", "+args.Y+")"); ctx.SetResult (HookResult.IGNORE); return; } if (!logtiles || !mysqlenabled) return; if (!args.RemovalFailed)//fixes multiple log entries for the same tile { logTile(player.Name, (int)args.X, (int)args.Y, args.Action, args.Type, Main.tile.At(args.X, args.Y)); //ProgramLog.Admin.Log(player.Name + " " + (int)args.X + " " + (int)args.Y + " " + args.Action + " " + args.Type + " " + Main.tile.At(args.X, args.Y).Type + " " + Main.tile.At(args.X, args.Y).Wall); } // args.Style is ignored for now }
void onPlayerChat(ref HookContext ctx, ref HookArgs.PlayerChat args) { Player player = ctx.Sender as Player; string playername = player.Name; if (mutelist.checklist(playername)) { DateTime timemuted = mutelist.getTimeMuted(playername); TimeSpan timeleft = timemuted.AddMinutes(5) - DateTime.UtcNow; if (timemuted > DateTime.UtcNow.AddHours(1)) { player.sendMessage("You are muted for a long time."); } else { player.sendMessage("You have " + timeleft.Minutes + ":" + timeleft.Seconds + " before you can chat again."); } ctx.SetResult(HookResult.IGNORE); } return; }
void OnReceiveProjectile(ref HookContext ctx, ref HookArgs.ProjectileReceived args) { if (!explosivesAllowed && args.Type.IsExplosive()) { Log("Cancelled Explosive usage of Player: " + ctx.Player.Name); ctx.SetResult(HookResult.ERASE); } }
void OnPlayerWorldAlteration(ref HookContext ctx, ref HookArgs.PlayerWorldAlteration args) { if (!tileBreakageAllowed) return; Log("Cancelled Tile change of Player: " + ctx.Player.Name); ctx.SetResult(HookResult.RECTIFY); }
void OnReceiveProjectile(ref HookContext ctx, ref HookArgs.ProjectileReceived args) { if (!explosivesAllowed) { int type = (int)args.Type; if (type == (int)ProjectileType.BOMB /* 28 */ || type == (int)ProjectileType.DYNAMITE /* 29 */ || type == (int)ProjectileType.BOMB_STICKY /* 37 */) { Log("Cancelled Explosive usage of Player: " + ctx.Player.Name); ctx.SetResult(HookResult.ERASE); } } }
void OnSignTextSet(ref HookContext ctx, ref HookArgs.SignTextSet args) { Player player = Server.GetPlayerByName(ctx.Sender.Name); if (IsInsideAnotherHouse(player.Name, (int)args.X, (int)args.Y, CHECK_SIGN_LOCK) && !player.Op) { ctx.SetResult(HookResult.RECTIFY); player.sendMessage("You cannot edit this sign, it's locked and inside someone else's house", chatColor); } //base.onPlayerEditSign(Event); }
void OnLiquidFlow(ref HookContext ctx, ref HookArgs.LiquidFlowReceived args) { Player player = Server.GetPlayerByName(ctx.Sender.Name); if (IsInsideAnotherHouse(player.Name, (int)args.X, (int)args.Y)) { ctx.SetResult(HookResult.IGNORE); player.sendMessage("You cannot use liquid inside someone else's house", chatColor); } //base.onPlayerFlowLiquid(Event); }
void OnSignTextSet(ref HookContext ctx, ref HookArgs.SignTextSet args) { if (configExtendedReachSign == false) { return; } else { Player player = ctx.Sender as Player; if (player == null || player.Op == true) { return; } int x = (int)args.X; int y = (int)args.Y; if (inSpawn(x, y)) { ctx.SetResult(HookResult.IGNORE); player.sendMessage("You are not allowed to edit spawn on this server.", 255, 255, 0, 0); return; } else if (distance(player.Location.X, player.Location.Y, x, y) > configExtendedReachRange) { ctx.SetResult(HookResult.IGNORE); player.sendMessage("You are too far away to edit that sign.", 255, 255, 0, 0); ProgramLog.Admin.Log("[" + base.Name + "]: Cancelled Sign Edit of Player: " + player.Name); } } }
void OnChat(ref HookContext ctx, ref HookArgs.PlayerChat args) { if (ctx.Player.AuthenticatedAs != null) { User usr; if (Permissions.users.TryGetValue(ctx.Player.Name, out usr)) { Color col; if (Chat.TryGetChatColor(usr, out col)) args.Color = col; string prefix; if (Chat.TryGetChatPrefix(usr, out prefix)) usr.prefix = prefix; string suffix; if (Chat.TryGetChatSuffix(usr, out suffix)) usr.suffix = suffix; string seperator; Chat.TryGetChatSeperator(usr, out seperator); ctx.SetResult(HookResult.IGNORE); Server.notifyAll( String.Concat(usr.prefix, ctx.Player.Name, seperator, args.Message, usr.suffix) , args.Color, false ); } } else if (ctx.Player.AuthenticatedAs == null) { Group dGrp = Permissions.GetDefaultGroup(); if (dGrp != null) { if (Chat.IsValidColor(dGrp.GroupInfo.color)) args.Color = dGrp.GroupInfo.color; ctx.SetResult(HookResult.IGNORE); Server.notifyAll( String.Concat( dGrp.GroupInfo.Prefix, ctx.Player.Name, dGrp.GroupInfo.Seperator, args.Message, dGrp.GroupInfo.Suffix) , args.Color, false ); } } }
void OnChat(ref HookContext ctx, ref HookArgs.PlayerChat args) { if (!IsEnabled) return; if (ctx.Player.AuthenticatedAs != null) { var name = ctx.Player.Name; if (XmlParser.HasUser(name)) { var user = XmlParser.GetUser(name); string chatSeperator, prefix, suffix; Color chatColour; GetChatSeperator(user, out chatSeperator); GetColor(user, out chatColour); GetPrefix(user, out prefix); GetSuffix(user, out suffix); args.Color = chatColour; //Might set this for next plugins. ctx.SetResult(HookResult.IGNORE); Server.notifyAll( String.Concat(prefix, ctx.Player.Name, chatSeperator, args.Message, suffix) , args.Color ); } else if (XmlParser.HasDefaultGroup()) { var defaultGroup = XmlParser.GetDefaultGroup(); ctx.SetResult(HookResult.IGNORE); Server.notifyAll( String.Concat ( defaultGroup.Prefix, ctx.Player.Name, defaultGroup.ChatSeperator, args.Message, defaultGroup.Suffix ) , defaultGroup.Color ); } } else if (ctx.Player.AuthenticatedAs == null) { if (XmlParser.HasDefaultGroup()) { var defaultGroup = XmlParser.GetDefaultGroup(); ctx.SetResult(HookResult.IGNORE); Server.notifyAll( String.Concat ( defaultGroup.Prefix, ctx.Player.Name, defaultGroup.ChatSeperator, args.Message, defaultGroup.Suffix ) , defaultGroup.Color ); } } }
void OnLiquidFlow(ref HookContext ctx, ref HookArgs.LiquidFlowReceived args) { var player = ctx.Player; if (player == null || player.Name == null) { ProgramLog.Log ("<Mysql> Invalid player in onPlayerFlowLiquid."); ctx.SetResult (HookResult.IGNORE); return; } if (!player.Op) return; // DEBUG: this is for if another plugin cancelled the event, not to log it *TEST* if (!mysqlenabled || !logliquid) return; DateTime value = DateTime.Now; string time = value.ToString ("yyyyMMddHHmmssffff"); string playername = player.Name.Replace ("'", @"\'"); // sends FlowLiquid information to the queue string isLava = null; if (args.Lava == true) { isLava = "LAVA"; } else { isLava = "WATER"; } //TODO: fix this string query = "INSERT INTO terraria_tiles ( timestamp, player, x, y, action, tile, tiletype ) " + "VALUES ( '" + time + "', '" + playername + "', '" + player.Location.X + "', '" + player.Location.Y + "', 'FLOW', 'null', '" + isLava + "' );"; q.add(query); }
void OnAlter(ref HookContext ctx, ref HookArgs.PlayerWorldAlteration args) { if (configExtendedReach == false) { return; } else { Player player = ctx.Sender as Player; if (player == null || player.Op == true) { return; } int x = (int)args.X; int y = (int)args.Y; if (inSpawn(x, y)) { ctx.SetResult(HookResult.IGNORE); player.sendMessage("You are not allowed to edit spawn on this server.", 255, 255, 0, 0); return; } else if (x < 0 || y < 0 || x > Main.maxTilesX || y > Main.maxTilesY || distance(player.Location.X, player.Location.Y, x, y) > configExtendedReachRange) { ctx.SetResult(HookResult.IGNORE); return; } } }
public override void Process(int whoAmI, byte[] readBuffer, int length, int num) { short projectileIdentity = BitConverter.ToInt16(readBuffer, num); num += 2; float x = BitConverter.ToSingle(readBuffer, num); num += 4; float y = BitConverter.ToSingle(readBuffer, num); num += 4; float vX = BitConverter.ToSingle(readBuffer, num); num += 4; float vY = BitConverter.ToSingle(readBuffer, num); num += 4; float knockBack = BitConverter.ToSingle(readBuffer, num); num += 4; short damage = BitConverter.ToInt16(readBuffer, num); num += 2; byte projectileOwner = readBuffer[num++]; byte type = readBuffer[num++]; if (projectileOwner != whoAmI) { #if DEBUG_PROJECTILES ProgramLog.Debug.Log ("Ignoring unowned projectile from {0} ({1})", whoAmI, projectileOwner); #endif return; } if (Projectile.MAX_AI != 2) { throw new Exception ("Projectile receiving code hasn't been updated!"); } var ai0 = BitConverter.ToSingle (readBuffer, num); num += 4; var ai1 = BitConverter.ToSingle (readBuffer, num); var player = Main.players[whoAmI]; var projectileIndex = Projectile.FindExisting (projectileIdentity, projectileOwner); var ctx = new HookContext { Connection = player.Connection, Player = player, Sender = player, }; var args = new HookArgs.ProjectileReceived { X = x, Y = y, VX = vX, VY = vY, Id = projectileIdentity, Owner = projectileOwner, Knockback = knockBack, Damage = damage, TypeByte = type, AI_0 = ai0, AI_1 = ai1, ExistingIndex = projectileIndex < 1000 ? projectileIndex : -1, }; if (projectileIndex == 1000 && args.Type.IsHighExplosive() && ai0 > 0.0) { // probably a lagged update from a repossessed projectile #if DEBUG_PROJECTILES ProgramLog.Debug.Log ("Ignoring old update for repossessed projectile."); #endif var msg = NetMessage.PrepareThreadInstance (); msg.EraseProjectile (projectileIdentity, projectileOwner); msg.Send (whoAmI); return; } HookPoints.ProjectileReceived.Invoke (ref ctx, ref args); if (ctx.CheckForKick ()) { args.CleanupProjectile (); return; } if (ctx.Result == HookResult.IGNORE) { args.CleanupProjectile (); return; } if (ctx.Result == HookResult.RECTIFY) { args.CleanupProjectile (); if (projectileIndex < 1000) { var msg = NetMessage.PrepareThreadInstance (); msg.Projectile (Main.projectile[projectileIndex]); msg.Send (whoAmI); return; } else { ctx.SetResult (HookResult.ERASE); } } if (ctx.Result == HookResult.ERASE) { args.CleanupProjectile (); var msg = NetMessage.PrepareThreadInstance (); msg.EraseProjectile (projectileIdentity, projectileOwner); msg.Send (whoAmI); return; } if (ctx.Result != HookResult.CONTINUE) { if (type > Projectile.MAX_PROJECTILES) { args.CleanupProjectile (); NetPlay.slots[whoAmI].Kick ("Invalid projectile."); return; } else if (type == (int)ProjectileType.N38_HARPY_FEATHER || type == (int)ProjectileType.N55_STINGER || type == (int)ProjectileType.N44_DEMON_SICKLE) { args.CleanupProjectile (); NetPlay.slots[whoAmI].Kick ("Projectile cheat detected."); return; } else if (type == (int)ProjectileType.N23_HARPOON) { args.CleanupProjectile (); if (Math.Abs (vX) + Math.Abs (vY) < 1e-4) // ideally, we'd want to figure out all projectiles that never have 0 velocity { NetPlay.slots[whoAmI].Kick ("Harpoon cheat detected."); return; } } } Projectile projectile; if (args.ExistingIndex >= 0) { #if DEBUG_PROJECTILES ProgramLog.Debug.Log ("Updated projectile {0} ({1}/{2}/{3}) ({4}/{5})", projectileIndex, projectileOwner, projectileIdentity, args.Type, ai0, ai1); #endif args.CleanupProjectile (); projectile = Main.projectile[args.ExistingIndex]; args.Apply (projectile); } else { projectile = args.CreateProjectile (); if (projectile == null) { //ProgramLog.Debug.Log ("No slots left for projectile ({1}/{2}/{3})", projectileOwner, projectileIdentity, args.Type); return; } projectileIndex = projectile.whoAmI; #if DEBUG_PROJECTILES ProgramLog.Debug.Log ("Created projectile {0} ({1}/{2}/{3}) ({4}/{5})", projectileIndex, projectileOwner, projectileIdentity, args.Type, ai0, ai1); #endif } if (args.Type.IsHighExplosive()) { #if DEBUG_PROJECTILES ProgramLog.Debug.Log ("Repossessing projectile ({0}, {1}, {2}, {3}).", vX, vY, ai0, ai1); #endif // transfer ownership //var msg = NetMessage.PrepareThreadInstance (); //msg.EraseProjectile (projectileIdentity, projectileOwner); //projectile.Repossess (); //msg.Projectile (projectile); //msg.Send (whoAmI); /* temp, Until Repossessing is complete, At the moment if killed by a repossessed projectile * the client wont be killed, the death text will fire once, thereafter they cannot * be killed via explosives. */ if (Server.RejectedItems.Contains(args.TypeByte.ToString()) || Server.RejectedItems.Contains(projectile.Name) || !Program.properties.AllowExplosions) { var msg = NetMessage.PrepareThreadInstance(); msg.EraseProjectile(projectileIdentity, projectileOwner); msg.Send(whoAmI); } } // int projectileIndex = getProjectileIndex(projectileOwner, projectileIdentity); // Projectile oldProjectile = Main.projectile[projectileIndex]; // if (!oldProjectile.Active || projectile.type != oldProjectile.type) // { // NetPlay.slots[whoAmI].spamProjectile += 1f; // } // if (playerEvent.Cancelled || (!Program.properties.AllowExplosions && // ( type == (int)ProjectileType.BOMB /* 28 */ || // type == (int)ProjectileType.DYNAMITE /* 29 */ || // type == (int)ProjectileType.BOMB_STICKY /* 37 */ // ) && !Main.players[whoAmI].Op)) // { // // erase the projectile client-side // projectile.Position.X = -1000; // projectile.Position.Y = -1000; // projectile.type = ProjectileType.UNKNOWN; // // var msg = NetMessage.PrepareThreadInstance (); // msg.Projectile (projectile); // msg.Send (whoAmI); // // return; // } Main.projectile[projectileIndex] = projectile; NetMessage.SendData(27, -1, whoAmI, "", projectileIndex); }
void OnDoorStateChanged(ref HookContext ctx, ref HookArgs.DoorStateChanged args) { if (configExtendedReachDoor == false) { return; } else { Player player = ctx.Sender as Player; if (player == null || player.Op == true) { return; } if (distance(player.Location.X, player.Location.Y, args.X, args.Y) > configExtendedReachRange) { ctx.SetResult(HookResult.IGNORE); player.sendMessage("You are too far away to " + args.Direction + " that door", 255, 255, 0, 0); ProgramLog.Admin.Log("[" + base.Name + "]: Cancelled Door Change of Player: " + player.Name); } } }
void OnDoorStateChange(ref HookContext ctx, ref HookArgs.DoorStateChanged args) { foreach (Region rgn in regionManager.Regions) { if (rgn.HasPoint(new Vector2(args.X, args.Y))) { if (ctx.Sender is Player) { Player player = ctx.Sender as Player; if (IsRestrictedForUser(player, rgn, DoorChange)) { ctx.SetResult(HookResult.RECTIFY); player.sendMessage("You cannot edit this area!", ChatColor.Red); return; } } else if (ctx.Sender is NPC) { if (rgn.RestrictedNPCs) { ctx.SetResult(HookResult.RECTIFY); //[TODO] look into RECIFYing for NPC's, They don't need to be resent, only cancelled, IGRNORE? return; } } } } }
void OnLiquidFlow(ref HookContext ctx, ref HookArgs.LiquidFlowReceived args) { if (!configBlockLavaFlow && !configBlockWaterFlow) { return; } Player player = ctx.Sender as Player; if (player == null) return; if (player.Op) return; int x = (int)args.X; int y = (int)args.Y; if (args.Lava && configBlockLavaFlow) { ctx.SetResult(HookResult.IGNORE); player.sendMessage("You are not allowed to use lava on this server.", 255, 255, 0, 0); return; } else if (!args.Lava && configBlockWaterFlow) { ctx.SetResult(HookResult.IGNORE); player.sendMessage("You are not allowed to use water on this server.", 255, 255, 0, 0); return; } else if (inSpawn(x, y)) { ctx.SetResult(HookResult.IGNORE); player.sendMessage("You are not allowed to edit spawn on this server.", 255, 255, 0, 0); return; } else if (x < 0 || y < 0 || x > Main.maxTilesX || y > Main.maxTilesY || distance(player.Location.X, player.Location.Y, x, y) > configExtendedReachRange) { //ProgramLog.Debug.Log("[" + base.Name + "]: Cancelled out of reach {1} flow by {0}.", player.Name ?? player.whoAmi.ToString(), Event.Lava ? "lava" : "water"); ctx.SetResult(HookResult.IGNORE); return; } }
void OnPlayerWorldAlteration(ref HookContext ctx, ref HookArgs.PlayerWorldAlteration args) { Vector2 Position = new Vector2(args.X, args.Y); if (args.TileWasPlaced && args.Type == SelectorItem && selection.isInSelectionlist(ctx.Player) && ctx.Player.Op) { ctx.SetResult(HookResult.RECTIFY); SelectorPos = !SelectorPos; Vector2[] mousePoints = selection.GetSelection(ctx.Player); if (!SelectorPos) mousePoints[0] = Position; else mousePoints[1] = Position; selection.SetSelection(ctx.Player, mousePoints); ctx.Player.sendMessage(String.Format("You have selected block at {0},{1}, {2} position", Position.X, Position.Y, (!SelectorPos) ? "First" : "Second"), ChatColor.Green); return; } foreach (Region rgn in regionManager.Regions) { if (rgn.HasPoint(Position)) { if (IsRestrictedForUser(ctx.Player, rgn, ((args.TileWasRemoved || args.WallWasRemoved) ? TileBreak : TilePlace))) { ctx.SetResult(WorldAlter); ctx.Player.sendMessage("You cannot edit this area!", ChatColor.Red); return; } } } }
void onPlayerChat(ref HookContext ctx, ref HookArgs.PlayerChat args) { if (configBlockChatSpam == false) { return; } else { Player player = ctx.Sender as Player; if (player == null || player.Op) return; PlayerState state = null; if (!player.PluginData.Contains(this)) { state = new PlayerState(); player.PluginData[this] = state; states.Add(state); } else { state = (PlayerState)player.PluginData[this]; } state.messages += 1; if (state.messages >= 9) { ctx.SetResult(HookResult.IGNORE); state.messages -= 9; ProgramLog.Admin.Log("[" + base.Name + "]: Stopped chat spam from {1}.", player.Name ?? "<null>"); player.Kick("Do not spam chat."); return; } } }
void OnSignEdit(ref HookContext ctx, ref HookArgs.SignTextSet args) { foreach (Region rgn in regionManager.Regions) { if (rgn.HasPoint(new Vector2(args.X, args.Y))) { if (ctx.Sender is Player) { if (IsRestrictedForUser(ctx.Player, rgn, DoorChange)) { ctx.SetResult(HookResult.IGNORE); ctx.Player.sendMessage("You cannot edit this area!", ChatColor.Red); return; } } } } }
void OnAlter(ref HookContext ctx, ref HookArgs.PlayerWorldAlteration args) { Player player = Server.GetPlayerByName(ctx.Sender.Name); bool starthouse = player.PluginData.ContainsKey("starthouse") ? (bool)player.PluginData["starthouse"] : false; bool endhouse = player.PluginData.ContainsKey("endhouse") ? (bool)player.PluginData["endhouse"] : false; bool check = player.PluginData.ContainsKey("check") ? (bool)player.PluginData["check"] : false; bool teleportSet = player.PluginData.ContainsKey("teleportset") ? (bool)player.PluginData["teleportset"] : false; int houseIndex = player.PluginData.ContainsKey("houseIndex") ? (int)player.PluginData["houseIndex"] : -1; string houseName = player.PluginData.ContainsKey("houseName") ? (string)player.PluginData["houseName"] : null; if (starthouse || endhouse) { String NodeName = starthouse ? "topleft" : "bottomright"; String cornerDesc = starthouse ? "top-left" : "bottom-right"; ctx.SetResult(HookResult.RECTIFY); if (GetHouseNameImInside(player) == null) { UpdateCoordsForPlayer(player.Name, (int)args.X, (int)args.Y, houseIndex); player.sendMessage("You've set the " + cornerDesc + " corner of house " + houseName, chatColor); player.PluginData["starthouse"] = false; player.PluginData["endhouse"] = false; } else { player.sendMessage("You're inside another house, you cannot set your " + cornerDesc + " here"); } } else if (IsInsideAnotherHouse(player.Name, (int)args.X, (int)args.Y) && ! starthouse && ! endhouse && !player.Op) { ctx.SetResult(HookResult.RECTIFY); player.sendMessage("You're trying to build inside someone's house--this is not allowed", chatColor); } else if (check) { ctx.SetResult(HookResult.RECTIFY); player.PluginData["check"] = false; player.sendMessage("The block you just clicked on is at " + (int)args.X + "," + (int)args.Y, chatColor); } else if (teleportSet) { if (GetMyHouseNamePositionInside(player.Name, (int)args.X, (int)args.Y) == (string)player.PluginData["teleporthouse"]) { int playerIndex = GetPlayerHouseIndex(player.Name); houseIndex = GetHouseCoordsIndexByName(player.Name, (string)player.PluginData["teleporthouse"]); PlayerHouseCoords tempCoords = playerHouses[playerIndex].Houses[houseIndex]; tempCoords.TeleportPoint.X = (int)args.X; tempCoords.TeleportPoint.Y = (int)args.Y; playerHouses[playerIndex].Houses[houseIndex] = tempCoords; player.sendMessage("Teleport point set for house " + (string)player.PluginData["teleporthouse"], chatColor); } else player.sendMessage("That block is not inside your house called " + (string)player.PluginData["teleporthouse"], chatColor); player.PluginData["teleportset"] = false; } //base.onPlayerTileChange(Event); }