Beispiel #1
0
        public static void unshareWith(PlayerClient senderClient, string[] args)
        {
            if (args.Count() > 1)
            {
                if (args[1] == "all")
                {
                    string senderUID = senderClient.userID.ToString();

                    if (Vars.sharingData.ContainsKey(senderUID))
                    {
                        Broadcast.noticeTo(senderClient.netPlayer, ":(", "Doors unshared with everyone.");
                        Vars.remDoorData(senderUID, "all");
                    }
                    else
                    {
                        Broadcast.noticeTo(senderClient.netPlayer, ":(", "You are not sharing doors with anyone.");
                    }
                }
                else
                {
                    PlayerClient[] possibleTargets = Array.FindAll(Vars.AllPlayerClients.ToArray(), (PlayerClient pc) => pc.userName.Contains(args[1]));
                    if (possibleTargets.Count() == 0)
                    {
                        Broadcast.broadcastTo(senderClient.netPlayer, "No player names equal or contain '" + args[1] + "'.");
                    }
                    else if (possibleTargets.Count() > 1)
                    {
                        Broadcast.broadcastTo(senderClient.netPlayer, "Too many player names contain '" + args[1] + "'.");
                    }
                    else
                    {
                        PlayerClient targetClient = possibleTargets[0];
                        string       senderUID    = senderClient.userID.ToString();
                        string       targetUID    = targetClient.userID.ToString();

                        if (senderUID != null && targetUID != null && senderUID.Length == 17 && targetUID.Length == 17 && senderUID != targetUID)
                        {
                            if (Vars.sharingData.ContainsKey(senderUID))
                            {
                                if (Vars.sharingData[senderUID].Contains(targetUID))
                                {
                                    List <string> shareData = Vars.sharingData[senderUID].Split(':').ToList();
                                    if (shareData.Contains(targetUID))
                                    {
                                        shareData.Remove(targetUID);
                                        string newData  = "";
                                        int    curIndex = 0;
                                        foreach (string s in shareData)
                                        {
                                            curIndex++;
                                            if (curIndex > 1)
                                            {
                                                newData += ":" + s;
                                            }
                                            else
                                            {
                                                newData += s;
                                            }
                                        }
                                        Vars.sharingData[senderUID] = newData;
                                    }
                                    Broadcast.noticeTo(senderClient.netPlayer, ":(", "Doors unshared with " + targetClient.userName + ".");
                                    Broadcast.noticeTo(targetClient.netPlayer, ":D", "You can no longer open " + senderClient.userName + "'s doors.");
                                    Vars.remDoorData(senderUID, targetUID);
                                }
                                else
                                {
                                    Broadcast.noticeTo(senderClient.netPlayer, ":(", "You are not sharing doors with " + targetClient.userName + ".");
                                }
                            }
                            else
                            {
                                Broadcast.noticeTo(senderClient.netPlayer, ":(", "You are not sharing doors with " + targetClient.userName + ".");
                            }
                        }
                    }
                }
            }
        }
Beispiel #2
0
        public static void executeCMD(string playerName, string message, uLink.NetworkPlayer player, PlayerClient playerClient, Character playerChar)
        {
            string[] commandArgs = message.Split(' ');
            string   command     = commandArgs[0];

            if (Vars.totalCommands.Contains(command) || (playerChar.netUser.CanAdmin() && commandArgs[0] == "/reload"))
            {
                if (Vars.enabledCommands[Vars.findRank(playerClient.userID.ToString())].Contains(command) || (playerChar.netUser.CanAdmin() && commandArgs[0] == "/reload"))
                {
                    if (Vars.enabledCommands[Vars.findRank(playerClient.userID.ToString())].Contains("/whitelist check") && message.StartsWith("/whitelist check"))
                    {
                        Vars.whitelistCheck(playerClient);
                    }
                    else if (Vars.enabledCommands[Vars.findRank(playerClient.userID.ToString())].Contains("/f safezone") && message.StartsWith("/f safezone"))
                    {
                        Vars.manageZones(playerClient, commandArgs, true);
                    }
                    else if (Vars.enabledCommands[Vars.findRank(playerClient.userID.ToString())].Contains("/f warzone") && message.StartsWith("/f warzone"))
                    {
                        Vars.manageZones(playerClient, commandArgs, false);
                    }
                    else if (Vars.enabledCommands[Vars.findRank(playerClient.userID.ToString())].Contains("/f build") && message.StartsWith("/f build"))
                    {
                        Vars.handleFactions(playerClient, commandArgs);
                    }
                    else
                    {
                        switch (command)
                        {
                        case "/client":
                            Vars.grabClient(playerClient, commandArgs);
                            break;

                        case "/clearinv":
                            Vars.clearPlayer(playerClient, commandArgs);
                            break;

                        case "/craft":
                            Vars.craftTool(playerClient, commandArgs);
                            break;

                        case "/vanish":
                            Vars.vanishTool(playerClient, commandArgs);
                            break;

                        case "/hide":
                            Vars.hideTool(playerClient, commandArgs);
                            break;

                        case "/dist":
                            Vars.showDistance(playerClient, commandArgs);
                            break;

                        case "/owner":
                            Vars.showOwner(playerClient, commandArgs);
                            break;

                        case "/removeall":
                            Vars.removerAllTool(playerClient, commandArgs);
                            break;

                        case "/remove":
                            Vars.removerTool(playerClient, commandArgs);
                            break;

                        case "/f":
                            Vars.handleFactions(playerClient, commandArgs);
                            break;

                        case "/r":
                            Broadcast.reply(playerClient, commandArgs);
                            break;

                        case "/rules":
                            Vars.showRules(playerClient);
                            break;

                        case "/players":
                            Vars.showPlayers(playerClient);
                            break;

                        case "/warps":
                            Vars.showWarps(playerClient);
                            break;

                        case "/kits":
                            Vars.showKits(playerClient);
                            break;

                        case "/feed":
                            Vars.feedPlayer(player, playerName, commandArgs);
                            break;

                        case "/heal":
                            Vars.healPlayer(player, playerName, commandArgs);
                            break;

                        case "/access":
                            Vars.giveAccess(playerClient, commandArgs);
                            break;

                        case "/version":
                            Broadcast.broadcastTo(player, "The server is running Rust Essentials v" + Vars.currentVersion + ".");
                            break;

                        case "/save":
                            Vars.save(playerClient);
                            break;

                        case "/saypop":
                            Vars.saypop(commandArgs);
                            break;

                        case "/tppos":
                            Vars.teleportPos(playerClient, commandArgs);
                            break;

                        case "/tphere":
                            Vars.teleportHere(playerClient, commandArgs);
                            break;

                        case "/tpaccept":
                            Vars.teleportAccept(playerClient, commandArgs);
                            break;

                        case "/tpdeny":
                            Vars.teleportDeny(playerClient, commandArgs);
                            break;

                        case "/tpa":
                            Vars.teleportRequest(playerClient, commandArgs);
                            break;

                        case "/tp":
                            Vars.teleport(playerClient, commandArgs);
                            break;

                        case "/history":
                            Vars.showHistory(playerClient, commandArgs);
                            break;

                        case "/unmute":
                            Vars.mute(playerClient, commandArgs, false);
                            break;

                        case "/mute":
                            Vars.mute(playerClient, commandArgs, true);
                            break;

                        case "/stop":
                            Vars.stopServer();
                            break;

                        case "/say":
                            Vars.say(commandArgs);
                            break;

                        case "/chan":
                            Vars.channels(playerClient, commandArgs);
                            break;

                        case "/kickall":
                            Vars.kickAll(playerClient);
                            break;

                        case "/whitelist":
                            Vars.whitelistPlayer(player, commandArgs);
                            break;

                        case "/reload":
                            Vars.reloadFile(player, commandArgs);
                            break;

                        case "/unban":
                            Vars.unbanPlayer(playerClient, commandArgs);
                            break;

                        case "/ban":
                            Vars.banPlayer(playerClient, commandArgs, false);
                            break;

                        case "/bane":
                            Vars.banPlayer(playerClient, commandArgs, true);
                            break;

                        case "/kick":
                            Vars.kickPlayer(playerClient, commandArgs, false);
                            break;

                        case "/kicke":
                            Vars.kickPlayer(playerClient, commandArgs, true);
                            break;

                        case "/daylength":
                            Vars.setDayLength(playerClient, commandArgs);
                            break;

                        case "/nightlength":
                            Vars.setNightLength(playerClient, commandArgs);
                            break;

                        case "/time":
                            Vars.setTime(playerClient, commandArgs);
                            break;

                        case "/join":
                            Vars.fakeJoin(playerClient, commandArgs);
                            break;

                        case "/leave":
                            Vars.fakeLeave(playerClient, commandArgs);
                            break;

                        case "/pos":
                            Vars.getPlayerPos(playerClient);
                            break;

                        case "/i":
                            Vars.createItem(playerClient, playerClient, commandArgs, message, true);
                            break;

                        case "/give":
                            Vars.createItem(playerClient, commandArgs, message);
                            break;

                        case "/giveall":
                            Vars.giveAll(playerClient, commandArgs);
                            break;

                        case "/random":
                            Vars.giveRandom(playerClient, commandArgs);
                            break;

                        case "/warp":
                            Vars.warpPlayer(playerClient, commandArgs);
                            break;

                        case "/kit":
                            Vars.giveKit(playerClient, commandArgs, message);
                            break;

                        case "/airdrop":
                            Vars.airdrop(player, commandArgs);
                            break;

                        case "/share":
                            Share.shareWith(playerClient, commandArgs);
                            break;

                        case "/unshare":
                            Share.unshareWith(playerClient, commandArgs);
                            break;

                        case "/pm":
                            Broadcast.sendPM(playerName, commandArgs);
                            break;

                        case "/online":
                            Broadcast.sendPlayers(player);
                            break;

                        case "/uid":
                            Vars.grabUID(playerClient, commandArgs);
                            break;

                        case "/god":
                            Vars.godMode(player, playerName, commandArgs, true);
                            break;

                        case "/ungod":
                            Vars.godMode(player, playerName, commandArgs, false);
                            break;

                        case "/fall":
                            Vars.setFall(player, commandArgs);
                            break;

                        case "/kill":
                            Vars.killTarget(player, commandArgs);
                            break;

                        case "/help":
                            Broadcast.help(player, commandArgs);
                            break;
                        }
                    }
                }
                else
                {
                    Broadcast.noticeTo(player, ":(", "You do not have permission to do this.");
                }
            }
            else
            {
                if (Vars.unknownCommand)
                {
                    Broadcast.broadcastTo(player, "Unknown command \"" + command + "\"!");
                }
            }
        }
Beispiel #3
0
        public static void sendPM(string sender, string[] args)
        {
            PlayerClient senderClient = Array.Find(Vars.AllPlayerClients.ToArray(), (PlayerClient pc) => pc.userName == sender);

            if (args.Length > 2)
            {
                bool          hadQuote       = false;
                int           lastIndex      = 0;
                string        playerName     = "";
                List <string> playerNameList = new List <string>();
                if (args[1].Contains("\""))
                {
                    foreach (string s in args)
                    {
                        lastIndex++;
                        if (s.StartsWith("\""))
                        {
                            hadQuote = true;
                        }
                        if (hadQuote)
                        {
                            playerNameList.Add(s);
                        }
                        if (s.EndsWith("\""))
                        {
                            hadQuote = false;
                            break;
                        }
                    }
                    playerName = string.Join(" ", playerNameList.ToArray());
                }
                else
                {
                    playerName = args[1];
                    lastIndex  = 1;
                }
                playerName = playerName.Replace("\"", "").Trim();

                if (playerName != senderClient.userName)
                {
                    string        message     = "";
                    int           curIndex    = 0;
                    List <string> messageList = new List <string>();
                    foreach (string s in args)
                    {
                        if (curIndex > lastIndex)
                        {
                            messageList.Add(s);
                        }
                        curIndex++;
                    }
                    message = string.Join(" ", messageList.ToArray());
                    if (playerName != null && message != null)
                    {
                        PlayerClient[] possibleTargets = Array.FindAll(Vars.AllPlayerClients.ToArray(), (PlayerClient pc) => pc.userName.Contains(playerName));
                        if (possibleTargets.Count() == 0)
                        {
                            Broadcast.broadcastTo(senderClient.netPlayer, "No player names equal or contain \"" + playerName + "\".");
                        }
                        else if (possibleTargets.Count() > 1)
                        {
                            Broadcast.broadcastTo(senderClient.netPlayer, "Too many player names contain \"" + playerName + "\".");
                        }
                        else
                        {
                            PlayerClient targetClient = possibleTargets[0];
                            message = Vars.replaceQuotes(message);
                            Vars.conLog.Chat("<PM FROM> " + senderClient.userName + ": " + message);
                            Vars.conLog.Chat("<PM TO> " + targetClient.userName + ": " + message);
                            string namePrefixTo   = (Vars.nextToName ? "[PM to] " : "");
                            string msgPrefixTo    = (!Vars.nextToName ? "[PM to] " : "");
                            string namePrefixFrom = (Vars.nextToName ? "[PM from] " : "");
                            string msgPrefixFrom  = (!Vars.nextToName ? "[PM from] " : "");
                            ConsoleNetworker.SendClientCommand(senderClient.netPlayer, "chat.add \"" + namePrefixTo + targetClient.userName + "\" \"" + msgPrefixTo + message + "\"");
                            ConsoleNetworker.SendClientCommand(targetClient.netPlayer, "chat.add \"" + namePrefixFrom + senderClient.userName + "\" \"" + msgPrefixFrom + message + "\"");

                            if (Vars.latestPM.ContainsKey(senderClient))
                            {
                                Vars.latestPM[senderClient] = targetClient;
                            }
                            else
                            {
                                Vars.latestPM.Add(senderClient, targetClient);
                            }

                            if (Vars.latestPM.ContainsKey(targetClient))
                            {
                                Vars.latestPM[targetClient] = senderClient;
                            }
                            else
                            {
                                Vars.latestPM.Add(targetClient, senderClient);
                            }
                        }
                    }
                }
                else
                {
                    broadcastTo(senderClient.netPlayer, "You can't PM yourself!");
                }
            }
        }