1. Heyo,

    Anyone know how to call an API method in JavaScript? I've looked through Oxide's GitHub files and looked at the docs without any luck. I'm curious if it's even supported for JS, I really hope so :p

    Here's what I'd like to transform into JS (From ServerRewards):
    Code:
    object AddPoints(ulong playerID, int amount) // Returns true if successful, otherwise returns null
    object TakePoints(ulong playerID, int amount) // Returns true if successful, otherwise returns null
    object object CheckPoints(ulong ID) // Returns int, or null if no data is saved//Example
    [PluginReference] Plugin ServerRewards;
    void ExampleFunction(BasePlayer player)
    {
         ServerRewards?.Call("AddPoints", new object[] { player.userID, 5 });
         ServerRewards?.Call("TakePoints", new object[] { player.userID, 5 });
    }
    Thanks in advance <3
     
  2. Wulf

    Wulf Community Admin

    For every language other than C#, you'd need to store a plugins.Find reference instead of PluginReference, then use that to Call the hook desired.
     
  3. Yes! Thank you Wulf, it works <3
     
  4. See the following post for future reference: Classes | Oxide
    (In this case, see the "Libraries" bullet point)
     
  5. Oh cool, thanks sqroot!