1. Okay so today i started making a plugin and its named "Advanced Save System"
    I want to add for every command AuthLevel but i dont know how .. + i want to add in config AuthLevel Option... but i dont know how
    I tried to do this with "if player.net.connection.authLevel < 2 then return end" dunno if it works actualy .. and i want to set AuthLevel Option to config as i said help plz:)
    Code:
    PLUGIN.Title = "Advanced Save System"
    PLUGIN.Version = V(0, 1, 0)
    PLUGIN.Description = "Advanced Save System."
    PLUGIN.Author = "Merka"function PLUGIN:Init()
        command.AddChatCommand("steamid",  self.Plugin, "cmdSteamId")
        command.AddChatCommand("save",    self.Plugin, "cmdSave")
        command.AddChatCommand("setautosave_2m",  self.Plugin, "cmdas2m")
        command.AddChatCommand("setautosave_5m",  self.Plugin, "cmdas5m")
        command.AddChatCommand("setautosave_10m",  self.Plugin, "cmdas10m")
        command.AddChatCommand("setautosave_30m",  self.Plugin, "cmdas30m")
    end
    function PLUGIN:cmdSteamId(player, command, arg)
        rust.SendChatMessage(player, "SERVER", "Your Steam ID is: " .. rust.UserIDFromPlayer(player))
    end
    function PLUGIN:cmdSave(player,    command, arg)
    if player.net.connection.authLevel < 2 then return end
        rust.RunServerCommand("server.save")
    end
    function PLUGIN:cmdas2m(player, command, arg)
    if player.net.connection.authLevel < 2 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 player.net.connection.authLevel < 2 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 player.net.connection.authLevel < 2 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 player.net.connection.authLevel < 2 then return end
        rust.RunServerCommand("server.saveinterval 1800")
        rust.SendChatMessage(player, "Save-System", "You just set the AUTO-SAVE to 30minutes!")
    end
    function PLUGIN:OnServerSave()
        rust.BroadcastChat("Server-Save", "Save Process just finished!")
    end
    
     
  2. Wulf

    Wulf Community Admin

    I'd recommend using the Oxide permissions system instead of Rust's auth levels. If you want an example of using auth levels though, take a look at a lot of my plugins. http://oxidemod.org/plugins/ping.656/
     
  3. I want to start from easy things :p maybe in my next plugin i will use Oxide Permissions System. So that what i did works ?
    Code:
    if player.net.connection.authLevel < 2 then return end
    ?? So is there any tutorial.. how to add Authlevel to config ?
     
  4. Wulf

    Wulf Community Admin

    Look at my plugin. ;) All you really need to do is check a config setting per command, or one if you want the same level for all like my plugin does.
     
  5. I think i've did it !!
    Code:
    PLUGIN.Title = "Advanced Save System"
    PLUGIN.Version = V(0, 1, 0)
    PLUGIN.Description = "Advanced Save System."
    PLUGIN.Author = "Merka"
    PLUGIN.HasConfig = truefunction PLUGIN:LoadDefaultConfig()
        self.Config.Settings = self.Config.Settings or {}
        self.Config.Settings.AuthLevel = tonumber(self.Config.Settings.AuthLevel) or 2
        self:SaveConfig()
    endfunction PLUGIN:Init()    command.AddChatCommand("steamid",  self.Plugin, "cmdSteamId")
        command.AddChatCommand("save",    self.Plugin, "cmdSave")
        command.AddChatCommand("setautosave_2m",  self.Plugin, "cmdas2m")
        command.AddChatCommand("setautosave_5m",  self.Plugin, "cmdas5m")
        command.AddChatCommand("setautosave_10m",  self.Plugin, "cmdas10m")
        command.AddChatCommand("setautosave_30m",  self.Plugin, "cmdas30m")
    end
    function PLUGIN:cmdSteamId(player, command, arg)
        rust.SendChatMessage(player, "SERVER", "Your Steam ID is: " .. rust.UserIDFromPlayer(player))
    end
    function PLUGIN:cmdSave(player,    command, arg)
        rust.RunServerCommand("server.save")
    end
    function PLUGIN:cmdas2m(player, command, arg)
        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)
        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)
        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)
        rust.RunServerCommand("server.saveinterval 1800")
        rust.SendChatMessage(player, "Save-System", "You just set the AUTO-SAVE to 30minutes!")
    end
    function PLUGIN:OnServerSave()
        rust.BroadcastChat("Server-Save", "Save Process just finished!")
    end
    local function HasPermission(self, connection)
        local authLevel
        if connection then
            authLevel = connection.authLevel
        else
            authLevel = 2
        end
        if debug then print(connection.username .. " has auth level: " .. tostring(authLevel)) end
        local neededLevel = tonumber(self.Config.Settings.AuthLevel) or 2
        if authLevel and authLevel >= neededLevel then
            return true
        else
            return false
        end
    end
    
    and CONFIG
    Code:
    {
      "Settings": {
        "AuthLevel": 2
      }
    }
    
     
  6. Wulf

    Wulf Community Admin

    My HasPermissions is probably a little bit overkill for what you want, but you aren't actually using it in your code above, so all of your commands are wide open for every user. ;)
     
  7. Local function should be before main function where it's used
    + some code reduction
    Code:
    local function HasPermission(self, connection)
        local authLevel
        if connection then
            authLevel = connection.authLevel
        else
            authLevel = 2
        end
        if debug then print(connection.username .. " has auth level: " .. tostring(authLevel)) end
        local neededLevel = tonumber(self.Config.Settings.AuthLevel) or 2
        if authLevel and authLevel >= neededLevel then
            return true
        else
            return false
        end
    end
    
    to
    Code:
    local function HasPermission(self, connection)
        local authLevel = (connection and connection.authLevel) or 2
        if debug then print(connection.username .. " has auth level: " .. tostring(authLevel)) end
        local neededLevel = tonumber(self.Config.Settings.AuthLevel) or 2
        return authLevel >= neededLevel
    end
     
  8. SO it must be like this ?
    Code:
    PLUGIN.Title = "Advanced Save System"
    PLUGIN.Version = V(0, 1, 0)
    PLUGIN.Description = "Advanced Save System."
    PLUGIN.Author = "Merka"
    PLUGIN.HasConfig = truefunction PLUGIN:LoadDefaultConfig()
        self.Config.Settings = self.Config.Settings or {}
        self.Config.Settings.AuthLevel = tonumber(self.Config.Settings.AuthLevel) or 2
        self:SaveConfig()
    endfunction PLUGIN:Init()    command.AddChatCommand("steamid",  self.Plugin, "cmdSteamId")
        command.AddChatCommand("save",    self.Plugin, "cmdSave")
        command.AddChatCommand("setautosave_2m",  self.Plugin, "cmdas2m")
        command.AddChatCommand("setautosave_5m",  self.Plugin, "cmdas5m")
        command.AddChatCommand("setautosave_10m",  self.Plugin, "cmdas10m")
        command.AddChatCommand("setautosave_30m",  self.Plugin, "cmdas30m")
    end
    local function HasPermission(self, connection)
        local authLevel = connection.authLevel or 2
        if debug then print(connection.username .. " has auth level: " .. tostring(authLevel)) end
        local neededLevel = tonumber(self.Config.Settings.AuthLevel) or 2
        return authLevel >= neededLevel
    end
    function PLUGIN:cmdSteamId(player, command, arg)
        rust.SendChatMessage(player, "SERVER", "Your Steam ID is: " .. rust.UserIDFromPlayer(player))
    end
    function PLUGIN:cmdSave(player,    command, arg)
        rust.RunServerCommand("server.save")
    end
    function PLUGIN:cmdas2m(player, command, arg)
        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)
        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)
        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)
        rust.RunServerCommand("server.saveinterval 1800")
        rust.SendChatMessage(player, "Save-System", "You just set the AUTO-SAVE to 30minutes!")
    end
    function PLUGIN:OnServerSave()
        rust.BroadcastChat("Server-Save", "Save Process just finished!")
    end
    
     
  9. Wulf

    Wulf Community Admin

    Yes, but you still have to use the function before your command functions are run. You aren't checking if the user has permission.
     
  10. You posted after me didnt see ur msg :p your reply is UP post#8
     
  11. Wulf

    Wulf Community Admin

    I'm not sure what you mean, but my post still applies. :p
     
  12. Yes, but i have 1 fail:
    connection.authLevel or 2 -> (connection and connection.authLevel) or 2
     
  13. SO NOW MUST BE READY :) what about this
    Code:
    PLUGIN.Title = "Advanced Save System"
    PLUGIN.Version = V(0, 1, 0)
    PLUGIN.Description = "Advanced Save System."
    PLUGIN.Author = "Merka"
    PLUGIN.HasConfig = truefunction PLUGIN:LoadDefaultConfig()
        self.Config.Settings = self.Config.Settings or {}
        self.Config.Settings.AuthLevel = tonumber(self.Config.Settings.AuthLevel) or 2
        self:SaveConfig()
    endfunction PLUGIN:Init()    command.AddChatCommand("steamid",  self.Plugin, "cmdSteamId")
        command.AddChatCommand("save",    self.Plugin, "cmdSave")
        command.AddChatCommand("setautosave_2m",  self.Plugin, "cmdas2m")
        command.AddChatCommand("setautosave_5m",  self.Plugin, "cmdas5m")
        command.AddChatCommand("setautosave_10m",  self.Plugin, "cmdas10m")
        command.AddChatCommand("setautosave_30m",  self.Plugin, "cmdas30m")
    end
    local function HasPermission(self, connection)
         (connection and connection.authLevel) or 2
        if debug then print(connection.username .. " has auth level: " .. tostring(authLevel)) end
        local neededLevel = tonumber(self.Config.Settings.AuthLevel) or 2
        return authLevel >= neededLevel
    end
    function PLUGIN:cmdSteamId(player, command, arg)
        rust.SendChatMessage(player, "SERVER", "Your Steam ID is: " .. rust.UserIDFromPlayer(player))
    end
    function PLUGIN:cmdSave(player,    command, arg)
        rust.RunServerCommand("server.save")
    end
    function PLUGIN:cmdas2m(player, command, arg)
        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)
        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)
        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)
        rust.RunServerCommand("server.saveinterval 1800")
        rust.SendChatMessage(player, "Save-System", "You just set the AUTO-SAVE to 30minutes!")
    end
    function PLUGIN:OnServerSave()
        rust.BroadcastChat("Server-Save", "Save Process just finished!")
    end
    
     
  14. Wulf

    Wulf Community Admin

    Still missing the actual permission checking for each command. ;)
    Code:
    function PLUGIN:cmdSave(player, command, arg)
        if not HasPermission(self, player.net.connection) then return end
        rust.RunServerCommand("server.save")
    end
    And you replaced too much:
    Code:
    local function HasPermission(self, connection)
        local authLevel = (connection and connection.authLevel) or 2
        if debug then print(connection.username .. " has auth level: " .. tostring(authLevel)) end
        local neededLevel = tonumber(self.Config.Settings.AuthLevel) or 2
        return authLevel >= neededLevel
    end
     
  15. so with this fucnction u need to use it like:

    Code:
    function PLUGIN:cmdSteamId(player, command, arg)
        if HasPermission(self, player) then
            rust.SendChatMessage(player, "SERVER", "Your Steam ID is: " .. rust.UserIDFromPlayer(player))
        end
    end
     
  16. For god sake.. xD sry for beeing so retarded but still learning what about this ?
    Code:
    PLUGIN.Title = "Advanced Save System"
    PLUGIN.Version = V(0, 1, 0)
    PLUGIN.Description = "Advanced Save System."
    PLUGIN.Author = "Merka"
    PLUGIN.HasConfig = truefunction PLUGIN:LoadDefaultConfig()
        self.Config.Settings = self.Config.Settings or {}
        self.Config.Settings.AuthLevel = tonumber(self.Config.Settings.AuthLevel) or 2
        self:SaveConfig()
    endfunction PLUGIN:Init()    command.AddChatCommand("steamid",  self.Plugin, "cmdSteamId")
        command.AddChatCommand("save",    self.Plugin, "cmdSave")
        command.AddChatCommand("setautosave_2m",  self.Plugin, "cmdas2m")
        command.AddChatCommand("setautosave_5m",  self.Plugin, "cmdas5m")
        command.AddChatCommand("setautosave_10m",  self.Plugin, "cmdas10m")
        command.AddChatCommand("setautosave_30m",  self.Plugin, "cmdas30m")
    end
    local function HasPermission(self, connection)
         (connection and connection.authLevel) or 2
        if debug then print(connection.username .. " has auth level: " .. tostring(authLevel)) end
        local neededLevel = tonumber(self.Config.Settings.AuthLevel) or 2
        return authLevel >= neededLevel
    end
    function PLUGIN:cmdSteamId(player, command, arg)
        if HasPermission(self, player:GetComponent("BaseNetworkable").net.connection) then
        rust.SendChatMessage(player, "SERVER", "Your Steam ID is: " .. rust.UserIDFromPlayer(player))
    end
    function PLUGIN:cmdSave(player,    command, arg)
    if HasPermission(self, player:GetComponent("BaseNetworkable").net.connection) then
        rust.RunServerCommand("server.save")
    end
    function PLUGIN:cmdas2m(player, command, arg)
    if HasPermission(self, player:GetComponent("BaseNetworkable").net.connection) then
        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 HasPermission(self, player:GetComponent("BaseNetworkable").net.connection) then
        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 HasPermission(self, player:GetComponent("BaseNetworkable").net.connection) then
        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 HasPermission(self, player:GetComponent("BaseNetworkable").net.connection) then
        rust.RunServerCommand("server.saveinterval 1800")
        rust.SendChatMessage(player, "Save-System", "You just set the AUTO-SAVE to 30minutes!")
    end
    function PLUGIN:OnServerSave()
        rust.BroadcastChat("Server-Save", "Save Process just finished!")
    end
    
     
  17. Wulf

    Wulf Community Admin

    Your if checks are a bit more than you need, and you're missing some closing tags for the if statements.
     
  18. Not sure what you want but changed something hope this is what you told me to do
    Code:
    PLUGIN.Title = "Advanced Save System"
    PLUGIN.Version = V(0, 1, 0)
    PLUGIN.Description = "Advanced Save System."
    PLUGIN.Author = "Merka"
    PLUGIN.HasConfig = truefunction PLUGIN:LoadDefaultConfig()
        self.Config.Settings = self.Config.Settings or {}
        self.Config.Settings.AuthLevel = tonumber(self.Config.Settings.AuthLevel) or 2
        self:SaveConfig()
    endfunction PLUGIN:Init()    command.AddChatCommand("steamid",  self.Plugin, "cmdSteamId")
        command.AddChatCommand("save",    self.Plugin, "cmdSave")
        command.AddChatCommand("setautosave_2m",  self.Plugin, "cmdas2m")
        command.AddChatCommand("setautosave_5m",  self.Plugin, "cmdas5m")
        command.AddChatCommand("setautosave_10m",  self.Plugin, "cmdas10m")
        command.AddChatCommand("setautosave_30m",  self.Plugin, "cmdas30m")
    end
    local function HasPermission(self, connection)
         (connection and connection.authLevel) or 2
        if debug then print(connection.username .. " has auth level: " .. tostring(authLevel)) end
        local neededLevel = tonumber(self.Config.Settings.AuthLevel) or 2
        return authLevel >= neededLevel
    end
    function PLUGIN:cmdSteamId(player, command, arg)
        if HasPermission(self, player:GetComponent("BaseNetworkable").net.connection) then
        rust.SendChatMessage(player, "SERVER", "Your Steam ID is: " .. rust.UserIDFromPlayer(player))
    end
    function PLUGIN:cmdSave(player,    command, arg)
        if HasPermission(self, player:GetComponent("BaseNetworkable").net.connection) then
        rust.RunServerCommand("server.save")
    end
    function PLUGIN:cmdas2m(player, command, arg)
        if HasPermission(self, player:GetComponent("BaseNetworkable").net.connection) then
        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 HasPermission(self, player:GetComponent("BaseNetworkable").net.connection) then
        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 HasPermission(self, player:GetComponent("BaseNetworkable").net.connection) then
        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 HasPermission(self, player:GetComponent("BaseNetworkable").net.connection) then
        rust.RunServerCommand("server.saveinterval 1800")
        rust.SendChatMessage(player, "Save-System", "You just set the AUTO-SAVE to 30minutes!")
    end
    function PLUGIN:OnServerSave()
        rust.BroadcastChat("Server-Save", "Save Process just finished!")
    end
    
     
  19. Wulf

    Wulf Community Admin

    Try running it on the server, you'll see. ;)
    Code:
    function PLUGIN:cmdSave(player, command, arg)
        if HasPermission(self, player.net.connection) then
            rust.RunServerCommand("server.save")
        end
    end
    This would also work:
    Code:
    function PLUGIN:cmdSave(player, command, arg)
        if not HasPermission(self, player.net.connection) then return end
        rust.RunServerCommand("server.save")
    end
     
  20. Ready to Publish xD?
    Code:
    PLUGIN.Title = "Advanced Save System"
    PLUGIN.Version = V(0, 1, 0)
    PLUGIN.Description = "Advanced Save System."
    PLUGIN.Author = "Merka"
    PLUGIN.HasConfig = truefunction PLUGIN:LoadDefaultConfig()
        self.Config.Settings = self.Config.Settings or {}
        self.Config.Settings.AuthLevel = tonumber(self.Config.Settings.AuthLevel) or 2
        self:SaveConfig()
    endfunction PLUGIN:Init()    command.AddChatCommand("steamid",  self.Plugin, "cmdSteamId")
        command.AddChatCommand("save",    self.Plugin, "cmdSave")
        command.AddChatCommand("setautosave_2m",  self.Plugin, "cmdas2m")
        command.AddChatCommand("setautosave_5m",  self.Plugin, "cmdas5m")
        command.AddChatCommand("setautosave_10m",  self.Plugin, "cmdas10m")
        command.AddChatCommand("setautosave_30m",  self.Plugin, "cmdas30m")
    end
    local function HasPermission(self, connection)
         (connection and connection.authLevel) or 2
        if debug then print(connection.username .. " has auth level: " .. tostring(authLevel)) end
        local neededLevel = tonumber(self.Config.Settings.AuthLevel) or 2
        return authLevel >= neededLevel
    end
    function PLUGIN:cmdSteamId(player, command, arg)
        if not HasPermission(self, player.net.connection) then return end
        rust.SendChatMessage(player, "SERVER", "Your Steam ID is: " .. rust.UserIDFromPlayer(player))
    end
    function PLUGIN:cmdSave(player,    command, arg)
        if not HasPermission(self, player.net.connection) then return end
        rust.RunServerCommand("server.save")
    end
    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
    function PLUGIN:OnServerSave()
        rust.BroadcastChat("Server-Save", "Save Process just finished!")
    end