public override void Execute(TriggerBase trigger) { var hardwareId = trigger.Get <string>("hardwareId"); var reason = trigger.Get <string>("reason"); if (!IPCAccessor.Instance.IsConnected) { trigger.ReplyError("IPC service not operational !"); return; } var message = new BanHardwareIdMessage { HardwareId = hardwareId, BanReason = reason }; var source = trigger.GetSource() as WorldClient; if (source != null) { message.BannerAccountId = source.Account.Id; } IPCAccessor.Instance.SendRequest(message, ok => { World.Instance.ForEachCharacter(x => x.Account.LastHardwareId == hardwareId, character => character.Client.Disconnect()); trigger.Reply("HardwareId {0} banned", hardwareId); }, error => trigger.ReplyError("HardwareId {0} not banned : {1}", hardwareId, error.Message)); }
public override void Execute(TriggerBase trigger) { var ip = trigger.Get <string>("ip"); var reason = trigger.Get <string>("reason"); if (!IPCAccessor.Instance.IsConnected) { trigger.ReplyError("IPC service not operational !"); return; } try { IPAddressRange.Parse(ip); } catch { trigger.ReplyError("IP format '{0}' incorrect", ip); return; } var message = new BanIPMessage { IPRange = ip, BanReason = reason, }; var source = trigger.GetSource() as WorldClient; if (source != null) { message.BannerAccountId = source.Account.Id; } if (trigger.IsArgumentDefined("time")) { message.BanEndDate = DateTime.Now + TimeSpan.FromMinutes(trigger.Get <int>("time")); } else if (trigger.IsArgumentDefined("life")) { message.BanEndDate = null; } else { trigger.ReplyError("No ban duration given"); return; } IPCAccessor.Instance.SendRequest(message, ok => trigger.Reply("IP {0} banned", ip), error => trigger.ReplyError("IP {0} not banned : {1}", ip, error.Message)); }
public override void Execute(TriggerBase trigger) { var reason = trigger.Get <string>("reason"); if (!IPCAccessor.Instance.IsConnected) { trigger.ReplyError("IPC service not operational !"); return; } foreach (var target in GetTargets(trigger)) { var message = new BanAccountMessage { AccountId = target.Account.Id, BanReason = reason, }; var source = trigger.GetSource() as WorldClient; if (source != null) { message.BannerAccountId = source.Account.Id; } if (!trigger.IsArgumentDefined("time")) { trigger.ReplyError("No ban duration given"); return; } var time = trigger.Get <int>("time"); message.BanEndDate = DateTime.Now + TimeSpan.FromMinutes(time); message.Jailed = true; IPCAccessor.Instance.SendRequest(message, ok => { target.Area.ExecuteInContext(() => target.TeleportToJail()); target.Account.IsJailed = true; target.Mute(TimeSpan.FromMinutes(time), source.Character); target.OpenPopup(string.Format("Vous avez été emprisonné et muté pendant {0} minutes par {1}", time, source.Character.Name)); trigger.Reply("Account {0} jailed for {1} minutes. Reason : {2}", target.Account.Login, trigger.Get <int>("time"), reason); }, error => trigger.ReplyError("Account {0} not jailed : {1}", target.Account.Login, error.Message)); } }
public override void Execute(TriggerBase trigger) { var accountName = trigger.Get <string>("account"); var reason = trigger.Get <string>("reason"); if (!IPCAccessor.Instance.IsConnected) { trigger.ReplyError("IPC service not operational !"); return; } var message = new BanAccountMessage { AccountName = accountName, BanReason = reason, }; var source = trigger.GetSource() as WorldClient; if (source != null) { message.BannerAccountId = source.Account.Id; } if (trigger.IsArgumentDefined("time")) { message.BanEndDate = DateTime.Now + TimeSpan.FromMinutes(trigger.Get <int>("time")); } else if (trigger.IsArgumentDefined("life")) { message.BanEndDate = null; } else { trigger.ReplyError("No ban duration given"); return; } IPCAccessor.Instance.SendRequest(message, ok => trigger.Reply("Account {0} banned", accountName), error => trigger.ReplyError("Account {0} not banned : {1}", accountName, error.Message)); }
public override void Execute(TriggerBase trigger) { string reason = trigger.Get <string>("reason"); if (!IPCAccessor.Instance.IsConnected) { trigger.ReplyError("IPC service not operational !"); } else { Character[] targets = base.GetTargets(trigger); for (int i = 0; i < targets.Length; i++) { Character target = targets[i]; BanAccountMessage banAccountMessage = new BanAccountMessage { AccountId = new int?(target.Account.Id), BanReason = reason }; WorldClient worldClient = trigger.GetSource() as WorldClient; if (worldClient != null) { banAccountMessage.BannerAccountId = new int?(worldClient.Account.Id); } if (trigger.IsArgumentDefined("time")) { int num = trigger.Get <int>("time"); if (num > 1440 && trigger.UserRole == RoleEnum.GameMaster_Padawan) { num = 1440; } banAccountMessage.BanEndDate = new System.DateTime?(System.DateTime.Now + System.TimeSpan.FromMinutes((double)num)); } else { if (!trigger.IsArgumentDefined("life") || trigger.UserRole == RoleEnum.GameMaster_Padawan) { trigger.ReplyError("No ban duration given"); break; } banAccountMessage.BanEndDate = null; } target.TeleportToJail(); target.Account.IsJailed = true; banAccountMessage.Jailed = true; IPCAccessor.Instance.SendRequest(banAccountMessage, delegate(CommonOKMessage ok) { trigger.Reply("Account {0} jailed for {1} minutes. Reason : {2}", new object[] { target.Account.Login, trigger.Get <int>("time"), reason }); }, delegate(IPCErrorMessage error) { trigger.ReplyError("Account {0} not jailed : {1}", new object[] { target.Account.Login, error.Message }); }); } } }
public override void Execute(TriggerBase trigger) { string reason = trigger.Get <string>("reason"); if (!IPCAccessor.Instance.IsConnected) { trigger.ReplyError("IPC service not operational !"); } else { Character[] targets = base.GetTargets(trigger); for (int i = 0; i < targets.Length; i++) { Character target = targets[i]; BanAccountMessage banAccountMessage = new BanAccountMessage { AccountId = new int?(target.Account.Id), BanReason = reason }; WorldClient worldClient = trigger.GetSource() as WorldClient; if (worldClient != null) { banAccountMessage.BannerAccountId = new int?(worldClient.Account.Id); } else { if (!trigger.IsArgumentDefined("life") || trigger.UserRole == RoleEnum.GameMaster_Padawan) { trigger.ReplyError("Ajoute le temps du Ban"); break; } banAccountMessage.BanEndDate = null; } banAccountMessage.Jailed = false; target.Client.Disconnect(); IPCAccessor.Instance.SendRequest(banAccountMessage, delegate(CommonOKMessage ok) { World.Instance.SendAnnounce(String.Format("Le joueur {0} a été banni.", target.Name), System.Drawing.Color.Red); }, delegate(IPCErrorMessage error) { trigger.ReplyError("Account {0} not banned : {1}", new object[] { target.Account.Login, error.Message }); }); if (!trigger.IsArgumentDefined("ip")) { break; } BanIPMessage message = new BanIPMessage { IPRange = target.Client.IP, BanReason = reason, BannerAccountId = banAccountMessage.BannerAccountId }; IPCAccessor.Instance.SendRequest(message, delegate(CommonOKMessage ok) { trigger.Reply("IP {0} banned", new object[] { target.Client.IP }); }, delegate(IPCErrorMessage error) { trigger.ReplyError("IP {0} not banned : {1}", new object[] { target.Client.IP, error.Message }); }); } } }
public override void Execute(TriggerBase trigger) { var reason = trigger.Get <string>("reason"); if (!IPCAccessor.Instance.IsConnected) { trigger.ReplyError("IPC service not operational !"); return; } foreach (var target in GetTargets(trigger)) { var message = new BanAccountMessage { AccountId = target.Account.Id, BanReason = reason, }; var source = trigger.GetSource() as WorldClient; if (source != null) { message.BannerAccountId = source.Account.Id; } if (trigger.IsArgumentDefined("time")) { var time = trigger.Get <int>("time"); if (time > 60 * 24 && trigger.UserRole == RoleEnum.GameMaster_Padawan) { // max ban time for padawan == 24h time = 60 * 24; } message.BanEndDate = DateTime.Now + TimeSpan.FromMinutes(time); } else if (trigger.IsArgumentDefined("life") && trigger.UserRole != RoleEnum.GameMaster_Padawan) { message.BanEndDate = null; } else { trigger.ReplyError("No ban duration given"); return; } message.Jailed = false; target.Client.Disconnect(); IPCAccessor.Instance.SendRequest(message, ok => trigger.Reply("Account {0} banned for {1} minutes. Reason : {2}", target.Account.Login, trigger.Get <int>("time"), reason), error => trigger.ReplyError("Account {0} not banned : {1}", target.Account.Login, error.Message)); if (!trigger.IsArgumentDefined("ip")) { return; } var banIPMessage = new BanIPMessage { IPRange = target.Client.IP, BanReason = reason, BanEndDate = message.BanEndDate, BannerAccountId = message.BannerAccountId }; IPCAccessor.Instance.SendRequest(banIPMessage, ok => trigger.Reply("IP {0} banned", target.Client.IP), error => trigger.ReplyError("IP {0} not banned : {1}", target.Client.IP, error.Message)); } }
public override void Execute(TriggerBase trigger) { string ip = trigger.Get <string>("ip"); string banReason = trigger.Get <string>("reason"); if (!IPCAccessor.Instance.IsConnected) { trigger.ReplyError("IPC service not operational !"); } else { try { IPAddressRange.Parse(ip); } catch { trigger.ReplyError("IP format '{0}' incorrect", new object[] { ip }); return; } BanIPMessage banIPMessage = new BanIPMessage { IPRange = ip, BanReason = banReason }; WorldClient worldClient = trigger.GetSource() as WorldClient; if (worldClient != null) { banIPMessage.BannerAccountId = new int?(worldClient.Account.Id); } if (trigger.IsArgumentDefined("time")) { banIPMessage.BanEndDate = new System.DateTime?(System.DateTime.Now + System.TimeSpan.FromMinutes((double)trigger.Get <int>("time"))); } else { if (!trigger.IsArgumentDefined("life")) { trigger.ReplyError("No ban duration given"); return; } banIPMessage.BanEndDate = null; } IPCAccessor.Instance.SendRequest(banIPMessage, delegate(CommonOKMessage ok) { trigger.Reply("IP {0} banned", new object[] { ip }); }, delegate(IPCErrorMessage error) { trigger.ReplyError("IP {0} not banned : {1}", new object[] { ip, error.Message }); }); } }