1. How about trying your code on a local server? This is a discussion forum not a debugger.
     
  2. Wulf

    Wulf Community Admin

    INPUT ERROR! Does not compute!
     
  3. Okay delete this thread then.. nvm Thanks Wulf 4 help
     
  4. Wulf

    Wulf Community Admin

    You're fine, he was just recommending that you test it yourself to see if any other errors come up. The logs can be quite helpful too.
     
  5. I didnt mean to offend you.
    Try and error is the best way to learn stuff. You wont learn much if we just fix your bugs and you dont know whats actually happening in your plugins.
     
  6. Code:
    function PLUGIN:cmdas2m(player, command, arg)
        if not HasPermission(self, player.net.connection) then return end
        rust.RunServerCommand("server.saveinterval 120")
        rust.SendChatMessage(player, "Save-System", "You just set the AUTO-SAVE to 2minutes!")
    end
    function PLUGIN:cmdas5m(player, command, arg)
        if not HasPermission(self, player.net.connection) then return end
        rust.RunServerCommand("server.saveinterval 300")
        rust.SendChatMessage(player, "Save-System", "You just set the AUTO-SAVE to 5minutes!")
    end
    function PLUGIN:cmdas10m(player, command, arg)
        if not HasPermission(self, player.net.connection) then return end
        rust.RunServerCommand("server.saveinterval 600")
        rust.SendChatMessage(player, "Save-System", "You just set the AUTO-SAVE to 10minutes!")
    end
    function PLUGIN:cmdas30m(player, command, arg)
        if not HasPermission(self, player.net.connection) then return end
        rust.RunServerCommand("server.saveinterval 1800")
        rust.SendChatMessage(player, "Save-System", "You just set the AUTO-SAVE to 30minutes!")
    end
    can be replaced with:

    Code:
    function PLUGIN:cmdAS(player, command, arg)
        if not HasPermission(self, player.net.connection) then return end
        if (args.Length == 0) then return end
        local seconds = args[0] * 60
        local message = "You just set the AUTO-SAVE to {min}min!"
        message = message:gsub( "{min}", args[0])
        local command = "server.saveinterval {sec}"
        rust.RunServerCommand(command:gsub( "{sec}", seconds))
        rust.SendChatMessage(player, "Save-System", message)
    end
    and usage like:
    setautosave 30
     
    Last edited by a moderator: Apr 9, 2015
  7. Missed a spot :p
     
  8. now?:p
     
  9. Code:
    [Oxide] 10:46 AM [Error] Failed to load plugin AdvancedSaveSystem
    File: AdvancedSaveSystem.lua Line: 26 syntax error near 'or':
      at NLua.Lua.ThrowExceptionFromError (Int32 oldTop) [0x00000] in <filename unknown>:0
      at NLua.Lua.LoadString (System.String chunk, System.String name) [0x00000] in <filename unknown>:0
      at Oxide.Lua.Plugins.LuaPlugin.Load () [0x00000] in <filename unknown>:0
      at Oxide.Lua.Plugins.LuaPluginLoader.Load (System.String directory, System.String name) [0x00000] in <filename unknown>:0
      at Oxide.Core.OxideMod.LoadPlugin (System.String name) [0x00000] in <filename unknown>:0
    Line 25,26,27,28,29,30 http://screenshooter.net/101978843/nqkenuc
     
    Last edited by a moderator: Apr 9, 2015
  10. Think about this: What does line 26 do? What do you want it to do?
    Hint: Its nothing wrong with the function itself, your mistake is simple programming logic. Read the code line by line and think about what every line does, you should see your mistake yourself then.
     
  11. PaiN XD
    just take my Save system, add your code to it XD
    and also put a command like:
    /autosave XXX
    with XXX being the seconds
    why put 10 commands for it when you could just do couple lines XD?
     
  12. Wulf

    Wulf Community Admin

    The claim is that your plugin corrupts saves, even though it simply uses the same function that the server.save command uses.
     
  13. why 10 commands ? bcs i'm retarded and i cant to something more..
     
  14. Code:
    // Reference: Newtonsoft.Json
    // Reference: Oxide.Ext.Rustusing System.Collections.Generic;
    using System.Reflection;
    using System;
    using System.Data;
    using UnityEngine;
    using Oxide.Core;namespace Oxide.Plugins
    {
        [Info("Save", "Reneb", "2.0.1")]
        class Save : RustPlugin
        {
            private int saveAuth;
            private bool Changed;
            private string noAccess;
            private string saved;        void Loaded()
            {
                LoadVariables();
                permission.RegisterPermission("cansave", this);
            }
            private object GetConfig(string menu, string datavalue, object defaultValue)
            {
                var data = Config[menu] as Dictionary<string, object>;
                if (data == null)
                {
                    data = new Dictionary<string, object>();
                    Config[menu] = data;
                    Changed = true;
                }
                object value;
                if (!data.TryGetValue(datavalue, out value))
                {
                    value = defaultValue;
                    data[datavalue] = value;
                    Changed = true;
                }
                return value;
            }
            private void LoadVariables()
            {
                saveAuth = Convert.ToInt32(GetConfig("Settings", "authLevel", 1));
                noAccess = Convert.ToString(GetConfig("Messages", "noAccess", "You are not allowed to use this command"));
                saved = Convert.ToString(GetConfig("Messages", "saved", "World & Players saved"));
                if (Changed)
                {
                    SaveConfig();
                    Changed = false;
                }
            }
            void LoadDefaultConfig()
            {
                Puts("Save: Creating a new config file");
                Config.Clear();
                LoadVariables();
            }
            bool hasPermission(BasePlayer player)
            {
                if (player.net.connection.authLevel >= saveAuth) return true;
                return permission.UserHasPermission(player.userID.ToString(), "cansave");
            }
            [ConsoleCommand("save.all")]
            void cmdConsoleSave(ConsoleSystem.Arg arg)
            {
                if (arg.connection != null)
                {
                    if (arg.connection.authLevel < saveAuth)
                    {
                        SendReply(arg, noAccess);
                        return;
                    }
                }
                SaveRestore.Save();
                SendReply(arg, saved);
            }
            [ChatCommand("save")]
            void cmdChatSave(BasePlayer player, string command, string[] args)
            {
                if (!hasPermission(player)) { SendReply(player, noAccess); return; }
                SaveRestore.Save();
                SendReply(player, saved);
                if (args.Length > 0)
                {
                    float value;
                    if (float.TryParse(args[0], out value))
                    {
                        ConsoleSystem.Run.Server.Normal("server.saveinterval " + args[0], new object[] { });
                        SendReply(player, "set: server.saveinterval " + args[0]);
                    }
                }
            }
        }
    }
    
    [DOUBLEPOST=1428603888][/DOUBLEPOST]lol who claims that XD?
     
  15. return permission.UserHasPermission(player.userID.ToString(), "cananticheat"); lol :p
     
  16. There are billions of plugins out there to help you achieve it in 1 command :p
    this is an exemple in C#
    but look here: https://github.com/strykes/Oxide2Plugins
    i may not be the best in lua, but i was able to achieve most of what was needed to code on rust :p
    [DOUBLEPOST=1428603992][/DOUBLEPOST]
    lol
     
  17. Yeah right i'm learning from other plugins :p but i want to have one that contains a bit of everything .. but its not possible
     
  18. nooo not a bit of everything XD