Exemplo n.º 1
0
    public static void add(Arg args)
    {
        string  @string = args.GetString(0);
        float   @float  = args.GetFloat(1, 0.1f);
        Command command = Find(@string);
        float   result;

        if (command == null)
        {
            args.ReplyWith("Convar not found: " + (@string ?? "<null>"));
        }
        else if (args.IsClientside && command.Replicated)
        {
            args.ReplyWith("Cannot set replicated convars from the client (use sv to do this)");
        }
        else if (args.IsServerside && command.ServerAdmin && !args.IsAdmin)
        {
            args.ReplyWith("Permission denied");
        }
        else if (!float.TryParse(command.String, out result))
        {
            args.ReplyWith("Convar value cannot be parsed as a number");
        }
        else
        {
            command.Set(result + @float);
        }
    }
Exemplo n.º 2
0
        public static void gesture_radius(Arg arg)
        {
            BasePlayer basePlayer = ArgEx.Player(arg);

            if (basePlayer == null || !basePlayer.IsAdmin)
            {
                return;
            }
            float         @float = arg.GetFloat(0);
            List <string> list   = Facepunch.Pool.GetList <string>();

            for (int i = 0; i < 5; i++)
            {
                if (!string.IsNullOrEmpty(arg.GetString(i + 1)))
                {
                    list.Add(arg.GetString(i + 1));
                }
            }
            if (list.Count == 0)
            {
                arg.ReplyWith("No gestures provided. eg. player.gesture_radius 10f cabbagepatch raiseroof");
                return;
            }
            List <BasePlayer> obj = Facepunch.Pool.GetList <BasePlayer>();

            global::Vis.Entities(basePlayer.transform.position, @float, obj, 131072);
            foreach (BasePlayer item in obj)
            {
                GestureConfig toPlay = basePlayer.gestureList.StringToGesture(list[Random.Range(0, list.Count)]);
                item.Server_StartGesture(toPlay);
            }
            Facepunch.Pool.FreeList(ref obj);
        }
Exemplo n.º 3
0
        public static void deployLoadoutInRange(Arg arg)
        {
            BasePlayer basePlayer = ArgEx.Player(arg);

            if ((!basePlayer.IsAdmin && !basePlayer.IsDeveloper && !Server.cinematic) || basePlayer == null)
            {
                return;
            }
            string       @string = arg.GetString(0);
            SavedLoadout so;

            if (!LoadLoadout(@string, out so))
            {
                arg.ReplyWith("Can't find loadout: " + @string);
                return;
            }
            float             @float = arg.GetFloat(1);
            List <BasePlayer> obj    = Facepunch.Pool.GetList <BasePlayer>();

            global::Vis.Entities(basePlayer.transform.position, @float, obj, 131072);
            int num = 0;

            foreach (BasePlayer item in obj)
            {
                if (!(item == basePlayer) && !item.isClient)
                {
                    so.LoadItemsOnTo(item);
                    num++;
                }
            }
            arg.ReplyWith($"Applied loadout {@string} to {num} players");
            Facepunch.Pool.FreeList(ref obj);
        }
Exemplo n.º 4
0
        public static void sleepingusersinrange(Arg arg)
        {
            BasePlayer fromPlayer = ArgEx.Player(arg);

            if (fromPlayer == null)
            {
                return;
            }
            float             range = arg.GetFloat(0);
            string            text  = "<slot:userid:\"name\">\n";
            int               num   = 0;
            List <BasePlayer> obj   = Facepunch.Pool.GetList <BasePlayer>();

            foreach (BasePlayer sleepingPlayer in BasePlayer.sleepingPlayerList)
            {
                obj.Add(sleepingPlayer);
            }
            obj.RemoveAll((BasePlayer p) => p.Distance2D(fromPlayer) > range);
            obj.Sort((BasePlayer player, BasePlayer basePlayer) => (!(player.Distance2D(fromPlayer) < basePlayer.Distance2D(fromPlayer))) ? 1 : (-1));
            foreach (BasePlayer item in obj)
            {
                text += $"{item.userID}:{item.displayName}:{item.Distance2D(fromPlayer)}m\n";
                num++;
            }
            Facepunch.Pool.FreeList(ref obj);
            text += $"{num} sleeping users within {range}m\n";
            arg.ReplyWith(text);
        }
Exemplo n.º 5
0
        public static void stall(Arg arg)
        {
            float num = Mathf.Clamp(arg.GetFloat(0), 0f, 1f);

            arg.ReplyWith("Stalling for " + num + " seconds...");
            Thread.Sleep(Mathf.RoundToInt(num * 1000f));
        }
Exemplo n.º 6
0
        public static void AnimalSenseLoadBalancerUpdateInterval(Arg args)
        {
            LoadBalancedQueue loadBalancedQueue = AnimalSensesLoadBalancer.animalSensesLoadBalancer as LoadBalancedQueue;

            if (loadBalancedQueue != null)
            {
                loadBalancedQueue.defaultUpdateInterval = args.GetFloat(0, loadBalancedQueue.defaultUpdateInterval);
            }
        }
Exemplo n.º 7
0
        public static void defaultLoadBalancerUpdateInterval(Arg args)
        {
            LoadBalancedQueue loadBalancedQueue = Apex.LoadBalancing.LoadBalancer.defaultBalancer as LoadBalancedQueue;

            if (loadBalancedQueue != null)
            {
                loadBalancedQueue.defaultUpdateInterval = args.GetFloat(0, loadBalancedQueue.defaultUpdateInterval);
            }
        }
Exemplo n.º 8
0
        public static void aiManagerLoadBalancerUpdateInterval(Arg args)
        {
            LoadBalancedQueue loadBalancedQueue = AiManagerLoadBalancer.aiManagerLoadBalancer as LoadBalancedQueue;

            if (loadBalancedQueue != null)
            {
                loadBalancedQueue.defaultUpdateInterval = args.GetFloat(0, loadBalancedQueue.defaultUpdateInterval);
            }
        }
Exemplo n.º 9
0
        public static void dof_nudge(Arg arg)
        {
            float @float = arg.GetFloat(0);

            dof_focus_dist += @float;
            if (dof_focus_dist < 0f)
            {
                dof_focus_dist = 0f;
            }
        }
Exemplo n.º 10
0
        public static void stopgesture_radius(Arg arg)
        {
            BasePlayer basePlayer = ArgEx.Player(arg);

            if (basePlayer == null || !basePlayer.IsAdmin)
            {
                return;
            }
            float             @float = arg.GetFloat(0);
            List <BasePlayer> obj    = Facepunch.Pool.GetList <BasePlayer>();

            global::Vis.Entities(basePlayer.transform.position, @float, obj, 131072);
            foreach (BasePlayer item in obj)
            {
                item.Server_CancelGesture();
            }
            Facepunch.Pool.FreeList(ref obj);
        }
Exemplo n.º 11
0
        public static void rendermap(Arg arg)
        {
            float @float = arg.GetFloat(0, 1f);
            int   imageWidth;
            int   imageHeight;
            Color background;

            byte[] array = MapImageRenderer.Render(out imageWidth, out imageHeight, out background, @float, false);
            if (array == null)
            {
                arg.ReplyWith("Failed to render the map (is a map loaded now?)");
                return;
            }
            string fullPath = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, $"map_{global::World.Size}_{global::World.Seed}.png"));

            File.WriteAllBytes(fullPath, array);
            arg.ReplyWith("Saved map render to: " + fullPath);
        }
Exemplo n.º 12
0
        public static void give(Arg arg)
        {
            BasePlayer basePlayer = ArgEx.Player(arg);

            if (!basePlayer)
            {
                return;
            }
            Item item = ItemManager.CreateByPartialName(arg.GetString(0), 1, arg.GetULong(3, 0uL));

            if (item == null)
            {
                arg.ReplyWith("Invalid Item!");
                return;
            }
            int   num  = (item.amount = arg.GetInt(1, 1));
            float num2 = (item.conditionNormalized = arg.GetFloat(2, 1f));

            item.OnVirginSpawn();
            if (!basePlayer.inventory.GiveItem(item))
            {
                item.Remove();
                arg.ReplyWith("Couldn't give item (inventory full?)");
                return;
            }
            basePlayer.Command("note.inv", item.info.itemid, num);
            Debug.Log("giving " + basePlayer.displayName + " " + num + " x " + item.info.displayName.english);
            if (basePlayer.IsDeveloper)
            {
                basePlayer.ChatMessage("you silently gave yourself " + num + " x " + item.info.displayName.english);
            }
            else
            {
                Chat.Broadcast(basePlayer.displayName + " gave themselves " + num + " x " + item.info.displayName.english, "SERVER", "#eee", 0uL);
            }
        }