Beispiel #1
0
        private void guildname(GameClient client, GameObject target, string[] args)
        {
            if (args.Length < 4)
            {
                DisplaySyntax(client, args[1]);
                return;
            }

            if (target is GameStaticItem)
            {
                client.Out.SendMessage("GameStaticObjects don't have a guild name!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return;
            }

            if (target is GameNPC)
            {
                if (target is GameKeepGuard)
                {
                    client.Out.SendMessage("You cannot translate the guild name of a GameKeepGuard!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                    return;
                }

                if (target is GameMovingObject)
                {
                    client.Out.SendMessage("GameMovingObjects don't have a guild name!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                    return;
                }

                // Not sure if we should allow (or not) guild name translations for GamePets.

                GameNPC npc = (GameNPC)target;
                if (Util.IsEmpty(npc.TranslationId))
                {
                    client.Out.SendMessage("Your target doesn't have a translation id, please use '/mob translationid <translation id>' first.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                    return;
                }

                DBLanguageNPC result = GameServer.Database.SelectObject<DBLanguageNPC>("TranslationId = '" + GameServer.Database.Escape(npc.TranslationId) +
                                                                                       "' and Language = '" + args[2].ToUpper() + "'");
                if (result != null)
                    GameServer.Database.DeleteObject(result);
                else
                {
                    result = new DBLanguageNPC();
                    result.TranslationId = npc.TranslationId;
                    result.Name = string.Empty;
                    result.Suffix = string.Empty;
                    result.ExamineArticle = string.Empty;
                    result.MessageArticle = string.Empty;
                    result.Language = args[2].ToUpper();
                }

                if (args.Length > 4)
                    result.GuildName = string.Join(" ", args, 3, args.Length - 3);
                else
                    result.GuildName = args[3];

                GameServer.Database.AddObject(result);

                if (!(npc is GameMovingObject) && !(npc is GamePet) && client.Account.Language.ToUpper() == args[2].ToUpper())
                {
                    npc.RemoveFromWorld();
                    GameNPC.RefreshTranslation(args[2].ToUpper(), result.TranslationId);
                    npc.AddToWorld();
                }
                else
                    GameNPC.RefreshTranslation(args[2].ToUpper(), result.TranslationId);

                client.Out.SendMessage("Guild name for language '" + args[2].ToUpper() + "' changed to: " + result.GuildName, eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return;
            }

            DisplaySyntax(client, args[1]);
        }
Beispiel #2
0
        private void messagearticle(GameClient client, GameObject target, string[] args)
        {
            if (args.Length < 4)
            {
                DisplaySyntax(client, args[1]);
                return;
            }

            if (target is GameStaticItem)
            {
                client.Out.SendMessage("Not supported yet.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return;
            }

            if (target is GameNPC)
            {
                GameNPC npc = (GameNPC)target;
                if (Util.IsEmpty(npc.TranslationId))
                {
                    client.Out.SendMessage("Your target doesn't have a translation id, please use '/mob translationid <translation id>' first.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                    return;
                }

                DBLanguageNPC result = GameServer.Database.SelectObject<DBLanguageNPC>("TranslationId = '" + GameServer.Database.Escape(npc.TranslationId) +
                                                                                       "' and Language = '" + args[2].ToUpper() + "'");
                if (result != null)
                    GameServer.Database.DeleteObject(result);
                else
                {
                    result = new DBLanguageNPC();
                    result.TranslationId = npc.TranslationId;
                    result.Name = string.Empty;
                    result.Suffix = string.Empty;
                    result.GuildName = string.Empty;
                    result.ExamineArticle = string.Empty;
                    result.Language = args[2].ToUpper();
                }

                if (args.Length > 4)
                    result.MessageArticle = string.Join(" ", args, 3, args.Length - 3);
                else
                    result.MessageArticle = args[3];

                GameServer.Database.AddObject(result);
                GameNPC.RefreshTranslation(args[2].ToUpper(), result.TranslationId);
                client.Out.SendMessage("Message article for language '" + args[2].ToUpper() + "' changed to: " + result.MessageArticle, eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return;
            }

            DisplaySyntax(client, args[1]);
        }
Beispiel #3
0
        public static DBLanguageNPC GetTranslation(string lang, GameNPC npc)
        {
            DBLanguageNPC result = null;

            if (npc == null)
            {
                result = new DBLanguageNPC();
                result.Name = "NoTranslation";
                return result;
            }

            string id = string.Empty;

            lock (npc.TranslationId)
                id = npc.TranslationId;

            if (!Util.IsEmpty(id) && !Util.IsEmpty(lang) && !lang.ToLower().Equals(ServerProperties.Properties.SERV_LANGUAGE.ToLower()))
            {
                lock (m_nameTranslations)
                {
                    if (m_nameTranslations.ContainsKey(lang))
                    {
                        if (m_nameTranslations[lang].ContainsKey(id))
                            result = m_nameTranslations[lang][id];
                    }
                }
            }

            if (result != null)
            {
                if (Util.IsEmpty(result.Name))
                    result.Name = npc.Name; // Get sure we have a name. Doesn't matter when we set it to default because it's not saved.
            }
            else
            {
                result = new DBLanguageNPC();

                result.TranslationId = npc.TranslationId;
                result.Name = npc.Name;
                result.Suffix = npc.Suffix;
                result.GuildName = npc.GuildName;
                result.ExamineArticle = npc.ExamineArticle;
                result.MessageArticle = npc.MessageArticle;
            }

            return result;
        }