1. Hello!

    I have been trying to figure out a way to prevent players from changing who they are spectating when they hit the space bar. I have considered checking for user input while spectating, but that seems like a dirty workaround for something that might just be a configurable option.

    Does anyone know any easy way to prevent this?

    --FSM
     
  2. It's probably client sided (default commands are usually optimized for what they're intended for).
     
  3. That is what I was thinking, but I would think it would talk to the server at some point in all this.
     
  4. The Rust admin system is pretty simple. It just disables a bunch of bounds checks for admins (both client and server side). The server is actually never told that the user is spectating.
    This is pretty much the safest client/server arch you can build for this kind of thing.
     
  5. @sqroot In my current use case, I am not using the Rust Admin system, and using my plugin in order to manage who is spectating and who they are spectating. The biggest problem I have is once a player starts spectating they can switch which player they are spectating. I don't want this since I am restricting who they can spectate. :)
     
  6. What are you using for spectating? The client commands?
     
  7. There is some other code around it, but basically:
    player.SetPlayerFlag(BasePlayer.PlayerFlags.Spectating, true);
     
  8. Hm, in that case, I'd start with reading the source code of BasePlayer.UpdateSpectateTarget in the Assembly, maybe that helps.
    I'm not sure if what you're trying to do is possible without reflection, though.
     
  9. @sqroot that is what I was afriad of xD. I was hoping someone much smarter than me would have come up with a solution haha. I'll start digging through some of the code in the Assembly soon. I've got more bugs to fix in the plugin first. :/
     
  10. Wulf

    Wulf Community Admin

    Spectate for Rust | Oxide > You can easily block the command and change it like I do.
     
  11. @Wulf are you preventing the switching of spectators using:

    Code:
    object OnServerCommand(ConsoleSystem.Arg arg)
            {
                if (arg?.cmd?.namefull != "global.spectate" || arg.connection == null) return null;            var player = arg.connection.player as BasePlayer;
                var target = new[] { arg.GetString(0) };
                ChatCommand(player, null, target);            return true;
            }
    If so can you give me a quick run down on how this code work? Does pressing space-bar while in spectate send the command: "global.spectate" to the server? To me that just looks like it is running the Spectate command when it is run from the console.
     
  12. Wulf

    Wulf Community Admin

    I'm basically intercepting the game's default spectate console command, and making it do my own stuff. You can do whatever you want after the first check, including only allowing them to spectate a specific target.
     
  13. @Wulf Thanks! You made this issue so much less complicated then I thought it would be. Also, side topic for you is there a way I can send you a PM? I haven't been able to find one on Oxidemod.org.
     
  14. Wulf

    Wulf Community Admin

    I generally keep PM closed unless it's a security issue or account related. I get too many general support requests otherwise.
     
  15. @Wulf, makes sense. I don't have any off the top of my head at the moment, but I have had a couple times in the past where I was hoping to reach out to you about things that would be awesome to include into Oxide if possible. I also strictly run Linux servers so if you ever need someone to test the Linux build let me know :)
     
  16. Wulf

    Wulf Community Admin

    Make a thread. ;)
     
  17. Will do! :p Thanks for all of your help!
     
  18. @Wulf so using OnServerCommand doesn't seem to catch the command sent when a spectating player hits the space bar. Got any other ideas? I just put a Puts() in it and it caught everything but the spacebar :p
     
  19. Wulf

    Wulf Community Admin

    That may be handled by another command, otherwise listen using OnPlayerInput.