Exemplo n.º 1
0
            static bool OnGuildInvite(LoginClient client, CMSG msgID, BinReader data)
            {
                DBGuild guild = client.Character.Guild;

                if (guild == null || client.Character.GuildID == 0)
                {
                    SendResult(client, 2, " ", (int)GUILDRESULT.NOT_IN_GUILD);
                    return(true);
                }

                if ((guild.getRankFlags(client.Character.GuildRank) & (uint)GUILDFLAGS.INVITE) != (uint)GUILDFLAGS.INVITE)
                {
                    SendResult(client, 1, " ", (int)GUILDRESULT.PERMISSIONS);
                    ; return(true);
                }

                string name = data.ReadString();

                DBCharacter character = (DBCharacter)DataServer.Database.FindObjectByKey(typeof(DBCharacter), name.ToLower());

                if (character == null)
                {
                    SendResult(client, 1, name, (int)GUILDRESULT.NOT_FOUND);
                }

                else
                {
                    LoginClient targetClient = LoginServer.GetLoginClientByCharacterID(character.ObjectId);
                    if (targetClient != null)
                    {
//						targetClient.Character.LastGuildID=client.Character.GuildID;
                        if (targetClient.Character.LastGuildInviterID != 0)
                        {
                            SendResult(client, 1, name, (int)GUILDRESULT.ALREADY_INVITED_TO_GUILD_S);
                            return(true);
                        }

                        if (targetClient.Character.GuildID != 0)
                        {
                            SendResult(client, 1, targetClient.Character.Name, (int)GUILDRESULT.ALREADY_IN_GUILD_S);
                            return(true);
                        }

                        targetClient.Character.LastGuildInviterID = client.Character.ObjectId;

                        BinWriter gpkg = LoginClient.NewPacket(SMSG.GUILD_INVITE);
                        gpkg.Write(client.Character.Name);
                        gpkg.Write(guild.Name);
                        targetClient.Send(gpkg);
                        SendResult(client, 1, name, (int)GUILDRESULT.SUCCESS);
                    }
                    else
                    {
                        Chat.System(client, name + " is not currently online");
                    }
                }

                return(true);
            }            //OnGuildInvite
Exemplo n.º 2
0
            static bool OnGuildRemove(LoginClient client, CMSG msgID, BinReader data)
            {
                DBGuild guild = client.Character.Guild;

                if (guild == null || client.Character.GuildID == 0)
                {
                    SendResult(client, 2, " ", (int)GUILDRESULT.NOT_IN_GUILD);
                    return(true);
                }

                if ((guild.getRankFlags(client.Character.GuildRank) & (uint)GUILDFLAGS.DEMOTE) != (uint)GUILDFLAGS.DEMOTE)
                {
                    SendResult(client, 1, " ", (int)GUILDRESULT.PERMISSIONS);
                    ; return(true);
                }

                string name = data.ReadString();

                DBCharacter tChar = (DBCharacter)DataServer.Database.FindObjectByKey(typeof(DBCharacter), name.ToLower());

                if (tChar == null)
                {
                    SendResult(client, 1, name, (int)GUILDRESULT.NOT_FOUND);
                    return(true);
                }

                else if (client.Character.GuildID != tChar.GuildID)
                {
                    SendResult(client, 1, name, (int)GUILDRESULT.NOT_IN_GUILD_S);
                    return(true);
                }
                //		2					1
                if (tChar.GuildRank <= client.Character.GuildRank)
                {
                    SendResult(client, 1, name, (int)GUILDRESULT.RANK_TO_HIGH);
                    return(true);
                }

                DBGuildMembers member = (DBGuildMembers)DataServer.Database.FindObjectByKey(typeof(DBGuildMembers), tChar.ObjectId);

                if (member == null || member.GuildID != client.Character.GuildID)
                {
                    SendResult(client, 1, name, (int)GUILDRESULT.NOT_IN_GUILD_S);
                    return(true);
                }
                if (RemoveMember(member, client))
                {
                    Chat.System(client, "You have removed " + tChar.Name + " from the guild");
                }
                else
                {
                    SendResult(client, 1, name, (int)GUILDRESULT.INTERNAL);
                }
                return(true);
            }            //OnGuildRemove
Exemplo n.º 3
0
            static bool OnGuildDemote(LoginClient client, CMSG msgID, BinReader data)
            {
                DBGuild guild = client.Character.Guild;

                if (guild == null || client.Character.GuildID == 0)
                {
                    SendResult(client, 2, " ", (int)GUILDRESULT.NOT_IN_GUILD);
                    return(true);
                }

                if ((guild.getRankFlags(client.Character.GuildRank) & (uint)GUILDFLAGS.DEMOTE) != (uint)GUILDFLAGS.DEMOTE)
                {
                    SendResult(client, 1, " ", (int)GUILDRESULT.PERMISSIONS);
                    ; return(true);
                }

                string name = data.ReadString();

                DBCharacter tChar = (DBCharacter)DataServer.Database.FindObjectByKey(typeof(DBCharacter), name.ToLower());

                if (tChar == null)
                {
                    SendResult(client, 1, name, (int)GUILDRESULT.NOT_FOUND);
                    return(true);
                }

                else if (client.Character.GuildID != tChar.GuildID)
                {
                    SendResult(client, 1, name, (int)GUILDRESULT.NOT_IN_GUILD_S);
                    return(true);
                }
                //		2					1
                if (tChar.GuildRank <= client.Character.GuildRank)
                {
                    SendResult(client, 1, name, (int)GUILDRESULT.RANK_TO_HIGH);
                    return(true);
                }
                else if (tChar.GuildRank >= guild.MaxRank)
                {
                    SendResult(client, 1, name, (int)GUILDRESULT.RANK_TO_LOW);
                    return(true);
                }

                DBGuildMembers tMember = (DBGuildMembers)DataServer.Database.FindObjectByKey(typeof(DBGuildMembers), tChar.ObjectId);

                if (tMember != null)
                {
                    tChar.GuildRank++;
                }
                tMember.Rank++;
                SendToWorld(client, tChar);
                GuildMessage(guild, tChar.Name + "has been demoted to the rank of " + guild.getRankName(tChar.GuildRank) + " by " + client.Character.Name);
                SendRoster(client, guild);
                return(true);
            }            //OnGuildDemote
Exemplo n.º 4
0
            static bool OnGuildMOTD(LoginClient client, CMSG msgID, BinReader data)
            {
                DBGuild tguild = client.Character.Guild;

                if ((tguild.getRankFlags(client.Character.GuildRank) & (uint)GUILDFLAGS.SET_MOTD) != (uint)GUILDFLAGS.SET_MOTD)
                {
                    SendResult(client, 1, " ", (int)GUILDRESULT.PERMISSIONS);
                    ; return(true);
                }

                tguild.MOTD = data.ReadString();
                DataServer.Database.SaveObject(tguild);
                SendRoster(client, tguild);
                GuildMessage(tguild, "MOTD: " + tguild.MOTD);
                return(true);
            }             //OnGuildRoster
Exemplo n.º 5
0
        public static void SendRoster(LoginClient client, DBGuild tGuild)
        {
            BinWriter pkg = LoginClient.NewPacket(SMSG.GUILD_ROSTER);

            pkg.Write((int)tGuild.Members.Length);
            pkg.Write((string)tGuild.MOTD);                                     //Guild.MOTD);
            pkg.Write((uint)tGuild.MaxRank + 1);                                //# of ranks
            for (uint i = 0; i < tGuild.MaxRank + 1; i++)
            {
                pkg.Write((uint)tGuild.getRankFlags(i));                        //Rank Flags for each rank
            }
            foreach (DBGuildMembers member in tGuild.Members)
            {
                DataServer.Database.FillObjectRelations(member);
                pkg.Write((ulong)member.MemberID);                //((LoginClient)e.Current).Character.Race);
                bool online = false;
                if (LoginServer.GetLoginClientByCharacterID(member.MemberID) != null)
                {
                    online = true;
                }
                pkg.Write((bool)online);                    //Online? 0-no/1-yes
                pkg.Write((string)member.Character.Name);   //Name
                pkg.Write((int)member.Character.GuildRank); //Rank
                pkg.Write((byte)member.Character.Level);    //Level
                pkg.Write((byte)member.Character.Class);    //Class((LoginClient)e.Current).Character.Level);
                pkg.Write((uint)member.Character.Zone);     //Zone
                if (online)
                {
                    pkg.Write((byte)member.Character.GroupLook);                        // Group (0-No/1-Yes) Only if online
                }
                else
                {
                    pkg.Write((uint)member.Character.GuildTimeStamp);                           // GuildTimeStamp
                }
                pkg.Write((string)(member.Note == null?" ":member.Note));                       //Player Note
                pkg.Write((string)(member.Note == null?" ":member.OfficerNote));                //Officer's Note
            }
            client.Send(pkg);
            return;
        } //SendRoster
Exemplo n.º 6
0
        static bool OnMessageChat(LoginClient client, CMSG msgID, BinReader data)
        {
            CHATMESSAGETYPE type = (CHATMESSAGETYPE)data.ReadInt32();

            /*int language =*/ data.ReadInt32();
            string target = string.Empty;

            if (type == CHATMESSAGETYPE.WHISPER)
            {
                target = data.ReadString(0x100);
            }
            string msg = data.ReadString(0x100);

            if (msg.StartsWith("!") || msg.StartsWith("%"))
            {
                return(OnChatCommand(client, msg.Substring(1)));
            }
            switch (type)
            {
            case CHATMESSAGETYPE.PARTY:
            case CHATMESSAGETYPE.CHANNEL:
            case CHATMESSAGETYPE.CHANNEL_JOIN:
            case CHATMESSAGETYPE.CHANNEL_LEAVE:
            case CHATMESSAGETYPE.CHANNEL_LIST:
            case CHATMESSAGETYPE.CHANNEL_NOTICE:
            case CHATMESSAGETYPE.CHANNEL_NOTICE_USER:
            case CHATMESSAGETYPE.SAY:
            case CHATMESSAGETYPE.YELL:
            case CHATMESSAGETYPE.EMOTE:
                return(false);                        // let worldserver handle it

            case CHATMESSAGETYPE.WHISPER:
            {
                DataObject[] objs = DataServer.Database.SelectObjects(typeof(DBCharacter), "Name = '" + target + "'");
                if (objs.Length == 0)
                {
                    Chat.System(client, "No such player.");
                    return(true);
                }
                LoginClient targetClient = LoginServer.GetLoginClientByCharacterID(objs[0].ObjectId);
                if (targetClient == null || targetClient.Character == null)
                {
                    Chat.System(client, "That player is not online.");
                    return(true);
                }
                Chat.Whisper(client, targetClient, msg);
                break;
            }

            case CHATMESSAGETYPE.GUILD:
            {
                DBGuild guild = client.Character.Guild;
                if (guild == null)
                {
                    return(true);
                }
                if ((guild.getRankFlags(client.Character.GuildRank) & (uint)GUILDFLAGS.SAY) == (uint)GUILDFLAGS.SAY)
                {
                    foreach (DBGuildMembers member in guild.Members)
                    {
                        if ((guild.getRankFlags(member.Rank) & (uint)GUILDFLAGS.LISTEN) == (uint)GUILDFLAGS.LISTEN)
                        {
                            LoginClient targetClient = LoginServer.GetLoginClientByCharacterID(member.MemberID);
                            if (targetClient == null || targetClient.Character == null)
                            {
                                continue;
                            }
                            else
                            {
                                Chat.GuildSay(client.Character.ObjectId, targetClient, msg, CHATMESSAGETYPE.GUILD);
                            }
                        }
                    }
                }
                else
                {
                    Chat.GuildSay(0, client, "You do not have permission", CHATMESSAGETYPE.GUILD);
                }

                break;
            }

            case CHATMESSAGETYPE.OFFICER:
            {
                DBGuild guild = client.Character.Guild;
                if (guild == null)
                {
                    return(true);
                }
                if ((guild.getRankFlags(client.Character.GuildRank) & (uint)GUILDFLAGS.OFFICER_SAY) == (uint)GUILDFLAGS.OFFICER_SAY)
                {
                    foreach (DBGuildMembers member in guild.Members)
                    {
                        if ((guild.getRankFlags(member.Rank) & (uint)GUILDFLAGS.OFFICER_LISTEN) == (uint)GUILDFLAGS.OFFICER_LISTEN)
                        {
                            LoginClient targetClient = LoginServer.GetLoginClientByCharacterID(member.MemberID);
                            if (targetClient == null || targetClient.Character == null)
                            {
                                continue;
                            }
                            else
                            {
                                Chat.GuildSay(client.Character.ObjectId, targetClient, msg, CHATMESSAGETYPE.OFFICER);
                            }
                        }
                    }
                }
                else
                {
                    Chat.GuildSay(0, client, "You do not have permission", CHATMESSAGETYPE.GUILD);
                }

                break;
            }

            default:
                Chat.System(client, "Received " + type + ": " + msg);
                break;
            }
            return(true);
        }