本文整理汇总了C#中Terraria_Server.Plugins.HookContext.SetResult方法的典型用法代码示例。如果您正苦于以下问题:C# HookContext.SetResult方法的具体用法?C# HookContext.SetResult怎么用?C# HookContext.SetResult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Terraria_Server.Plugins.HookContext
的用法示例。
在下文中一共展示了HookContext.SetResult方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnUnkownPacketSend
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;
}
}
}
示例2: OnProjectile
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);
}
}
}
示例3: OnChestOpen
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);
}
示例4: OnProjectileReceived
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;
}
}
}
}
}
示例5: OnLiquidFlowReceived
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;
}
}
}
}
示例6: OnChestOpen
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;
}
}
}
}
}
示例7: OnPlayerJoined
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;
}
}
示例8: OnAlter
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
}
示例9: onPlayerChat
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;
}
示例10: OnReceiveProjectile
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);
}
}
示例11: OnPlayerWorldAlteration
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);
}
示例12: OnReceiveProjectile
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);
}
}
}
示例13: OnSignTextSet
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);
}
示例14: OnLiquidFlow
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);
}
示例15: OnSignTextSet
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);
}
}
}