1. player.Reply doesn't seem to work with JavaScript.

    Code:
    [Oxide] 00:49 [Error] Web request callback raised an exception in 'rustedStore v1.0.0' plugin
    File: rustedStore.js Line: 93 Column: 16 TypeError Object has no method 'Reply':
    at Jint.Native.Function.ScriptFunctionInstance.Call (Jint.Native.JsValue,Jint.Native.JsValue[]) <0x00530>
    at Jint.Native.Function.BindFunctionInstance.Call (Jint.Native.JsValue,Jint.Native.JsValue[]) <0x00120>
    at (wrapper dynamic-method) object.lambda_method (System.Runtime.CompilerServices.Closure,int,string) <0x00261>
    at Oxide.Core.Libraries.WebRequests/WebRequest.<OnComplete>m__1 () <0x000a6>
    Also, I'm not sure if this is in the right section. Perhaps there should be a "Universal Development" sub-forum, like the game specific ones.
    [DOUBLEPOST=1474088388][/DOUBLEPOST]Or is there another game-agnostic way of replying to players?
    (Forum wouldn't let me edit OP)
     
  2. Wulf

    Wulf Community Admin

    player.Reply should work fine granted you have an IPlayer, not a BasePlayer as a BasePlayer is not universal, that is Rust only.
     
  3. The issue is that both Covalence and Rust use the same method name and method args. I'm not even sure if JS/Python/Lua plugins can even be Covalence plugins at this point.
     
  4. Wulf

    Wulf Community Admin

    They can, IPlayer is exposed in hooks and methods that provide IPlayer, normal Rust hooks don't and are not universal. Thomas had a sample Lua plugin floating around too that was loading fine last I had it.
    Code:
    PLUGIN.Title = "Covalence Test"
    PLUGIN.Version = V(1, 0, 0)
    PLUGIN.Author = "thomasfn"function PLUGIN:OnServerInitialized()
        permission.RegisterPermission("cankick", self.Plugin)    print("I am " .. covalence.Game .. "!")
        local server = covalence.Server
        print("People see me as " .. server.Name)    local sayAddress
        sayAddress = function()
            if (server.Address) then
                print("People can connect to me via " .. server.Address:ToString() .. ":" .. server.Port)
            else
                print("My server details aren't ready yet.")
                timer.Once(1, sayAddress)
            end
        end
        sayAddress()    server:Print("This is how I talk!")
        server:Command("chat.say", "I can do things")    local pMgr = covalence.Players    print("I know about these players:")
        local allPlayers = util.EvaluateEnumerable(pMgr:All)
        for i = 1, #allPlayers do
            local player = allPlayers[i]
            print("'" .. player.Name .. "' with unique ID '" .. player.Id .. "' (" .. (player and "Connected" or "Not Connected") .. ")")
        end    self:SayLivePlayers()    local attribs = self._attribArr
        print("I have " .. #attribs .. " attribs!")
        for i = 1, #attribs do
            local a = attribs[i]
            if (a._attribName == "Command") then
                print("Command: " .. a[1] .. " (" .. tostring(a.func) .. ")")
            end
        end
    endfunction PLUGIN:SayLivePlayers()
        local allLivePlayers = util.EvaluateEnumerable(covalence.Players:Connected)
        if (#allLivePlayers == 0) then
            print("There are no connected players presently.")
        else
            print("Here are all the connected players:")
            for i = 1, #allLivePlayers do
                local player = allLivePlayers[i]
                print(player.Name)
            end
        end
    endfunction PLUGIN:OnPlayerConnected(player)
        timer.NextFrame(function() self:SayLivePlayers() end)
    endfunction PLUGIN:OnPlayerDisconnected(player)
        timer.NextFrame(function() self:SayLivePlayers() end)
    endCommand{ "test.lol", "test.lol1", permission="cankick" }
    function PLUGIN:Kick(player, args)
        print("We got here!")
        if (#args == 0) then
            print("No args, kicking caller...")
            if (player) then player:Kick("testing") end
        else
            -- Working on it lol
            print("We got args!")
        end
    end
     
  5. The issue are hooks that are identical in both covalence and Rust (in terms of arg length and name). Scripting languages don't care about type overloading.
     
  6. Wulf

    Wulf Community Admin

    The hook arg may be the same names, but the hooks are not the same. OnUserConnected will provide an IPlayer, OnPlayerConnected will provide a BasePlayer for Rust. So if you want it to be universal, you'd need to use Covalence hooks, not game hooks. If you use game hooks, it wouldn't be universal and you'd need to grab the IPlayer in there using helper methods if you want to use it.
     
  7. I know. Scripting languages do not have any type annotations though, so how is something supposed to be able to figure out whether a hook uses an IPlayer or a BasePlayer (to the scripting lang extension it's just an object)? Currently, these hooks always default to the game-specific hooks.
     
  8. Wulf

    Wulf Community Admin

    Those objects are passed to it, so that's up the plugin author to use the appropriate hook for what they are developing for. I'm not sure what you mean by hooks defaulting to game-specific hooks.
     
  9. @Vitrify Are you trying to register a command and retrieve an IPlayer from the command hook?
     
  10. Yeah, that's exactly what I'm trying to do, @sqroot

    Code:
    command.AddChatCommand(this.Config.command, this.Plugin, "cmdBuy" )
    ...
    ...
    ...
    cmdBuy : function(player, cmd, args) {
        player.Reply(that.Lang('name', player.Id) , "sometext
    ")
    }
    Is there a way to set up a JavaScript plugin as a Covalence Plugin? It doesn't seem to exist in the docs.

    See Oxide API for Rust vs Oxide API for Rust
    (Also, that JS example doesn't work, because of the issue I started this thread with)
     
  11. Wulf

    Wulf Community Admin

    The plugin is a Covalence plugin if you use Covalence methods. The AddChatCommand is not a Covalence method, so that player the function is getting is not a Covalence player, it's a BasePlayer from Rust. If you want to send a reply as a non-Covalence plugin, you can use player.ChatMessage(message) or rust.SendChatMessage(player, message).

    The Docs need a bit of work yet, an overhaul was started on them to move them to Covalence format, but the scripted languages (all other than C#) are a bit behind the times in terms of support.
     
  12. So is there a way to register a chat command via Covalence rather than Rust in JS?

    To be fair about the docs, I seem to be the only one not using C#. I think I'll update some of it so the examples actually work once I figure this out.
     
  13. Wulf

    Wulf Community Admin

    Not for JS yet as far as I know. For now you'd likely be best to stick with the game-specific support. I'm not sure what the future will hold for the scripted languages, most do tend to use C# as it is the most supported.
     
  14. As Wulf said, the scripting languages aren't well supported for covalence. If you want to write a universal plugin, you should really work with C#.
    There are some other issues related to hook names and compilation flags for instance as well that make it very difficult to add scripting languages to covalence (it's either very difficult or would cause lots of things to break and get ugly).
     
  15. Thanks guys, I'll probably switch over to C# then.