1. Im having issues using the DataTables.
    1. The values somehow get saved, but they don't show up in the file.
    2. I cant clear those.
    Propably just totally failing.

    I would post my code in PM. But i don't want to do that here right now.
     
  2. Wulf

    Wulf Community Admin

    self:SaveDataFile()
     
  3. Code:
    datafile.SaveDataTable("pluginname")
    did that
     
  4. Wulf

    Wulf Community Admin

    Without seeing the code, it'd be hard to tell then. I would recommend trying what I mentioned though.
     
  5. Yes but as in the docs, datafile.SaveDataTable("pluginname")
    is exactly whats is in "self:SaveDataFile()"
    Also as I said I could write you the code
     
  6. Wulf

    Wulf Community Admin

    Actually, ignore me, that was an internal function. What you listed should be working. Are you sure that code is being hit?
     
  7. Yes I am. As I said I guess showing you the code would be easier then just descibing it everytime
     
  8. Wulf

    Wulf Community Admin

    Is there a need for the code to be private? Make sure you are creating the empty table first as well.
     
  9. Well I just don't want to share it before I release it.
    Yes Im doing that too...
     
  10. Wulf

    Wulf Community Admin

    That makes it a bit hard to get help from the community. The whole purpose of the development section is for peer review. ;)

    The more review done now, the less issues you run into later.
     
  11. Well yeah, just gonna post it here.

    Here it goes:
    Code:
    PLUGIN.Title        = "Admin Reports"
    PLUGIN.Description  = "Gives players the opportunity to send reports to admins"
    PLUGIN.Author       = "LaserHydra"
    PLUGIN.Version      = V(1,0,0)
    PLUGIN.ResourceId    = "?"function PLUGIN:Init()
        command.AddChatCommand("report", self.Object, "cmdReport")
    endfunction PLUGIN:LoadDataFiles()
        reports = datafile.GetDataTable("adminreports") or {}
    endfunction PLUGIN:cmdReport(player, cmd, args)
        reports = datafile.GetDataTable("adminreports") or {}
        local allArgs = ""
        local arg = args:GetEnumerator()
        local userId = rust.UserIDFromPlayer(player)
       
        while arg:MoveNext() do
            allArgs = allArgs .. " " .. arg.Current
        end
       
        if args.Length == 0 then
           
            rust.SendChatMessage(player, "<color=aqua>Admin Reports:</color>")
            rust.SendChatMessage(player, "/report message")
            if player.net.connection.authLevel >= 1 then
                rust.SendChatMessage(player, "/report list")
            end
           
        elseif args.Length > 0 then
           
            if args.Length == 1 and player.net.connection.authLevel >= 1 and args[0] == "list" then
               
                if #reports == 0  then
                    rust.SendChatMessage(player, "<color=cyan>Reports</color><color=white>", "</color>There currently are no reports!")
                    return false
                end
               
                if #reports >= 1 then
                    rust.SendChatMessage(player, "<color=cyan>Reports</color><color=white>", "</color>Following reports has been made:")
                    for report, data in pairs(reports) do
                        rust.SendChatMessage(player, "<color=cyan>-----------------------------------</color>")
                        rust.SendChatMessage(player, "<color=cyan>Player</color><color=white>", "</color>" .. data.player)
                        rust.SendChatMessage(player, "<color=cyan>SteamID</color><color=white>", "</color>" .. data.steamId)
                        rust.SendChatMessage(player, "<color=cyan>Message</color><color=white>", "</color>" .. data.message)
                        rust.SendChatMessage(player, "<color=cyan>-----------------------------------</color>")
                    end
                end
                    return false
            end
           
            if args.Length == 1 and player.net.connection.authLevel >= 1 and args[0] == "clear" then
                reports = {}
                datafile.SaveDataTable("adminreports")
                rust.SendChatMessage(player, "<color=cyan>Reports</color><color=white>", "</color>List of Reports successfully cleared.")
                return false
            end
           
            local report = {}
            report.player = player.displayName
            report.steamId = rust.UserIDFromPlayer(player)
            report.message = allArgs
       
            table.insert(reports, report)
            datafile.SaveDataTable("adminreports")
           
            rust.SendChatMessage(player, "<color=cyan>Reports</color><color=white>", "</color>You have sent following report:")
            rust.SendChatMessage(player, "<color=cyan>-----------------------------------</color>")
            rust.SendChatMessage(player, "<color=cyan>Player</color><color=white>", "</color>" .. report.player)
            rust.SendChatMessage(player, "<color=cyan>SteamID</color><color=white>", "</color>" .. report.steamId)
            rust.SendChatMessage(player, "<color=cyan>Message</color><color=white>", "</color>" .. report.message)
            rust.SendChatMessage(player, "<color=cyan>-----------------------------------</color>")
           
        end       
    end
    [DOUBLEPOST=1432664719][/DOUBLEPOST]What am I doing wrong?
     
  12. Remove the GetDataTable in cmdReport
     
  13. Didnt have that before, but that didnt work too. let me try again.
    [DOUBLEPOST=1432665086][/DOUBLEPOST]Wow now it works... um thanks :)
    [DOUBLEPOST=1432665158][/DOUBLEPOST]Now still the file seems to be empty though...
    [DOUBLEPOST=1432668522][/DOUBLEPOST]@Hatemail @Wulf thanks
    http://oxidemod.org/plugins/admin-reports-reporting-system.1065/
     
    Last edited by a moderator: May 26, 2015