ServerRewards

Moved

Total Downloads: 14,033 - First Release: Mar 2, 2016 - Last Update: Jun 9, 2018

5/5, 61 likes
  1. Was getting a strange error when people tried to sell items in the store. They could sell things, but get no confirmation from the UI, and an error was thrown in RCON.
    At first I thought it was due to an pending Oxide update, but it persisted afterwards. In case anyone else gets the error, I'll post the error message and my solution:

    Error (I've obscured part of my file path with "----"):
    Code:
    (13:01:30) | Failed to call hook 'cmdSell' on plugin 'ServerRewards v0.4.41' (DirectoryNotFoundException: Could not find a part of the path "c:\-----\108_61_109_142_28026\----\ruste\server\----\oxide\logs\ServerRewards-SoldItems_2017-05-08.txt".)
    (13:01:30) | at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean anonymous, FileOptions options) [0x00000] in <filename unknown>:0
      at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share) [0x00000] in <filename unknown>:0
      at (wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare)
      at System.IO.StreamWriter..ctor (System.String path, Boolean append, System.Text.Encoding encoding, Int32 bufferSize) [0x00000] in <filename unknown>:0
      at System.IO.StreamWriter..ctor (System.String path, Boolean append) [0x00000] in <filename unknown>:0
      at (wrapper remoting-invoke-with-check) System.IO.StreamWriter:.ctor (string,bool)
      at System.IO.File.AppendAllText (System.String path, System.String contents) [0x00000] in <filename unknown>:0
      at ConVar.Server.Log (System.String strFilename, System.String strMessage) [0x00000] in <filename unknown>:0
      at Oxide.Plugins.ServerRewards.cmdSell (.Arg arg) [0x00000] in <filename unknown>:0
      at Oxide.Plugins.ServerRewards.DirectCallHook (System.String name, System.Object& ret, System.Object[] args) [0x00000] in <filename unknown>:0
      at Oxide.Plugins.CSharpPlugin.InvokeMethod (HookMethod method, System.Object[] args) [0x00000] in <filename unknown>:0
      at Oxide.Core.Plugins.CSPlugin.OnCallHook (System.String name, System.Object[] args) [0x00000] in <filename unknown>:0
      at Oxide.Core.Plugins.Plugin.CallHook (System.String hook, System.Object[] args) [0x00000] in <filename unknown>:0
    What I found is that cmdSell is the only logger that uses "ConVar.Server.Log" instead of LogToFile", so I made this change:

    Original (around line 1320)
    Code:
    ConVar.Server.Log($"oxide/logs/ServerRewards-SoldItems_{dateTime}.txt", message);
    Change (same location):
    Code:
    LogToFile($"SoldItems", $"[{DateTime.Now.ToString("hh:mm:ss")}] {message}", this);
     
  2. Thank you for this fix. I have the same issue on my linux server.
     
  3. It was with the last version, not sure if it still works. Probably does.
    [DOUBLEPOST=1494380163][/DOUBLEPOST]
    [DOUBLEPOST=1494380211][/DOUBLEPOST]Anyone know the format for adding kits, items, commands and other such nonsense via the Data files? Adding everything back to the shop via chat commands would take up several days worth of time. If not, do the old versions of the plugin still work with the latest Rust update?
     
    Last edited by a moderator: May 10, 2017
  4. You can sell a permission by using "oxide.grant user [UserName|SteamID] [Permission.Name]" For example if I wanted to sell the NTeleportation.VIP permission, you could use
    /rewards add command "TeleVIP" "grant user $player.id NTeleportation.vip"

    If you want to sell time limited permissions, you could consider using Timed Permissions plug-in which would allow you to sell the permission for a set time period. Also, the Console Message is handy for giving the player additional information. I'll include an example of those below.

    Haven't tried Kits.
    For items, I've been using the command as I don't sell much.
    For commands, the syntax is pretty straight forward. Open the reward_data.json file and head down to commands. It helps if you add a test command or two to start with. Here's a snippit from my config. I use Timed Permissions and Console Message for my permissions:
    Code:
    "commands": {
        "Backpack": {
          "displayName": "Backpack.  Yup - Backpack",
          "description": "Got a lot of loot and need to move it?  Get more storage spots for one week.  Expensive but worth it.",
          "iconName": null,
          "commands": [
            "cm.say $player.name You have purchased a backpack for 1 week.  Press the 'b' key to access.  ",
            "grantperm $player.id backpacks.use 7d",
            "grantperm $player.id backpacks.use.large 7d"
          ],
          "cost": 40
        },
        "Backpack - Limited": {
          "displayName": "Backpack - Limited Access",
          "description": "Locked out of your backpack full of ill-gotten gains?  It's not gone!  Get One Hour of access to your backpack.  Great for casual players.",
          "iconName": null,
          "commands": [
            "cm.say $player.name You have purchased a backpack for 1 hour.  Press the 'b' key to access.  ",
            "grantperm $player.id backpacks.use 1h",
            "grantperm $player.id backpacks.use.large 1h"
          ],
          "cost": 1
        },
        "Teleport VIP": {
          "displayName": "Teleport VIP",
          "description": "Teleport in style with more than twice the number of teleports.  Lasts one week.",
          "iconName": null,
          "commands": [
            "cm.say $player.name You have purchased 1 week of VIP Teleporting.",
            "grantperm $player.id NTeleportation.vip 7d"
          ],
          "cost": 15
        },
    The first line is the command's Name and must be unique per json format. This name shows up in the gui when they buy it. You can pack several commands between the brackets. The last command should not have a comma at the end. Mine does because I have more after it. I'd recommend using JSON verifier like JsonLint to verify your config before uploading it. A stray comma can cause havoc.

    Quick Note: Using FileZilla, I had to choose to "Finish editing and delete local file" in order for the plug-in to be able to load the file. It might have been specific to my server, but though I'd mention it.
     
    Last edited by a moderator: May 10, 2017
  5. JMJ

    JMJ

    Thank you very much. I wasnt sure if if just putting in the grant command would work. Just glad someone finally had an answer! Ty ty!

    Edit: This actually wont work. Each player would have to have their own button as it is being applied by ID. I would like it to apply to anyone who so chooses to buy it. Seems to be a tricky one lol.
     
    Last edited by a moderator: May 10, 2017
  6. $Player.id is a variable that is switched out to the player id of the player who purchases the command. It works well. You just need the one command. I sell lots of different permissions.

    You can also use the timed permissions plugin to set a time limit on the permissions to do things like, allow players to use the remove command for a couple hours. Anything really.
     
  7. Does anyone know of a way to add a new category to the shop?
     
  8. Looks like there's still an issue of hard coding with sell logs

    Code:
    (21:33:45) | Failed to call hook 'cmdSell' on plugin 'ServerRewards v0.4.41' (DirectoryNotFoundException: Could not find a part of the path "C:\TCAFiles\Users\******\364\server\28015\oxide\logs\ServerRewards - SoldItems_2017-05-11.txt".)
     
  9. Wulf

    Wulf Community Admin

    Sounds like you're using an old version of the plugin. The latest version uses the oxide folder in the root.
     
  10. 0.4.41 is the latest version

    upload_2017-5-11_21-46-12.png
     
  11. Wulf

    Wulf Community Admin

    Open up the plugin and look for the path where ConVar.Server.Log is. It should be set to "oxide/logs".
     
  12. Anyone have a config of literally every item on sale in the items section?
     
  13. JMJ

    JMJ

    Oh, I did not know that. Still learning all this. Didnt know that is what you meant in your first post. So just.. grant user $Player.id "permission" ?
     
  14. If you look at my example above, you'll have to included the permission's name minus the quotes. When Server Rewards runs the command, it replaces the text $player.id with the person's SteamID number so the text
    grant user $player.id NTeleportation.vip
    get's run by the server as
    grant user 123456781234 NTeleportation.vip

    You can use $player.name instead but I'd advise against it. SteamID is less error prone.
     
  15. How do you remove an item from the shop now that nothing has an ID number in the rewards file?

    EDIT: '/rewards list items' doesnt output to console like it says it should.
     
    Last edited by a moderator: May 12, 2017
  16. you could always still delete it from the json data files.
     
  17. right, but when each item is just the skin id and item and none of them are in the same order they show as in the UI it's a lil difficult.
     
  18. 5dc5316f8dd98aa905dbffe75c97e6c2.png
    a3ca51c3737cbb5ffbc5a1e82506c6ba.png

    Item ID's are essentially "shortname_skinid", this changes if you have multiple items with the same skin ID, I don't see why you would ever do that though
     
  19. k1lly0u updated ServerRewards with a new update entry:

    0.4.5

     
  20. ah woops, just saw it goes to f1 console, was expecting to see output in rcon, nvm. Care to elaborate on the changes coming with the new Image Library? :) or is it just background stuff. Whadya think of the admin mode to put x's on the items and make em clickable?