当前位置: 首页>>代码示例>>C#>>正文


C# Server.SendMessageToAll方法代码示例

本文整理汇总了C#中Server.SendMessageToAll方法的典型用法代码示例。如果您正苦于以下问题:C# Server.SendMessageToAll方法的具体用法?C# Server.SendMessageToAll怎么用?C# Server.SendMessageToAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Server的用法示例。


在下文中一共展示了Server.SendMessageToAll方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Ban

 public bool Ban(Server server, int sourceClientId, int targetClientId, string reason)
 {
     if (!server.PlayerHasPrivilege(sourceClientId, ServerClientMisc.Privilege.ban))
     {
         server.SendMessage(sourceClientId, string.Format(server.language.Get("Server_CommandInsufficientPrivileges"), server.colorError));
         return false;
     }
     if (!reason.Equals(""))
     {
         reason = server.language.Get("Server_CommandKickBanReason") + reason + ".";
     }
     ClientOnServer targetClient = server.GetClient(targetClientId);
     if (targetClient != null)
     {
         if (targetClient.clientGroup.IsSuperior(server.GetClient(sourceClientId).clientGroup) || targetClient.clientGroup.EqualLevel(server.GetClient(sourceClientId).clientGroup))
         {
             server.SendMessage(sourceClientId, string.Format(server.language.Get("Server_CommandTargetUserSuperior"), server.colorError));
             return false;
         }
         string targetName = targetClient.playername;
         string sourceName = server.GetClient(sourceClientId).playername;
         string targetNameColored = targetClient.ColoredPlayername(server.colorImportant);
         string sourceNameColored = server.GetClient(sourceClientId).ColoredPlayername(server.colorImportant);
         server.banlist.BanPlayer(targetName, sourceName, reason);
         SaveBanlist(server);
         server.SendMessageToAll(string.Format(server.language.Get("Server_CommandBanMessage"), server.colorImportant, targetNameColored, sourceNameColored, reason));
         server.ServerEventLog(string.Format("{0} bans {1}.{2}", sourceName, targetName, reason));
         server.SendPacket(targetClientId, ServerPackets.DisconnectPlayer(string.Format(server.language.Get("Server_CommandBanNotification"), reason)));
         server.KillPlayer(targetClientId);
         return true;
     }
     server.SendMessage(sourceClientId, string.Format(server.language.Get("Server_CommandNonexistantID"), server.colorError, targetClientId));
     return false;
 }
开发者ID:MagistrAVSH,项目名称:manicdigger,代码行数:34,代码来源:BanList.cs

示例2: RestartMods

        public bool RestartMods(Server server, int sourceClientId)
        {
            if (!server.PlayerHasPrivilege(sourceClientId, ServerClientMisc.Privilege.restart))
            {
                server.SendMessage(sourceClientId, string.Format(server.language.Get("Server_CommandInsufficientPrivileges"), server.colorError));
                return false;
            }
            server.SendMessageToAll(string.Format(server.language.Get("Server_CommandRestartModsSuccess"), server.colorImportant, server.GetClient(sourceClientId).ColoredPlayername(server.colorImportant)));
            server.ServerEventLog(string.Format("{0} restarts mods.", server.GetClient(sourceClientId).playername));

            server.modEventHandlers = new ModEventHandlers();
            for (int i = 0; i < server.systemsCount; i++)
            {
                if (server.systems[i] == null) { continue; }
                server.systems[i].OnRestart(server);
            }

            LoadMods(server, true);
            return true;
        }
开发者ID:MagistrAVSH,项目名称:manicdigger,代码行数:20,代码来源:ModLoader.cs

示例3: BanOffline

    public bool BanOffline(Server server, int sourceClientId, string target, string reason)
    {
        if (!server.PlayerHasPrivilege(sourceClientId, ServerClientMisc.Privilege.ban_offline))
        {
            server.SendMessage(sourceClientId, string.Format(server.language.Get("Server_CommandInsufficientPrivileges"), server.colorError));
            return false;
        }
        if (!reason.Equals(""))
        {
            reason = server.language.Get("Server_CommandKickBanReason") + reason;
        }

        if (server.GetClient(target) != null)
        {
            server.SendMessage(sourceClientId, string.Format(server.language.Get("Server_CommandBanOfflineTargetOnline"), server.colorError, target));
            return false;
        }

        // Target is at the moment not online. Check if there is an entry in ServerClient

        // Get related client from config file
        ManicDigger.Client targetClient = server.serverClient.Clients.Find(
            delegate(ManicDigger.Client client)
            {
                return client.Name.Equals(target, StringComparison.InvariantCultureIgnoreCase);
            }
        );

        // Entry exists.
        if (targetClient != null)
        {
            // Get target's group.
            ManicDigger.Group targetGroup = server.serverClient.Groups.Find(
                delegate(ManicDigger.Group grp)
                {
                    return grp.Name.Equals(targetClient.Group);
                }
            );
            if (targetGroup == null)
            {
                server.SendMessage(sourceClientId, string.Format(server.language.Get("Server_CommandInvalidGroup"), server.colorError));
                return false;
            }

            // Check if target's group is superior.
            if (targetGroup.IsSuperior(server.GetClient(sourceClientId).clientGroup) || targetGroup.EqualLevel(server.GetClient(sourceClientId).clientGroup))
            {
                server.SendMessage(sourceClientId, string.Format(server.language.Get("Server_CommandTargetUserSuperior"), server.colorError));
                return false;
            }

            // Remove target's entry.
            server.serverClient.Clients.Remove(targetClient);
            server.serverClientNeedsSaving = true;
        }

        // Finally ban user.
        server.banlist.BanPlayer(target, server.GetClient(sourceClientId).playername, reason);
        SaveBanlist(server);
        server.SendMessageToAll(string.Format(server.language.Get("Server_CommandBanOfflineMessage"), server.colorImportant, target, server.GetClient(sourceClientId).ColoredPlayername(server.colorImportant), reason));
        server.ServerEventLog(string.Format("{0} bans {1}.{2}", server.GetClient(sourceClientId).playername, target, reason));
        return true;
    }
开发者ID:MagistrAVSH,项目名称:manicdigger,代码行数:63,代码来源:BanList.cs


注:本文中的Server.SendMessageToAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。