Player Ranks

Player ranks and stats database

Total Downloads: 4,901 - First Release: Mar 4, 2017 - Last Update: May 29, 2018

5/5, 19 likes
  1. Steenamaroo updated PlayerRanks with a new update entry:

    1.1.4

     
  2. @Steenamaroo No Update Attachment Found when pressing the download button.
     
  3. go to history and clic on the first 1.1.4 (second line)
     
  4. It double-posted and hung when I launched the update.

    I'll reattach to see if that helps.
     
  5. Steenamaroo updated PlayerRanks with a new update entry:

    1.1.4


    [DOUBLEPOST=1492281301][/DOUBLEPOST]Fixed.
     
  6. @Steenamaroo, there is a problem while you use /pr tops and try to close UI, it just create new UI without closing old one
     
  7. Thank you, Sami. I'll look into it ASAP.

    I haven't dismissed your names issue.
    I wasn't able to recreate, even using all the names you sent me, but if it's still happening for you I'll need to dig deeper.
    Please let me know.
     
  8. From now it just doesn't happen anymore, so, i think it's solved but idk how xD
     
  9. Great news.
    As I said, I don't really know much about SQL but I know I was getting console reports from v1.1.2 long after I updated to 1.1.3, for example.
    There's every chance you were getting lingering errors , I suppose, but don't be afraid to PM or post here if it happens again.

    The close issue - I can't replicate it either.
    Is your server and oxide 100% up to date? There is an issue with the cursor resetting to centre screen at intervals.
    Any chance that's related?
     
  10. Currently you're using timer.Once to trigger the save and not timer.Every, which is why it only saves once after the first 30 minutes but doesn't again repeat after another 30 minutes.
    To fix this change from
    Code:
    timer.Once(saveTimer * 60, () => SaveTrigger());
    to
    Code:
    timer.Every(saveTimer * 60, () => SaveTrigger());
    You also don't need a timer in the Save Trigger function here
    Code:
            void SaveTrigger()
            {
                timer.Once(saveTimer * 60, () => SaveData()); //publicly reports saving on the timer
                Puts("Player Ranks Local Database Was Saved.");
                if (useMySQL)
                {
                    LoadMySQL();
                }
            }
    You just need
    Code:
            void SaveTrigger()
            {
                SaveData(); //publicly reports saving on the timer
                Puts("Player Ranks Local Database Was Saved.");
                if (useMySQL)
                {
                    LoadMySQL();
                }
            }
    Or if you want to have it save whenever the server saves instead of having mismatched times you can do this as well.

    Code:
            void OnServerSave()
            {
                if (initialized) SaveTrigger(); //saves the database when the server saves
            }
    But, if you do that you also need to add and enable (initialized), not sure where exactly this should go, I think it's a region variable? I put it under line 26 and I know it works there.
    Code:
            bool HasPermission(string id, string perm) => permission.UserHasPermission(id, perm); //Line 26
            bool initialized; //Add this under as new line 27
    After that you need to set it to true in OnServerInitialized, to do that change
    Code:
            void OnServerInitialized()
            {
                lang.RegisterMessages(messages, this);
                PRData = Interface.Oxide.DataFileSystem.GetFile("PlayerRanks");
                LoadData();
                LoadVariables();
                cmd.AddChatCommand($"{chatCommandAlias}", this, "cmdTarget");
                CheckDependencies();
                if (useTimedTopList)
                    {
                        timer.Once(TimedTopListTimer * 60, () => pvpkills());
                    }
                   
                foreach(BasePlayer player in BasePlayer.activePlayerList)
                {
                    OnPlayerInit(player);
                }
                timer.Once(saveTimer * 60, () => SaveTrigger());
                if (useMySQL)
                {
                    LoadMySQL();
                }
    to
    Code:
            void OnServerInitialized()
            {
                lang.RegisterMessages(messages, this);
                PRData = Interface.Oxide.DataFileSystem.GetFile("PlayerRanks");
                LoadData();
                LoadVariables();
                cmd.AddChatCommand($"{chatCommandAlias}", this, "cmdTarget");
                CheckDependencies();
                if (useTimedTopList)
                    {
                        timer.Once(TimedTopListTimer * 60, () => pvpkills());
                    }
                initialized = true;
                foreach(BasePlayer player in BasePlayer.activePlayerList)
                {
                    OnPlayerInit(player);
                }
    Edit: The only C# I know is what I learned figuring out how to fix this and looking at other plugins, so I'm not sure if your other timers are good/working or not or even if what I changed is right, I just know it works.
     
    Last edited by a moderator: Apr 19, 2017
  11. Hi,
    Thanks for pointing that out.
    I'd rather have the customisable timer for people who want SQL saved at more frequent intervals.

    I changed the saving system in a rush because the saveloop was getting called by several things, but I didn't realise I forgot to loop it. :p
    I also didn't know timer.Every was a thing, so thanks for that. ;)


    Just having this under onserverinitialised

    Code:
                timer.Every(saveTimer * 60, () =>
                {
                SaveData();
                Puts("Player Ranks Local Database Was Saved.");
                if (useMySQL)
                {
                    LoadMySQL();
                }
                }
                );//publicly reports saving on the timer
    
    and this

    Code:
            void SaveData()
            {
                PRData.WriteObject(data); //silently saves the database at other times, such as pr del...pr wipe etc
            }
    with savetrigger removed, does what I want.

    Saves on the user-timer are printed to console, and saves that happen on del/wipe/pr save etc are not.

    Basically, it was fine before but I didn't want console save spam every time an admin command was carried out.
    Will tidy it up in next V. Thank you.

    I'm also just going to escape special characters in the mysql save.
    Thank you Sami for your time and input on that.
     
    Last edited by a moderator: Apr 19, 2017
  12. Steenamaroo updated PlayerRanks with a new update entry:

    1.1.5

     
  13. Yeah, I looked at the oxide docs and it doesn't have timer.Every listed on there for some reason. Anyways, glad I could help :)
     
  14. Wulf

    Wulf Community Admin

    The timer.Every method is the same as timer.Repeat(1, 0 ... Not all methods are documented.
     
  15. Code:
    Failed to call hook 'OnExplosiveThrown' on plugin 'PlayerRanks v1.1.5' (InvalidCastException: Cannot cast from source type to destination type.)
    One of our users threw survey charges to find oil & ore
     
  16. Thank you. Will sort. :)
     
  17. That's what I figured, I didn't really know what I was doing so my main method of figuring stuff out was just looking thru other plugins and that's where I found timer.Every.
    [DOUBLEPOST=1492719401][/DOUBLEPOST]@Steenamaroo Just realized something without using OnServerSave() or there being a console command that you can add to auto run, there isn't a method to save before automatic restarts. Maybe add a option in the config to use OnServerSave or a Timer? Not sure how difficult that would be.
     
  18. Thanks for your thoughts, man.
    It saves on Unload, which I thought would cover-all, but recently learned that plugins don't necessarily unload under all server-restart/stop circumstances.

    If I server.restart via rcon I'll see everything unload one by one, but if I restart via GameServers control panel, that doesn't happen.

    I'll add config true/false for savetimer.
    If it's false, then OnServerSave will be the default.
     
  19. I'm not getting this.
    Were there any additional circumstances?
     
  20. Afaik not. Only that guy I was talking to who threw like survey charges. We also had this message like 30 times with only 5-6 people online. Most of them probably crafting so i really think it was coming from him. Should I test it further on my server when the message appears?

    I also scanned all plugins for "OnExplosiveThrown" and only yours used that hook.