PlayerDatabase

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

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

5/5, 8 likes
  1. Hi, can you add ResourceId variable for "Updater" Support, please?
     
  2. Wulf

    Wulf Community Admin

    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.
     
  3. wonderful thx :)
     
  4. >:) mouhahahaha! and i won't!







    ...
    unless i remember to ^^
     
  5. Hey there, I don't know quite how to interpret these errors; this is after the most recent PlayerDatabase update -
    Code:
    (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. wrong sql configs
     
  7. Reneb updated PlayerDatabase with a new update entry:

    1.5.6

     
  8. 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 by a moderator: Jan 11, 2017
  9. show me the error and the situation of the problem.
     
  10. Ok. i found the issue, it is in your script :


    your function :

    Code:
            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:
    [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:
    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:
                            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 by a moderator: Jan 11, 2017
  11. Reneb updated PlayerDatabase with a new update entry:

    1.5.7


    [DOUBLEPOST=1484169565][/DOUBLEPOST]
    had the issue with SQLite, fixed it, i forgot to fix it with mysql also ^^
     
  12. 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. 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. i need to create "rust" database?
     
  15. Yes, just create an empty (or existing) database, with the name you want and add his name in the plugin cfg.
     
  16. in database can add vip or other? or just pick id and ip?
     
  17. 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 by a moderator: Jan 11, 2017
  18. 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 by a moderator: Jan 16, 2017
  19. 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.
     
  20. So from what Wild Wire said
    I was thinking, is there a way to also show the players entity count?