コード例 #1
0
    public SpawnList()
    {
        AddClass("spawnpage");
        AddChild(out Canvas, "canvas");

        Canvas.Layout.AutoColumns = true;
        Canvas.Layout.ItemSize    = new Vector2(100, 100);
        Canvas.OnCreateCell       = (cell, data) =>
        {
            var file  = (string)data;
            var panel = cell.Add.Panel("icon");
            panel.AddEvent("onclick", () =>
            {
                ConsoleSystem.Run("spawn", "models/" + file);
                Log.Info("Attemping to spawn a prop");
            });
            panel.Style.Background = new PanelBackground
            {
                Texture = Texture.Load($"/models/{file}_c.png", false)
            };
        };

        foreach (var file in FileSystem.Mounted.FindFile("models", "*.vmdl_c.png", true))
        {
            //if ( string.IsNullOrWhiteSpace( file ) ) continue;
            //if ( file.Contains( "_lod0" ) ) continue;
            //if ( file.Contains( "clothes" ) ) continue;

            Canvas.AddItem(file.Remove(file.Length - 6));
        }
    }
コード例 #2
0
 public void GiveArmed()
 {
     ConsoleSystem.Run(ConsoleSystem.Option.get_Client(), "inventory.givearm", new object[1]
     {
         (object)this.itemDef.itemid
     });
 }
コード例 #3
0
 public static void Init_Config()
 {
     ConsoleNetwork.Init();
     ConsoleSystem.UpdateValuesFromCommandLine();
     ConsoleSystem.Run(ConsoleSystem.Option.get_Server(), "server.readcfg", (object[])Array.Empty <object>());
     ServerUsers.Load();
 }
コード例 #4
0
 private static void SetServerEnvironementStatus()
 {
     ConsoleSystem.Run(ConsoleSystem.Option.Server, "weather.clouds ", 0);
     ConsoleSystem.Run(ConsoleSystem.Option.Server, "weather.rain", 0);
     ConsoleSystem.Run(ConsoleSystem.Option.Server, "weather.wind", 0);
     ConsoleSystem.Run(ConsoleSystem.Option.Server, "weather.fog", 0);
 }
コード例 #5
0
 public static void Init_Config()
 {
     ConsoleNetwork.Init();
     ConsoleSystem.UpdateValuesFromCommandLine();
     ConsoleSystem.Run(ConsoleSystem.Option.Server, "server.readcfg");
     ServerUsers.Load();
 }
コード例 #6
0
ファイル: EntityList.cs プロジェクト: anthrax3/sandbox
    public EntityList()
    {
        AddClass("spawnpage");
        AddChild(out Canvas, "canvas");

        Canvas.Layout.AutoColumns = true;
        Canvas.Layout.ItemSize    = new Vector2(100, 100);
        Canvas.OnCreateCell       = (cell, data) =>
        {
            var entry = (ClassLibraryAttribute)data;
            var btn   = cell.Add.Button(entry.Title);
            btn.AddClass("icon");
            btn.AddEvent("onclick", () => ConsoleSystem.Run("spawn_entity", entry.Name));
            btn.Style.Background = new PanelBackground
            {
                Texture = Texture.Load($"/entity/{entry.Name}.png", false)
            };
        };

        var ents = Library.GetAllAttributes <Entity>().Where(x => x.Spawnable).OrderBy(x => x.Title).ToArray();

        foreach (var entry in ents)
        {
            Canvas.AddItem(entry);
        }
    }
コード例 #7
0
 public void DeleteBag()
 {
     ConsoleSystem.Run(ConsoleSystem.Option.get_Client(), "respawn_sleepingbag_remove", new object[1]
     {
         (object)(uint)this.spawnOptions.id
     });
 }
コード例 #8
0
ファイル: SpawnMenu.cs プロジェクト: Facepunch/sandbox
    void RebuildToolList()
    {
        toollist.DeleteChildren(true);

        foreach (var entry in Library.GetAllAttributes <BaseTool>())
        {
            if (entry.Title == "BaseTool")
            {
                continue;
            }

            var button = toollist.Add.Button(entry.Title);
            button.SetClass("active", entry.Name == ConsoleSystem.GetValue("tool_current"));

            button.AddEventListener("onclick", () =>
            {
                ConsoleSystem.Run("tool_current", entry.Name);
                ConsoleSystem.Run("inventory_current", "weapon_tool");

                foreach (var child in toollist.Children)
                {
                    child.SetClass("active", child == button);
                }
            });
        }
    }
コード例 #9
0
 private static void ServerConsoleOnInput(string input)
 {
     if (!string.IsNullOrEmpty(input))
     {
         ConsoleSystem.Run(ConsoleSystem.Option.Server, input);
     }
 }
コード例 #10
0
        void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo info)
        {
            string Victim = "";

            if (entity.ShortPrefabName.Equals("patrolhelicopter.prefab"))
            {
                Victim = "PatrolHeli";
            }

            switch (Victim)
            {
            case "PatrolHeli":
                var      TimeNow  = DateTime.Now;
                var      ChopLT   = ChopperLifeTimeCurrent;
                DateTime Duration = ChopperSpawned.AddMinutes(ChopLT);
                TimeSpan l        = Duration.Subtract(TimeNow);
                if (l.Minutes <= 2)
                {
                    ChopperLifeTimeCurrent = ChopperLifeTimeCurrent + 5;
                    ConsoleSystem.Run(ConsoleSystem.Option.Server, "heli.lifetimeminutes", new String[] { ChopperLifeTimeCurrent.ToString() });
                    PrintToChat("<color=Red> [Coptor Tracker]</color>  Helicopter Lifetime has been extended as has been engaged");
                }

                break;
            }
        }
コード例 #11
0
 private void Start()
 {
     SteamClient.Create();
     ConsoleSystem.Run("config.load", false);
     ConsoleSystem.Run("serverfavourite.load", false);
     HudEnabled.Disable();
     DatablockDictionary.Initialize();
     Application.LoadLevelAdditive("GameUI");
     FeedbackLog.Start(FeedbackLog.TYPE.HardwareInfo);
     FeedbackLog.Writer.Write(SystemInfo.deviceModel);
     FeedbackLog.Writer.Write(SystemInfo.deviceName);
     FeedbackLog.Writer.Write(SystemInfo.graphicsDeviceName);
     FeedbackLog.Writer.Write(SystemInfo.graphicsDeviceVendor);
     FeedbackLog.Writer.Write(SystemInfo.graphicsDeviceVersion);
     FeedbackLog.Writer.Write(SystemInfo.graphicsMemorySize);
     FeedbackLog.Writer.Write(SystemInfo.graphicsShaderLevel);
     FeedbackLog.Writer.Write(SystemInfo.operatingSystem);
     FeedbackLog.Writer.Write(SystemInfo.processorCount);
     FeedbackLog.Writer.Write(SystemInfo.processorType);
     FeedbackLog.Writer.Write(SystemInfo.supportedRenderTargetCount);
     FeedbackLog.Writer.Write(SystemInfo.supportsComputeShaders);
     FeedbackLog.Writer.Write(SystemInfo.supportsImageEffects);
     FeedbackLog.Writer.Write(SystemInfo.supportsInstancing);
     FeedbackLog.Writer.Write(SystemInfo.supportsRenderTextures);
     FeedbackLog.Writer.Write(SystemInfo.supportsRenderToCubemap);
     FeedbackLog.Writer.Write(SystemInfo.supportsShadows);
     FeedbackLog.Writer.Write(SystemInfo.supportsStencil);
     FeedbackLog.Writer.Write(SystemInfo.systemMemorySize);
     FeedbackLog.End(FeedbackLog.TYPE.HardwareInfo);
     Connection.GameLoaded();
 }
コード例 #12
0
ファイル: SpawnList.cs プロジェクト: Facepunch/sandbox
    public SpawnList()
    {
        AddClass("spawnpage");
        AddChild(out Canvas, "canvas");

        Canvas.Layout.AutoColumns = true;
        Canvas.Layout.ItemWidth   = 100;
        Canvas.Layout.ItemHeight  = 100;

        Canvas.OnCreateCell = (cell, data) =>
        {
            var file  = (string)data;
            var panel = cell.Add.Panel("icon");
            panel.AddEventListener("onclick", () => ConsoleSystem.Run("spawn", "models/" + file));
            panel.Style.BackgroundImage = Texture.Load(FileSystem.Mounted, $"/models/{file}_c.png", false);
        };

        foreach (var file in FileSystem.Mounted.FindFile("models", "*.vmdl_c.png", true))
        {
            if (string.IsNullOrWhiteSpace(file))
            {
                continue;
            }
            if (file.Contains("_lod0"))
            {
                continue;
            }
            if (file.Contains("clothes"))
            {
                continue;
            }

            Canvas.AddItem(file.Remove(file.Length - 6));
        }
    }
コード例 #13
0
ファイル: RustLegacyExtension.cs プロジェクト: bawNg/Oxide
 private static void ServerConsoleOnInput(string input)
 {
     if (!string.IsNullOrEmpty(input))
     {
         ConsoleSystem.Run(input, true);
     }
 }
コード例 #14
0
 private static void OnCommand(RCon.Command cmd)
 {
     try
     {
         RCon.responseIdentifier = cmd.Identifier;
         RCon.responseConnection = cmd.ConnectionId;
         RCon.isInput            = true;
         if (RCon.Print)
         {
             Debug.Log(string.Concat(new object[] { "[rcon] ", cmd.Ip, ": ", cmd.Message }));
         }
         RCon.isInput = false;
         ConsoleSystem.Option server = ConsoleSystem.Option.Server;
         string str = ConsoleSystem.Run(server.Quiet(), cmd.Message, Array.Empty <object>());
         if (str != null)
         {
             RCon.OnMessage(str, string.Empty, UnityEngine.LogType.Log);
         }
     }
     finally
     {
         RCon.responseIdentifier = 0;
         RCon.responseConnection = string.Empty;
     }
 }
コード例 #15
0
 internal bool HandleMessage(int type, string msg)
 {
     if (!this.isAuthorised)
     {
         return(this.HandleMessage_UnAuthed(type, msg));
     }
     if (type == RCon.SERVERDATA_SWITCH_UTF8)
     {
         this.utf8Mode = true;
         return(true);
     }
     if (type == RCon.SERVERDATA_EXECCOMMAND)
     {
         Debug.Log(string.Concat("[RCON][", this.connectionName, "] ", msg));
         this.runningConsoleCommand = true;
         ConsoleSystem.Run(ConsoleSystem.Option.Server, msg, Array.Empty <object>());
         this.runningConsoleCommand = false;
         this.Reply(-1, RCon.SERVERDATA_RESPONSE_VALUE, "");
         return(true);
     }
     if (type == RCon.SERVERDATA_RESPONSE_VALUE)
     {
         this.Reply(this.lastMessageID, RCon.SERVERDATA_RESPONSE_VALUE, "");
         return(true);
     }
     Debug.Log(string.Concat(new object[] { "[RCON][", this.connectionName, "] Unhandled: ", this.lastMessageID, " -> ", type, " -> ", msg }));
     return(false);
 }
コード例 #16
0
    public SpawnList()
    {
        AddClass("spawnpage");
        AddChild(out Canvas, "canvas");

        Canvas.Layout.AutoColumns = true;
        Canvas.Layout.ItemSize    = new Vector2(100, 100);
        Canvas.OnCreateCell       = (cell, data) =>
        {
            var file  = (string)data;
            var panel = cell.Add.Panel("icon");
            panel.Style.Set("background-image", $"url( /models/{file}.png )");
            panel.AddEvent("onclick", () => ConsoleSystem.Run("spawn", "models/" + file));
        };


        foreach (var file in FileSystem.Mounted.FindFile("models", "*.vmdl_c", true))
        {
            if (file.Contains("_lod0"))
            {
                continue;
            }

            Canvas.AddItem(file);
        }
    }
コード例 #17
0
    private IEnumerator ServerRestartWarning(string info, int iSeconds)
    {
        if (iSeconds >= 0)
        {
            if (!string.IsNullOrEmpty(info))
            {
                ConsoleNetwork.BroadcastToAllClients("chat.add", (object)0, (object)("<color=#fff>SERVER</color> Restarting: " + info));
            }
            for (int i = iSeconds; i > 0; --i)
            {
                if (i == iSeconds || i % 60 == 0 || i < 300 && i % 30 == 0 || (i < 60 && i % 10 == 0 || i < 10))
                {
                    ConsoleNetwork.BroadcastToAllClients("chat.add", (object)0, (object)("<color=#fff>SERVER</color> Restarting in " + (object)i + " seconds!"));
                    Debug.Log((object)("Restarting in " + (object)i + " seconds"));
                }
                yield return((object)CoroutineEx.waitForSeconds(1f));
            }
            ConsoleNetwork.BroadcastToAllClients("chat.add", (object)0, (object)"<color=#fff>SERVER</color> Restarting");
            yield return((object)CoroutineEx.waitForSeconds(2f));

            foreach (BasePlayer basePlayer in BasePlayer.activePlayerList.ToArray())
            {
                basePlayer.Kick("Server Restarting");
            }
            yield return((object)CoroutineEx.waitForSeconds(1f));

            ConsoleSystem.Run(ConsoleSystem.Option.get_Server(), "quit", (object[])Array.Empty <object>());
        }
    }
コード例 #18
0
        public override void BuildInput(InputBuilder input)
        {
            Host.AssertClient();

            if (Camera is not FollowBallCamera camera)
            {
                return;
            }

            camera.BuildInput(input);

            // Okay maybe this should be a controller or something?
            if (input.Down(InputButton.Attack1))
            {
                ShotPower = Math.Clamp(ShotPower - input.AnalogLook.pitch, 0, 100);
            }

            if (ShotPower > 0.0f && !input.Down(InputButton.Attack1))
            {
                ConsoleSystem.Run("minigolf_stroke", camera.Angles.yaw, ShotPower / 100.0f);
                ShotPower = 0;
            }

            base.BuildInput(input);
        }
コード例 #19
0
 internal bool HandleMessage(int type, string msg)
 {
     if (!isAuthorised)
     {
         return(HandleMessage_UnAuthed(type, msg));
     }
     if (type == SERVERDATA_SWITCH_UTF8)
     {
         utf8Mode = true;
         return(true);
     }
     if (type == SERVERDATA_EXECCOMMAND)
     {
         Debug.Log("[RCON][" + connectionName + "] " + msg);
         runningConsoleCommand = true;
         ConsoleSystem.Run(ConsoleSystem.Option.Server, msg);
         runningConsoleCommand = false;
         Reply(-1, SERVERDATA_RESPONSE_VALUE, "");
         return(true);
     }
     if (type == SERVERDATA_RESPONSE_VALUE)
     {
         Reply(lastMessageID, SERVERDATA_RESPONSE_VALUE, "");
         return(true);
     }
     Debug.Log("[RCON][" + connectionName + "] Unhandled: " + lastMessageID + " -> " + type + " -> " + msg);
     return(false);
 }
コード例 #20
0
    //
    // Text has been entered into the console
    // Run it as a console command
    //
    void OnInputText(string obj)
    {
        ConsoleSystem.Run(obj);

        ClientConsole.singleton.input = obj;
        ClientConsole.singleton.HandleInput();
    }
コード例 #21
0
    public SpawnMenu()
    {
        Instance = this;

        StyleSheet.Load("/ui/SpawnMenu.scss");

        var left = Add.Panel("left");
        {
            var tabs = left.AddChild <ButtonGroup>();
            tabs.AddClass("tabs");

            var body = left.Add.Panel("body");

            {
                var props = body.AddChild <SpawnList>();
                tabs.SelectedButton = tabs.AddButtonActive("Props", (b) => props.SetClass("active", b));

                var ents = body.AddChild <EntityList>();
                tabs.AddButtonActive("Entities", (b) => ents.SetClass("active", b));
            }
        }

        var right = Add.Panel("right");
        {
            var tabs = right.Add.Panel("tabs");
            {
                tabs.Add.Button("Tools").AddClass("active");
                tabs.Add.Button("Utility");
            }
            var body = right.Add.Panel("body");
            {
                var list = body.Add.Panel("toollist");
                {
                    foreach (var entry in Library.GetAllAttributes <Sandbox.Tools.BaseTool>())
                    {
                        if (entry.Title == "Sandbox.Tools.BaseTool")
                        {
                            continue;
                        }

                        var button = list.Add.Button(entry.Title);
                        button.SetClass("active", entry.Name == ConsoleSystem.FindValue("tool_current"));

                        button.AddEvent("onclick", () =>
                        {
                            ConsoleSystem.Run("tool_current", entry.Name);
                            ConsoleSystem.Run("inventory_current", "weapon_tool");

                            foreach (var child in list.Children)
                            {
                                child.SetClass("active", child == button);
                            }
                        });
                    }
                }
                body.Add.Panel("inspector");
            }
        }
    }
コード例 #22
0
ファイル: PlayerStats.cs プロジェクト: rustmy/rustylife
        //cache



        void debugtestcons(ConsoleSystem.Arg arg)
        {
            if (arg.Args == null)
            {
                return;
            }
            ConsoleSystem.Run(ConsoleSystem.Option.Server, arg.Args[0]);
        }
コード例 #23
0
 public void GiveSelf(int amount)
 {
     ConsoleSystem.Run(ConsoleSystem.Option.get_Client(), "inventory.giveid", new object[2]
     {
         (object)this.itemDef.itemid,
         (object)amount
     });
 }
コード例 #24
0
ファイル: Tides.cs プロジェクト: regr3tti/Tides
 void OnServerInitialized()
 {
     timer.Repeat(refresh, 0, () =>                                                                                                    //This timer starts the loop below. Basically every 0.1 seconds the code below runs, an infinite number of times (or until it breaks!). It runs this often because otherwise the tide would look like it's jumping up and down, this keeps it smooth and makes the changes to ocean level virtually unnoticeable when staring at the ocean.
     {
         _oceanlevel = (tideheight / 2) * (float)Math.Sin((Math.PI / period) * Env.time - 1f * (Math.PI / offset)) + (tideheight / 2); //By default Ocean Level = 1*sin((pi/6)x-(pi/2))+1, Simply this makes High Tide at 6:00 and 18:00, with low tide at 0:00 and 12:00. Ocean Levels stay between 0 and 2.
         ConsoleSystem.Run(ConsoleSystem.Option.Server.Quiet(), $"env.oceanlevel {_oceanlevel}");                                      //Executes the command, and blocks output to the console (or you'd get a flood of commands every 0.1 seconds)
         //Puts($"{_oceanlevel}"); //Debugging purposes only. DO NOT enable unless you want a ridiculous amount of console spam.
     });
 }
コード例 #25
0
 public static void Kick(BasePlayer ply, string reason)
 {
     if (EACServer.eacScout != null)
     {
         EACServer.eacScout.SendKickReport(ply.userID.ToString(), reason, KickReasonCategory.KickReasonOther);
     }
     AddRecord(ply, kicks);
     ConsoleSystem.Run(ConsoleSystem.Option.Server, "kick", ply.userID, reason);
 }
コード例 #26
0
 public void RunCommandImmediately()
 {
     if (this.asIfTypedIntoConsole)
     {
         ConsoleWindow.singleton.RunCommand(this.consoleCommand);
         return;
     }
     ConsoleSystem.Run(this.consoleCommand, false);
 }
コード例 #27
0
    public void CL_ConsoleCommand(string message, NetworkMessageInfo info)
    {
        ConsoleWindow window = (ConsoleWindow)Object.FindObjectOfType(typeof(ConsoleWindow));

        if ((window != null) && !ConsoleSystem.Run(message, false))
        {
            Debug.Log("Unhandled command from server: " + message);
        }
    }
コード例 #28
0
 public static void Ban(BasePlayer ply, string reason)
 {
     if (EACServer.eacScout != null)
     {
         EACServer.eacScout.SendKickReport(ply.userID.ToString(), reason, KickReasonCategory.KickReasonCheating);
     }
     AntiHack.AddRecord(ply, AntiHack.bans);
     ConsoleSystem.Run(ConsoleSystem.Option.Server, "ban", new object[] { ply.userID, reason });
 }
コード例 #29
0
    public void UpdateConVars()
    {
        string str;

        if (this.GetStringValueFromControl(out str))
        {
            ConsoleSystem.Run(this.convarName + " \"" + str + "\"", false);
        }
    }
コード例 #30
0
        private string UpdateDescription(string text = "")
        {
            if (!string.IsNullOrEmpty(text))
            {
                config.Description = text;
            }

            StringBuilder newDescription = new StringBuilder(config.Description);

            foreach (Match match in varRegex.Matches(config.Description))
            {
                string command = match.Groups[1].Value;

                if (!string.IsNullOrEmpty(command))
                {
                    string reply = ConsoleSystem.Run(ConsoleSystem.Option.Server.Quiet(), command);
                    newDescription.Replace(match.ToString(), reply.Replace("\"", "") ?? "");
                }
            }

            if (config.ShowPlugins)
            {
                Plugin[] loadedPlugins = plugins.GetAll();

                if (loadedPlugins.Length != 0)
                {
                    int    count      = 0;
                    string pluginList = null;

                    foreach (Plugin plugin in loadedPlugins.Where(p => !p.IsCorePlugin))
                    {
                        if (!config.HiddenPlugins.Contains(plugin.Title) && !config.HiddenPlugins.Contains(plugin.Name))
                        {
                            pluginList += plugin.Title + ", ";
                            count++;
                        }
                    }
                    if (pluginList != null)
                    {
                        if (pluginList.EndsWith(", "))
                        {
                            pluginList = pluginList.Remove(pluginList.Length - 2);
                        }
                        newDescription.Append($"\n\nPlugins ({count}): {pluginList}");
                    }
                }
            }

            if (newDescription.ToString() != ConVar.Server.description)
            {
                ConVar.Server.description = newDescription.ToString();
                Puts($"Server description updated: \nmagic.description: \"{config.Description}\"");
            }

            return(ConVar.Server.description);
        }