1. Hi guys,

    I've been trying to pass commands through a recycled GUI to suite my own needs, into the games console, which is only usable by admins with an Oxide permission I've predefined.

    my issue is playerbase doesn't have the command i'm trying to use, and i have no idea how to change it into a suitable structure to pass it from a gui button i've set, into the ingame console.

    Any insight is much appreciated.

    The code i've been changing and editing to try and get it to work:

    "
    [ConsoleCommand("padm_teleport")]
    private void ccmdAdminMenu(ConsoleSystem.Arg arg)
    {
    var player = arg.Player();
    if (player == null) return;
    // ulong targetId;

    //if (!VerifyPermission(ref player, "AdminMenu.allow") || !GetTargetFromArg(ref arg, out targetId) || !configData.Enableteleport)
    // return;

    covalence.Players.FindPlayer(player.UserIDString).Teleport(targetId);
    LogInfo($"{player.displayName}: Teleported too {targetId}");
    BuildUI(Player, UiPage.PlayersPage, targetId.ToString());
    }
    "

    Error:

    Error while compiling: AdminMenu.cs(1378,21): error CS1503: Argument `#1' cannot convert `Oxide.Game.Rust.Libraries.Player' expression to type `BasePlayer'

    Much appreciated, sorry for being a nub. im sure i missed something obvious / am being an idiot, but im very new to C# and plugin development and such for Rust as is, so again, be gentle with me haha.
     
  2. I think you want

    Code:
    arg.Connection.player as BasePlayer
    Just looking at other plugins.
     
  3. Hey, i'll take a look. Thank you.
    [DOUBLEPOST=1531769809][/DOUBLEPOST]The original developer of the GUI im using is much more skilled than me, this is my learning curve so to speak. I appreciate the help.
     
  4. Not sure if i'm dumb or not, still can't get it to run, just getting a base player conversion error again, i think im going to try and work around it until i get it down. Thanks though. Chances are your recommendation would work, i just still don't know how to structure it.

     
  5. var player = arg.Connection.player as BasePlayer;
    is correct and does need fixed,
    but the error is coming from 'BuildUI(Player,.....'

    Player with a capital is a type and the error is telling you that type is Oxide.Game.Rust.Libraries.Player, where the method expects BasePlayer.

    Change the arg.Connection line, and then Player to player, and see what the next error is. ;)
     
  6. Hey there. Thank you, feel a bit silly now.

    Next error is:

    Error while compiling: AdminMenu.cs(1191,72): error CS1503: Argument `#1' cannot convert `ulong' expression to type `Oxide.Core.Libraries.Covalence.GenericPosition'

    One issue passed, another presented haha.

    Thanks for the help so far.

     
  7. Use the error and the clues it gives you.
    The complaint is about trying to convert ulong to type ..GenericPosition.

    So I guess you're passing a player.userID to something that wants a location?

    Post your up to date code in a codeblock as you go. ;)
     
  8. I am. I'm trying to pass a command to find a player, by ID and bring them to the ID of the player using the interface, in this case, my admins, as well as find the id of players, and use the teleport command to bring my admins to them, which is the focus of this case/code, i can worry about figuring out the bring later...

    I'm doing it using a consolecommand method, passing it off to check a permission, then if the permission is enabled, it should pass the code, to find the player, and then move the admin using the gui to the position of the player, which in this case im trying to call with targetId.

    Here's the code so far:

    Code:
           [ConsoleCommand("admin_goto")]
            private void ccmdAdminMenu(ConsoleSystem.Arg arg)
            {
                var player = arg.Connection.player as BasePlayer;
                ulong targetId;
                if (player == null) return;            (!VerifyPermission(ref player, "AdminMenu.allow") || !GetTargetFromArg(ref arg, out targetId) || !configData.Enableteleport);
                return;            covalence.Players.FindPlayer(player.UserIDString).Teleport(targetId);
                LogInfo($"{player.displayName}: Teleported too {targetId}");
                BuildUI(player, UiPage.PlayersPage, targetId.ToString());
            }
    I'll try to further edit and make changes shortly. I'm unable to work on it very much, so decided the great plugin developers of Oxide forums might be able to help, to which you've been fantastic so far. Let me know if there are any glaring issues, other than ulong being incorrect. Just gotta find out what i need to replace it with now haha.

    Thanks
     
  9. Ok,
    You've lost the "if" before your three conditions there, so that won't compile.

    The error you're being told about is
    covalence.Players.FindPlayer(player.UserIDString).Teleport(targetId);

    It looks like Teleport() will accept BasePlayer, Vector3, or string, but you're feeding it ulong.
    or it accepts player, position, or name, and you're feeding it ID.

    If you have the BasePlayer you have direct access all those things and more,
    so matching the given ID against ID's of online players to get the BasePlayer might be better?

    If you declare target = null before, then you can check if it's still null after the loop, to know if you found someone or not.
    Code:
    BasePlayer target = null;
    foreach (BasePlayer current in BasePlayer.activePlayerList)
    {
        if (current.userID == targetId)
        {
            target = current;
            player.Teleport(target.transform.position);
            //rest of stuff
        }
    }
    if (target == null)
    Puts("Couldn't find that player online");
    
    I'm sure there are more direct ways, but I thought that would be easy to visualise.
     
    Last edited by a moderator: Jul 17, 2018
  10. Hey,

    Thank you for taking timeout of your days to help me, it's much appreciated.

    I'll keep progressing, and see how i go . If i finish my customised Gui and if i have permission from the original GUI's developer, post it so people can use it if they want.

    Thanks again, ill let you know how i get on if you have any interest. :)