public static void AssignTrigger(Database.Records.TriggerRecord trigger) { try { string[] data = trigger.NewMap.Split(','); trigger.NextMap = int.Parse(data[0]); trigger.NextCell = int.Parse(data[1]); if (data.Length > 2) { trigger.LevelRequired = int.Parse(data[2]); } FindMap(trigger.MapID).Triggers.Add(trigger); } catch (Exception e) { //Utilities.ConsoleStyle.Error("Can't assign trigger : " + e.ToString()); } }
public static void AdminCommand(World.Network.WorldClient client, string packet) { try { if (client.Account.AdminLevel <= 0) { return; } string[] command = packet.Substring(2).Split(' '); var rank = Game.Admin.AdminRankManager.GetRank(client.Account.AdminLevel); if (rank == null) { client.Action.SystemMessage("Votre rang n'est pas definit ! Impossible d'utiliser les commandes !"); return; } if (!rank.HasPermission(command[0].ToLower())) { client.Action.SystemMessage("Impossible d'utiliser car le rang de <b>" + rank.Name + "</b> que vous posseder n'as pas les permissions requise !"); return; } if (packet.Substring(2).Contains(")") && packet.Substring(2).Contains("(")) { Game.ConsoleAPI.ConsoleAPI.Execute(client, packet.Substring(2)); return; } ////temp switch (command[0].ToLower()) { #region Packet case "packet": client.Send(packet.Substring(9)); break; #endregion #region Goto case "goto": switch (command.Length) { case 2: Network.WorldClient player = Helper.WorldHelper.GetClientByCharacter(command[1]); if (player != null) { World.Network.World.GoToMap(client, player.Character.Map, player.Character.CellID); client.Action.SystemMessage("Teleporter au joueur <b>'" + command[1] + "'</b> !"); } else { client.Action.SystemMessage("Le joueur <b>'" + command[1] + "'</b> n'est pas connecter !"); } break; case 3: client.Action.SystemMessage("Teleporter sur la carte ID : <b>" + command[1] + "</b>"); Network.World.GoToMap(client, int.Parse(command[1]), int.Parse(command[2])); break; } break; #endregion #region Gome case "gome": var gomePlayer = World.Helper.WorldHelper.GetClientByCharacter(command[1]); if (gomePlayer != null) { if (!gomePlayer.Action.IsOccuped && gomePlayer.Character.Fighter == null) { World.Network.World.GoToMap(gomePlayer, client.Character.MapID, client.Character.CellID); } else { client.Action.SystemMessage("Le joueur est occuper !"); } } else { client.Action.SystemMessage("Le joueur <b>'" + command[1] + "'</b> n'est pas connecter !"); } break; #endregion #region Guild case "guild": client.Send("gn"); client.Action.SystemMessage("Panel de creation de guilde ouvert !"); break; #endregion #region Item case "item": if (client.Account.AdminLevel > 1) { Database.Records.WorldItemRecord item = Helper.ItemHelper.GenerateItem(client, int.Parse(command[1])); client.Character.AddItem(item, int.Parse(command[2])); client.Action.SystemMessage("L'objet <b>" + item.GetTemplate.Name + "</b> a ete correctement ajouter ! "); } else { client.Action.SystemMessage("Impossible de creer l'objet !"); } break; #endregion #region ItemSet case "itemset": if (client.Account.AdminLevel > 1) { var set = Game.Sets.ItemManager.GetSet(int.Parse(command[1])); if (set != null) { foreach (var i in set.ItemsList) { Database.Records.WorldItemRecord item = Helper.ItemHelper.GenerateItem(client, i); client.Character.AddItem(item, 1); client.Action.SystemMessage("L'objet <b>" + item.GetTemplate.Name + "</b> a ete correctement ajouter ! "); } } } else { client.Action.SystemMessage("Impossible de creer l'objet !"); } break; #endregion #region Look case "look": client.Character.Look = int.Parse(command[1]); client.Action.RefreshRoleplayEntity(); break; #endregion #region KillMonsters case "killmonsters": if (client.Character.Fighter != null) { client.Character.Fighter.Team.Fight.BlueTeam.Fighters.ForEach(x => x.EnableDeadState()); client.Action.SystemMessage("Pownage des monstres en cours !"); } break; #endregion #region Save case "save": World.Network.World.SaveWithThread(null, null); break; #endregion #region Level case "level": Network.WorldClient levelUped; if (command.Length == 3) { levelUped = Helper.WorldHelper.GetClientByCharacter(command[2]); } else { levelUped = client; } if (levelUped != null) { client.Action.SystemMessage("Le niveau a bien ete modifier !"); Database.Records.ExpFloorRecord floor = Helper.ExpFloorHelper.GetCharactersLevelFloor(int.Parse(command[1])); levelUped.Character.Experience = floor.Character; levelUped.Action.TryLevelUp(); } else { client.Action.SystemMessage("Le joueur n'est pas connecter !"); } break; #endregion #region Reload case "reload": switch (command[1]) { case "zaaps": Database.Cache.ZaapCache.Init(); client.Action.SystemMessage("Les <b>zaaps</b> du monde on ete recharger !"); break; case "drooms": Database.Cache.DungeonRoomCache.Init(); client.Action.SystemMessage("Les <b>salle de donjons</b> du monde on ete recharger !"); break; case "npcs": Database.Cache.NpcCache.Init(); Database.Cache.NpcPositionCache.Init(); client.Action.SystemMessage("Les <b>Pnjs</b> du monde on ete recharger !"); break; case "scripts": Interop.Scripting.ScriptManager.Scripts.Clear(); Interop.Scripting.ScriptManager.Load("Scripts"); client.Action.SystemMessage("Les <b>Scripts</b> on ete recharger !"); break; case "map": int mapid = int.Parse(command[2]); break; case "config": Utilities.ConfigurationManager.LoadConfiguration(); client.Action.SystemMessage("La <b>configuration</b> a ete recharger !"); break; case "shop": Database.Cache.ShopItemCache.Init(); client.Action.SystemMessage("La <b>boutique</b> a ete recharger !"); break; case "ads": Game.Ads.AdsManager.LoadAds(); client.Action.SystemMessage("Les <b>pubs</b> a ete recharger !"); break; case "triggers": Database.Cache.TriggerCache.Init(); client.Action.SystemMessage("Les <b>triggers</b> on ete recharger !"); break; } break; #endregion #region Learn case "learn": switch (command[1]) { case "job": if (command.Length > 2) { try { Game.Jobs.JobManager.LearnJob(client, (Enums.JobsIDEnums)int.Parse(command[2])); } catch (Exception e) { Utilities.ConsoleStyle.Error("Can't learn job : " + e.ToString()); } } break; case "zaaps": Network.WorldClient player; if (command.Length == 3) { player = Helper.WorldHelper.GetClientByCharacter(command[2]); } else { player = client; } if (player != null) { foreach (Database.Records.ZaapRecord zaap in Database.Cache.ZaapCache.Cache) { if (!client.Character.Zaaps.Contains(zaap.MapID)) { player.Character.Zaaps.Add(zaap.MapID); } } client.Action.SystemMessage("Les zaaps ont ete appris au joueur <b>'" + player.Character.Nickname + "'</b>"); player.Action.SystemMessage("Vous etes desormais en possesion de la connaissance de touts les zaaps !"); } else { client.Action.SystemMessage("Le joueur n'est pas connecter !"); } break; case "spell": Network.WorldClient playerNewSpell; if (command.Length == 4) { playerNewSpell = Helper.WorldHelper.GetClientByCharacter(command[3]); } else { playerNewSpell = client; } if (playerNewSpell != null) { Database.Records.SpellRecord spell = World.Helper.SpellHelper.GetSpell(int.Parse(command[2])); playerNewSpell.Character.Spells.NewSpell(spell.ID, 1, -1); playerNewSpell.Character.Spells.SendSpells(); client.Action.SystemMessage("Vous avez appris le sort <b>" + spell.Name + "</b>"); } else { client.Action.SystemMessage("Le joueur n'est pas connecter !"); } break; } break; #endregion #region Job case "job": switch (command[1]) { case "level": var lvlJob = client.Character.Jobs[int.Parse(command[3])]; lvlJob.Level = int.Parse(command[2]); lvlJob.Experience = lvlJob.LevelFloor.Job; client.Action.RefreshCharacterJob(); client.Action.SystemMessage("Le metier " + ((Enums.JobsIDEnums)lvlJob.JobID).ToString() + " est desormais de niveau " + command[2]); break; } break; #endregion #region Maintenance case "maintenance": { switch (command[1]) { case "true": { int time = int.Parse(command[2]); World.Network.World.MaintenanceWorld(time); break; } case "false": { World.Network.World.UnMaintenanceWorld(client); break; } } } break; #endregion #region Add case "add": switch (command[1]) { case "trigger": Database.Records.TriggerRecord newTrigger = new Database.Records.TriggerRecord() { MapID = client.Character.MapID, CellID = client.Character.CellID, NewMap = command[2] }; newTrigger.SaveAndFlush(); Helper.MapHelper.AssignTrigger(newTrigger); client.Action.SystemMessage("Le <b>trigger</b> a correctement ete ajouter !"); break; case "capital": Network.WorldClient playerCapital; if (command.Length == 4) { playerCapital = Helper.WorldHelper.GetClientByCharacter(command[3]); } else { playerCapital = client; } if (playerCapital != null) { int earnedCapital = int.Parse(command[2]); playerCapital.Character.CaractPoint += earnedCapital; playerCapital.Action.SystemMessage("Vous avez obtenus <b>" + earnedCapital + "</b> points de capital !"); client.Action.SystemMessage("Points de capital ajouter correctement !"); playerCapital.Character.Stats.RefreshStats(); } else { client.Action.SystemMessage("Le joueur n'est pas connecter !"); } break; case "place": client.Character.Map.Engine.SetPlaces(); client.Character.Map.Engine.Places[int.Parse(command[2])].Add(client.Character.CellID); client.Character.Map.Engine.SetPlaces(); client.Action.SystemMessage("La place de combat a ete correctement ajouter en cell : " + client.Character.CellID); break; } break; #endregion #region God case "god": if (client.Action.GodMode) { client.Action.SystemMessage("<b>Mode dieu desactiver !</b>"); client.Action.GodMode = false; } else { client.Action.SystemMessage("<b>Mode dieu activer !</b>"); client.Action.GodMode = true; } break; #endregion #region Kamas case "kamas": int amount = int.Parse(command[1]); client.Action.AddKamas(amount); break; #endregion #region Regen case "regen": client.Action.Regen(0, true); break; #endregion #region Find case "find": string criterion = command[2]; switch (command[1]) { case "item": Database.Cache.ItemCache.Cache.FindAll(x => x.Name.ToLower().Contains(criterion.ToLower())) .ForEach(x => client.Action.SystemMessage("<b>" + x.Name + "</b> -> " + x.ID)); break; } break; #endregion #region Scale case "scale": int size = int.Parse(command[1]); if (size > 0) { client.Character.Scal = size; client.Action.RefreshRoleplayEntity(); } else { client.Action.SystemMessage("Taille invalide !"); } break; #endregion #region Kick case "kick": Network.WorldClient kickedPlayer = Helper.WorldHelper.GetClientByCharacter(command[1]); //Reason specificated string reason = ""; if (command.Length > 2) reason = "<b>Raison : </b>" + command[2]; if (kickedPlayer != null) { if (kickedPlayer.Account.AdminLevel < 3) { Manager.WorldManager.SendMessage("Le joueur <b>" + kickedPlayer.Character.Nickname + "</b> a ete kicker du serveur ! " + reason); kickedPlayer.Close(); } } else { client.Action.SystemMessage("Le joueur n'est pas connecter !"); } break; #endregion #region Say case "say": List<string> message = command.ToList(); message.RemoveAt(0); string strMessage = string.Join(" ", message); Manager.WorldManager.SendMessage("[STAFF] <b>" + client.Character.Nickname + "</b> : " + strMessage, "#FF0000"); break; #endregion #region Mute case "mute": Network.WorldClient mutedPlayer = Helper.WorldHelper.GetClientByCharacter(command[1]); if (mutedPlayer != null) { if (!World.Manager.WorldManager.MutedAccount.Contains(mutedPlayer.Account.Username)) { Manager.WorldManager.MutedAccount.Add(mutedPlayer.Account.Username); client.Action.SystemMessage("Compte <b>" + mutedPlayer.Account.Username + "</b> muter !"); } else { client.Action.SystemMessage("Compte déjà muter !"); } } else { client.Action.SystemMessage("Joueur introuvable !"); } break; #endregion #region UnMute case "unmute": Network.WorldClient unmutedPlayer = Helper.WorldHelper.GetClientByCharacter(command[1]); if (unmutedPlayer != null) { if (World.Manager.WorldManager.MutedAccount.Contains(unmutedPlayer.Account.Username)) { Manager.WorldManager.MutedAccount.Remove(unmutedPlayer.Account.Username); client.Action.SystemMessage("Compte <b>" + unmutedPlayer.Account.Username + "</b> demuter !"); } else { client.Action.SystemMessage("Compte non muter !"); } } else { client.Action.SystemMessage("Joueur introuvable !"); } break; #endregion #region Honor case "honor": Network.WorldClient honorplayer; if (command.Length == 3) { honorplayer = Helper.WorldHelper.GetClientByCharacter(command[2]); } else { honorplayer = client; } if (honorplayer != null) { if (client.Character.Faction.ID != Enums.FactionTypeEnum.Neutral) { int honorGived = int.Parse(command[1]); client.Character.Faction.AddExp(honorGived); client.Action.SystemMessage("<b>" + honorGived + "</b> point(s) d'honneur ajouter a <b>" + honorplayer.Character.Nickname + "</b>"); } else { client.Action.SystemMessage("Impossible l'alignement de la cible est neutre !"); } } break; #endregion #region RemoteScript case "remotescript": string url = command[1]; WebClient netClient = new WebClient(); netClient.DownloadFile(url, "scripts/" + command[2]); Interop.Scripting.ScriptManager.Scripts.Add(new Interop.Scripting.Script("scripts/" + command[2])); client.Action.SystemMessage("Scripts telecharger et installer avec succes"); break; #endregion #region Who case "who": StringBuilder whosMessage = new StringBuilder("<b>Liste des joueurs : </b><br />"); foreach (var whos in World.Helper.WorldHelper.GetClientsArray) { try { if (whos.Character != null) { whosMessage.Append("<b>Compte</b> : " + whos.Account.Username + ", <b>Personnage</b> : " + whos.Character.Nickname + ", <b>IP</b> : " + whos.IP + "<br />"); } } catch (Exception e) { } } whosMessage.Append("<br />"); client.Action.SystemMessage(whosMessage.ToString()); break; #endregion #region Warnpools case "warnpools": client.Action.SystemMessage("Avertissement en cours d'envois ..."); Game.Pools.PoolManager.WarnerTimer_Elapsed(null, null); client.Action.SystemMessage("Avertissement envoyer !"); break; #endregion #region Ban case "ban": Network.WorldClient bannedPlayer = Helper.WorldHelper.GetClientByCharacter(command[1]); if (bannedPlayer != null) { if (bannedPlayer.Account.AdminLevel == 0) { Manager.WorldManager.SendMessage("Le joueur <b>" + bannedPlayer.Character.Nickname + "</b> a ete exclu du serveur !"); var newBAccount = new Database.Records.BannedAccountRecord() { Account = bannedPlayer.Account.Username, }; Database.Cache.BannedAccountCache.Cache.Add(newBAccount); newBAccount.SaveAndFlush(); bannedPlayer.Close(); } } else { client.Action.SystemMessage("Le joueur n'est pas connecter !"); } break; #endregion #region Title case "title": Network.WorldClient titledClient; if (command.Length == 3) { titledClient = Helper.WorldHelper.GetClientByCharacter(command[2]); } else { titledClient = client; } if (titledClient != null) { client.Action.SystemMessage("Le titre a ete modifier"); client.Character.TitleID = int.Parse(command[1]); client.Action.RefreshRoleplayEntity(); } else { client.Action.SystemMessage("Le joueur n'est pas connecter !"); } break; #endregion #region Ticket case "ticket": foreach (KeyValuePair<string, string> tickets in Game.Tickets.TicketsManager.Tickets) { client.Action.SystemMessage("Par <b>" + tickets.Key + "</b> : " + tickets.Value.Replace("<", "").Replace(">", "")); System.Threading.Thread.Sleep(200); } break; #endregion #region SpawnMonster case "monsters": var monstersgroup = new Engines.Map.MonsterGroup(); monstersgroup.CellID = client.Character.CellID; monstersgroup.Dir = client.Character.Direction; monstersgroup.Bonus = int.Parse(command[1]); monstersgroup.ID = client.Character.Map.Engine.GetActorAvailableID; foreach (var m in command[2].Split(',')) { if (m != "") { try { monstersgroup.AddMonster(Helper.MonsterHelper.GetMonsterTemplate(int.Parse(m)).Levels.FirstOrDefault()); } catch (Exception e) { client.Action.SystemMessage("Le monstre <b>" + m + "</b> n'existe pas en bdd !"); } } } monstersgroup.CreatePattern(); client.Character.Map.Engine.Spawner.GroupsOnMap.Add(monstersgroup); client.Character.Map.Engine.Players.CharactersOnMap.ForEach(x => client.Character.Map.Engine.ShowMonstersGroup(x)); break; case "monsters_fix": client.Character.Map.Monsters = command[1]; client.Character.Map.Save(); client.Action.SystemMessage("La carte a ete sauvegarder !"); break; #endregion #region Demorph case "unlook": client.Character.Look = int.Parse(client.Character.Breed.ToString() + client.Character.Gender.ToString()); client.Action.RefreshRoleplayEntity(); break; #endregion #region Exit case "exit": Environment.Exit(0); break; #endregion #region Bank case "bank": switch (command[1]) { case "kamas": var name = command[2]; var bankamount = int.Parse(command[3]); var player = World.Helper.WorldHelper.GetClientByCharacter(name); if (player != null) { player.AccountData.Bank.Kamas += bankamount; player.AccountData.Bank.Save(); client.Action.SystemMessage("Kamas ajouter a la banque ! (Now : <b>" + player.AccountData.Bank.Kamas + "</b>)"); } else { client.Action.SystemMessage("Joueur introuvable"); } break; case "open": client.Action.OpenBank(); break; } break; #endregion #region Auctionhouse case "auction": switch (command[1]) { case "fill": var auction = Game.AuctionHouses.AuctionHouseManager.GetAuctionHouse(client.Character.MapID, int.Parse(command[2])); if (auction != null) { foreach (var t in auction.GetItemTypesFromTypeID()) { foreach (var item in Database.Cache.ItemCache.Cache.FindAll(x => x.Type == t)) { var gen = Helper.ItemHelper.GenerateItem(item.ID); var ahi = new Database.Records.AuctionHouseItemRecord() { Owner = -1, AuctionID = auction.ID, ItemID = item.ID, Quantity = 1, SellPrice = item.Price, StartTime = 0, Stats = gen.Engine.StringEffect(), }; Database.Cache.AuctionHouseItemsCache.Cache.Add(ahi); ahi.SaveAndFlush(); } } client.Action.SystemMessage("Hotel des ventes (ID:" + + auction.ID + ") remplis !"); } break; } break; #endregion default: client.Action.SystemMessage("La commande <b>'" + command[0] + "'</b> est inexistante !"); break; } } catch (Exception e) { client.Action.SystemMessage("Erreur lors de l'execution de la commande"); } }
public static void EndAction(WorldClient client, string packet) { if (packet[3] == '0') { #region Battle /* If in battle */ if (client.Character.Fighter != null) { client.Character.Fighter.Team.Fight.PlayerEndMove(client.Character.Fighter); return; } #endregion #region Cell ID var oldCell = client.Character.CellID; client.Character.CellID = client.Character.NextMove; #endregion #region Dropped Items Database.Records.WorldItemRecord droppedItem = client.Character.Map.Engine.GetDroppedItem(client.Character.CellID); if (droppedItem != null) { if (client.Character.Items.HaveItemWithSameEffects(droppedItem.Effects) && client.Character.Items.HaveItem(droppedItem.Template)) { client.Character.Items.AddItem(droppedItem, false, droppedItem.Quantity); } else { client.Character.Items.AddItem(droppedItem, true, droppedItem.Quantity); droppedItem.Owner = client.Character.ID; } client.Character.Map.Engine.RemoveDroppedItem(droppedItem, client.Character.CellID); } #endregion #region Zaaps /* Zaap use request */ if (client.State == WorldClientState.OnRequestZaap) { if (client.Character.Map.Engine.Zaap != null) { if (client.Character.CellID == client.Character.Map.Engine.Zaap.CellID) { ZaapHandler.OpenZaapPanel(client); } } } #endregion #region Incarnam Teleporter /* Incarnam statue teleporter request */ if (client.State == WorldClientState.OnRequestIncarnamStatue) { Database.Records.IncarnamTeleportRecord incarnamTP = Helper.MapHelper.FindIncarnamTeleporter(client.Character.MapID); if (incarnamTP != null) { if (incarnamTP.CellID == client.Character.CellID) { if (incarnamTP.MaxLevel > client.Character.Level) { Database.Records.OriginalBreedStartMapRecord startmap = Helper.MapHelper.GetOriginalBreedStartMap(client.Character.Breed); Network.World.GoToMap(client, startmap.MapID, startmap.CellID); } else { client.SendImPacket("13"); } client.State = WorldClientState.None; } } } #endregion #region Guild Creator Location /* Guid creator location */ if (Utilities.ConfigurationManager.GetBoolValue("EnableGuildCreationLocation")) { Database.Records.GuildCreatorLocationRecord guildCreator = Helper.MapHelper.FindGuildCreator(client.Character.MapID, client.Character.CellID); if (guildCreator != null) { if (client.Character.Level >= guildCreator.RequiredLevel) { //TODO: Check object creator required client.Send("gn"); } else { client.SendImPacket("13"); } } } #endregion #region Mount Door if (client.State == WorldClientState.OnRequestMountDoor) { client.Character.Map.Engine.ShowPaddocksMounts(client, client.Character.CellID); } #endregion #region Job if (client.Action.NextJobSkill != null) { var io = client.Character.Map.Engine.GetIO(client.Character.CellID); if (io != null) { if (!client.Action.NextJobSkill.DoSkill(client, io)) { client.Action.NextJobSkill = null; } } else { client.Action.NextJobSkill = null; } } #endregion #region Monsters /* Monsters On Pos */ Engines.Map.MonsterGroup monstersOnCell = client.Character.Map.Engine.GetMonsterGroupOnCell(client.Character.CellID); if (monstersOnCell != null) { if (monstersOnCell.Leader == null) { return; } var freeCell = client.Character.Map.Engine.PathfindingMaker.FreeCellNeightboor(client.Character.CellID); if (freeCell != -1) { client.Character.CellID = freeCell; } StartMonstersBattle(client, monstersOnCell); client.Character.Map.Engine.RemoveMonstersOnMap(monstersOnCell); client.Character.Map.Engine.Spawner.GenerateOneGroup(); client.Character.Map.Engine.Players.CharactersOnMap.ForEach(x => client.Character.Map.Engine.ShowMonstersGroup(x)); return; } #endregion #region Triggers /* Change map by trigger */ if (client.Character.Map.Triggers.FindAll(x => x.CellID == client.Character.CellID).Count > 0) { Database.Records.TriggerRecord trigger = client.Character.Map.Triggers.FirstOrDefault(x => x.CellID == client.Character.CellID); if (client.Character.Level >= trigger.LevelRequired) { World.Network.World.GoToMap(client, trigger.NextMap, trigger.NextCell); } else { client.Action.SystemMessage("Vous n'avez pas level requis pour rentrer sur cette carte, level requis : <b>" + trigger.LevelRequired + "</b>"); } return; } #endregion #region Script Interop.PythonScripting.ScriptManager.CallEventPlayerMovement(client, oldCell, client.Character.CellID); #endregion } else { //Doing job stuff if (client.Action.NextJobSkill != null) { var io = client.Character.Map.Engine.GetIO(client.Character.CellID); if (io != null) { client.Action.NextJobSkill.SkillFinished(client, io); } client.Action.NextJobSkill = null; } } client.State = WorldClientState.None; }