PlayerDatabase

Big database with light weight way to save it to prevent lag

Total Downloads: 714 - First Release: May 30, 2016 - Last Update: Jan 11, 2017

5/5, 5 likes
  1. mobileberlin

    mobileberlin Naked Wanderer

    Hi, can you add ResourceId variable for "Updater" Support, please?
     
  2. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    For this plugin, change [Info("PlayerDatabase", "Reneb", "1.5.5")] to [Info("PlayerDatabase", "Reneb", "1.5.5", ResourceId = 1939)]

    Keep in mind as soon as you download another version of this, it will no longer have that unless the author adds it.
     
    mobileberlin likes this.
  3. mobileberlin

    mobileberlin Naked Wanderer

    wonderful thx :)
     
  4. Reneb

    Reneb Grenade Master Plugin Developer

    >:) mouhahahaha! and i won't!







    ...
    unless i remember to ^^
     
  5. STANNIS BARATHEON

    STANNIS BARATHEON Scavenger

    Hey there, I don't know quite how to interpret these errors; this is after the most recent PlayerDatabase update -
    Code (Text):


    (23:26:59) | [Oxide] 23:25 [Error] MySql command callback raised an exception (InvalidCastException: Cannot cast from source type to destination type.)
    (23:26:59) | [Oxide] 23:25 [Debug]   at Oxide.Plugins.PlayerDatabase+<LoadPlayerSQL>c__AnonStorey1.<>m__0 (System.Collections.Generic.List`1 list) [0x00000] in <filename unknown>:0
      at Oxide.Core.MySql.Libraries.MySql+MySqlQuery+<Handle>c__AnonStorey0.<>m__0 () [0x00000] in <filename unknown>:0
    (23:28:03) | [Oxide] 23:26 [Error] MySql command callback raised an exception (InvalidCastException: Cannot cast from source type to destination type.)
    (23:28:03) | [Oxide] 23:26 [Debug]   at Oxide.Plugins.PlayerDatabase+<LoadPlayerSQL>c__AnonStorey1.<>m__0 (System.Collections.Generic.List`1 list) [0x00000] in <filename unknown>:0
      at Oxide.Core.MySql.Libraries.MySql+MySqlQuery+<Handle>c__AnonStorey0.<>m__0 () [0x00000] in <filename unknown>:0
    (23:28:20) | [Oxide] 23:26 [Warning] Calling 'OnPlayerInit' on 'RustIO v2.9.0' took 268ms
    (23:28:20) | [Oxide] 23:26 [Error] MySql command callback raised an exception (InvalidCastException: Cannot cast from source type to destination type.)
    (23:28:20) | [Oxide] 23:26 [Debug]   at Oxide.Plugins.PlayerDatabase+<LoadPlayerSQL>c__AnonStorey1.<>m__0 (System.Collections.Generic.List`1 list) [0x00000] in <filename unknown>:0
      at Oxide.Core.MySql.Libraries.MySql+MySqlQuery+<Handle>c__AnonStorey0.<>m__0 () [0x00000] in <filename unknown>:0
    (23:28:31) | [Oxide] 23:26 [Warning] Calling 'OnPlayerInit' on 'RustIO v2.9.0' took 291ms
    (23:28:31) | [Oxide] 23:26 [Error] MySql command callback raised an exception (InvalidCastException: Cannot cast from source type to destination type.)
    (23:28:31) | [Oxide] 23:26 [Debug]   at Oxide.Plugins.PlayerDatabase+<LoadPlayerSQL>c__AnonStorey1.<>m__0 (System.Collections.Generic.List`1 list) [0x00000] in <filename unknown>:0
      at Oxide.Core.MySql.Libraries.MySql+MySqlQuery+<Handle>c__AnonStorey0.<>m__0 () [0x00000] in <filename unknown>:0
     
  6. Reneb

    Reneb Grenade Master Plugin Developer

    wrong sql configs
     
  7. Reneb

    Reneb Grenade Master Plugin Developer

  8. GIGISTONE

    GIGISTONE Naked Wanderer

    Hi Reneb, i have the same problem : (casting exception on loadallplayer) last version.
    I don't know quite how to interpret these castings errors too.

    my mysql config seems good, i dont understand where it is wrong :

    http://i.imgur.com/mNE1H8r.png
    http://i.imgur.com/1JtG45V.png

    Can you help me please ?
     
    Last edited: Jan 11, 2017
  9. Reneb

    Reneb Grenade Master Plugin Developer

    show me the error and the situation of the problem.
     
  10. GIGISTONE

    GIGISTONE Naked Wanderer

    Ok. i found the issue, it is in your script :


    your function :

    Code (Text):
            void LoadPlayerSQL(string userid)
            {
                if (!sqlData.ContainsKey(userid)) sqlData.Add(userid, new Hash<string, string>());
                bool newplayer = true;
                Sql.Query(Core.Database.Sql.Builder.Append(string.Format("SELECT * from playerdatabase WHERE `userid` = '{0}'", userid)), Sql_conn, list =>
                {
                    if (list != null)
                    {
                        foreach (var entry in list)
                        {
                            foreach (var p in entry)
                            {
                                Puts("DEBUG: column: " + p.ToString()); // print added by me here.
                                sqlData[userid][p.Key] = (string)p.Value;
                            }
                            newplayer = false;
                        }
                    }
                    if (newplayer)
                    {
                        sqlData[userid]["userid"] = userid;
                        Sql.Insert(Core.Database.Sql.Builder.Append(string.Format("INSERT IGNORE INTO playerdatabase ( userid ) VALUES ( {0} )", userid)), Sql_conn);

                        changedPlayersData.Add(userid);
                    }
                });
            }

    runtime problem location :

    Code (Text):
    [PlayerDatabase] DEBUG: column: [id, 0]
    MySql command callback raised an exception (InvalidCastException: Cannot cast from source type to destination type.)
      at Oxide.Plugins.PlayerDatabase+<LoadPlayerSQL>c__AnonStorey1.<>m__0 (System.Collections.Generic.List`1 list) [0x00000] in <filename unknown>:0
      at Oxide.Core.MySql.Libraries.MySql+MySqlQuery+<Handle>c__AnonStorey0.<>m__0 () [0x00000] in <filename unknown>:0


    in your .LoadMysql() method :

    Code (Text):
    Sql.Insert(Core.Database.Sql.Builder.Append("CREATE TABLE IF NOT EXISTS playerdatabase ( `id` int(11) NOT NULL, `userid` VARCHAR(17) NOT NULL );"), Sql_conn);

    You have created a column with int type. Then, while the foreach iterates (from loadplayersql), when you get columns values, you try to cast the value of "id", which is an integer, to a string :

    Code (Text):
                            foreach (var p in entry)
                            {
                                sqlData[userid][p.Key] = (string)p.Value;
                            }

    you can't explicitly cast an int to a string in c# ( (string)int ).

    In any case, i think it is not necessary to create this column, it is obsolete.
     
    Last edited: Jan 11, 2017
    Canopy Sheep likes this.
  11. Reneb

    Reneb Grenade Master Plugin Developer

    Reneb updated PlayerDatabase with a new update entry:

    1.5.7

    Read the rest of this update entry...
    --- Double Post Merged, Jan 11, 2017 ---
    had the issue with SQLite, fixed it, i forgot to fix it with mysql also ^^
     
    Canopy Sheep and GIGISTONE like this.
  12. MR.Putin

    MR.Putin Naked Wanderer

    Hi. i have a problem with you config.
    this's my config

    static int dataTypeCfg = 2;

    static string sqlitename = "playerdatabase.db";

    static string sql_host = "localhost";
    static int sql_port = 3306;
    static string sql_db = "rust";
    static string sql_user = "root";
    static string sql_pass = "1150";


    1:28 PM [Error] MySql handle raised an exception in 'PlayerDatabase v1.5.7' plugin (MySqlException: Unknown database 'rust')
    1:28 PM [Stacktrace] at MySql.Data.MySqlClient.MySqlStream.ReadPacket () [0x00000] in <filename unknown>:0
    at MySql.Data.MySqlClient.NativeDriver.ReadPacket () [0x00000] in <filename unknown>:0
    at MySql.Data.MySqlClient.Authentication.MySqlAuthenticationPlugin.ReadPacket () [0x00000] in <filename unknown>:0
    13:28 [Info] Unloaded plugin PlayerDatabase v1.5.7 by Reneb
     
  13. GIGISTONE

    GIGISTONE Naked Wanderer

    1:28 PM [Error] MySql handle raised an exception in 'PlayerDatabase v1.5.7' plugin (MySqlException: Unknown database 'rust')

    the name of your db is incorrect.

    np, useful plugin thanks !
     
  14. MR.Putin

    MR.Putin Naked Wanderer

    i need to create "rust" database?
     
  15. GIGISTONE

    GIGISTONE Naked Wanderer

    Yes, just create an empty (or existing) database, with the name you want and add his name in the plugin cfg.
     
  16. MR.Putin

    MR.Putin Naked Wanderer

    in database can add vip or other? or just pick id and ip?
     
  17. GIGISTONE

    GIGISTONE Naked Wanderer

    Yes if you want, just call plugin methods (read the plugin overview). You don't need to create the column yourself, she will created by the plugin (LONGTEXT type).
     
    Last edited: Jan 11, 2017
  18. WildWire

    WildWire Scavenger

    how do i add player statistings to the database? Kills, Clans etc etc, deaths

    i have no clue how to call the plugin can anyone explain me?
     
    Last edited: Jan 16, 2017 at 1:17 AM
  19. WildWire

    WildWire Scavenger

    Hello everyone is there way to get Kills and Deaths to MySQL with player database plugin,
    If yes i would like to have some help with it, i cannot figure it out.