Solved ChatCommand example?

Discussion in 'H2o Development' started by Rube, Apr 23, 2016.

  1. Rube

    Rube Naked Wanderer

    hey guys
    h2o chatcommand Example?
    bad running ....

    Code (Text):
            [ChatCommand("kick")]
            void KickedPlayer(PlayerInfos user, string command, string[] args)
            {
                if (!IsAdmin(user.account_id)) return;

                var player = players.FindOnlinePlayer(args[0]);
                player.Kick(GetMessage("Messages", player.BasePlayer.UniqueID));
            }
     
    Last edited: Apr 23, 2016
  2. SweetLouHD

    SweetLouHD Plugin Developer

    last i checked typed commands are not available yet in the current snapshot.
    --- Double Post Merged, Apr 23, 2016 ---
    i think @Wulf said he was working to resolve this
     
  3. Rube

    Rube Naked Wanderer

    Sorry for speaking without checking

    Wait for the corresponding
     
  4. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    Chat commands are already in the last couple snapshots, and last release too I believe.

    Your plugin can't be a CovalencePlugin though, you should be using HideHoldOutPlugin. Don't base your plugins entirely on mine, I develop using the newer API that isn't completed yet. ;)

    There aren't wrappers for kicking and such yet with HideHoldOutPlugin, so you'd need to either call kicking functions in the game directly, or wait for a wrapper for them.
     
  5. SweetLouHD

    SweetLouHD Plugin Developer

    I guess I can try it again. when I did nothing happened. I think that was .69 tho. I will try with the .70
     
  6. k1lly0u

    k1lly0u Plugin Developer

    I'm also having trouble getting a working chat command. Do you use the PlayerInfos component? Also anyone worked out how to message a player directly?
     
  7. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    It should, the '/oxide.version' command in the core is a good example. It does indeed work though.
     
  8. k1lly0u

    k1lly0u Plugin Developer

    Thanks Wulf, Ill keep playing around with it
    --- Double Post Merged, Apr 24, 2016 ---
    I got it working but its not like it is for Rust. [ChatCommand()] by itself doesn't work for me, I need to get the Command library and manually register the chat command on plugin load
     
  9. Rube

    Rube Naked Wanderer

    Thanks Work!!
    Code (Text):
    using System.Collections.Generic;
    using System.Text;

    using Oxide.Core;
    using Oxide.Core.Plugins;
    using Oxide.Game.HideHoldOut.Libraries;

            // The command library
            private readonly Command cmdlib = Interface.Oxide.GetLibrary<Command>();

            void Init()
            {
                //add command
                cmdlib.AddChatCommand("test", this, "testCMD");
            }
           
            [HookMethod("testCMD")]
            private void testCMD(PlayerInfos id, string command, string[] args)
            {
                var player = players.FindOnlinePlayer(id.Nickname);
                Puts("It Work!!!" + args[0]);
                player.Message("It Work!!!" + args[0]);
            }
     
     
  10. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    You don't need to pull in the command library again, it's already there with "command".
    Code (C#):
    cmd.AddChatCommand("test", this, "testCMD");