Hello .. Good evening!
I'm trying to get MySql class in my plugin, the more I'm having trouble.
I'm new in the creation of plugins, then create straight at the root, to help me with details, and have been successful. so I'm having trouble now with MySql!
Here is a print
Please, Help-me!
Solved Trouble using MySQL extension
Discussion in 'Rust Development' started by Darkesh, Sep 14, 2016.
-
Attached Files:
Last edited by a moderator: Sep 15, 2016 -
-
Wulf Community Admin
First, if you are making a plugin, the namespace needs to be Oxide.Plugins. The class also needs to match your filename and have a base such as RustPlugin. From there, everything you need is under Oxide.Core.Database.
-
Sorry!
This was already done, and I ended up generating this file only to illustrate the error and where I'm creating it!
Oxide.Core.Database, I do not need to call the mysql namespace? I had read something about it!
Example: Oxide.Ext.MySql
[DOUBLEPOST=1473900767][/DOUBLEPOST]My project and make an online database, to create a certain interactivity.
Standing could generate some examples!
I mess up! Sorry! -
??
Then? -
Wulf Community Admin
Oxide.Core.Database is all that is needed in most cases, but there may still be some references to Oxide.Ext.MySql. -
Give me an example script instantiating a class?
[DOUBLEPOST=1473969429][/DOUBLEPOST]All right, I instantiate the Connection class, but I'm not managing to make a connection in MySql! -
Wulf Community Admin
Take a look at DonationClaim | Oxide. -
Then the way runs would be:
so was the process?Code:Using Oxide.Core.Database; namespace Oxide.Plugins { public class nomedoplugin: RustPlugin { Connection conn; // Example CONNECTION to the database; public void Init () { conn = mySql.OpenDb (host, database, user, password, port); // From now on I am connected to the database, then you would only pass the commands via MySql Query. mySql.Query (conn, "Database commands"); } } }
[DOUBLEPOST=1473971290][/DOUBLEPOST]My problem is that I can not instantiate the mySql at Oxide.Ext!
[DOUBLEPOST=1473971962][/DOUBLEPOST]Code:readonly Ext.MySql.Libraries.MySql mySql = new Ext.MySql.Libraries.MySql();
My Plugin now. ?Code:using System; using Oxide.Core.Database;namespace Oxide.Plugins { [Info("Teste", "none", "0.0.0.1")] [Description("teste")] public class Teste : RustPlugin { Connection conn; public string host = "localhost"; public string db = "dbtest"; public string user = "root"; public string pass = "123"; public void Init() { } } }
Please Help-me! -
Wulf takes more even help at the time of connection and the way it should be implemented database commands, hence forth I can finish the plugin!
I really need help because right now I'm stuck. -
Wulf Community Admin
I have very little experience with the MySQL extension, so right now your guess is as good as mine. -
Kk! then I think I was really stuck!
I will try, if not get, I'll try methods to circumvent!
Vlw Wulf!
If one community is reading and know how to help me, I accept!
C # know sulficiente to schedule, the more this world of plugins and new to me!
[DOUBLEPOST=1473974448][/DOUBLEPOST]I would like to try the SQLite, but I believe that I will be arrested, because I have never worked with this type of database programming!
If you wulf some experience with it, please help me! -
So wait what are you having issues with I am confused?
-
I want to work with an online database through MySql.
The problem is that I know C # more not dominate the programming altogether, so I have a little trouble!
I can not call the MySql instance to make the connection, or at least have no idea of how to call through the Oxide.
This is my problem, call and make the connection with MySql plugin!
I can not instantiate through the Oxide.Ext.MySql,
Then Wulf recommended me Oxide.Core.Database more ficnado just the same!
[DOUBLEPOST=1473977017][/DOUBLEPOST]"
I can not instantiate through the Oxide.Ext.MySql,
Then Wulf recommended me Oxide.Core.Database, most ended up staying in it!
" **
Translated by Google Translate
[DOUBLEPOST=1473977131][/DOUBLEPOST]Dylan,
If you can help me, I am grateful!
First time I develop plugins, have success in my work, the problem and only this, cannot make the connection with mysql, I have no idea how to alert by oxide -
Here's a example of connecting and creating a table:
[DOUBLEPOST=1473977376][/DOUBLEPOST]Example of sending a command to a table:Code:using Oxide.Core; using System.Collections.Generic; using Oxide.Core.Database; using Oxide.Ext.MySql; using MySql.Data; using MySql.Data.MySqlClient; using UnityEngine; using Oxide.Game.Rust.Cui; using System.Text.RegularExpressions; using System;namespace Oxide.Plugins { [Info("SQL Testing", "DylanSMR", "1.0.0", ResourceId = 0)] [Description("SQL Test")] public class SqlTest : RustPlugin { ConfigFile Cfg = new ConfigFile(); class ConfigFile { public string Host = "localhost"; public int Port = 3306; public string Database = "databasehere"; public string User = "root"; public string Password = "password"; } public static readonly Oxide.Ext.MySql.Libraries.MySql _mySql = Interface.Oxide.GetLibrary<Oxide.Ext.MySql.Libraries.MySql>(); public static Connection _mySqlConnection; private void Loaded() { Cfg = Config.ReadObject<ConfigFile>(); _mySqlConnection = _mySql.OpenDb(Cfg.Host, Cfg.Port, Cfg.Database, Cfg.User, Cfg.Password, this); CreateTables(); } public void Unload(){ _mySql.CloseDb(_mySqlConnection); } private void CreateTables(){ if (_mySqlConnection == null) { Puts("Can't connect to the database!"); return; } var commands = Sql.Builder.Append($@"CREATE TABLE IF NOT EXISTS messageInfo ( id INT unsigned NOT NULL AUTO_INCREMENT, # Unique ID for the record name VARCHAR(150) NOT NULL, # Name of the player message VARCHAR(150) NOT NULL, # Message that was sent PRIMARY KEY (id) # Make the id the primary key );"); _mySql.ExecuteNonQuery(commands, _mySqlConnection); } } }
[DOUBLEPOST=1473977433][/DOUBLEPOST]I can send you a multi-server manager I have using SQL if you want a full look.Code:private void CreatePlayer(BasePlayer player){ _mySql.Query(Sql.Builder.Append($"INSERT INTO players{Cfg.serverName} (`id`, `name`) VALUES ('{player.userID}', '{player.displayName}');"), _mySqlConnection, callback => { }); Puts($"SQL Addition: Created a new player named: {player.displayName} with the ID of {player.userID}."); } -
Thank you, your topic will help me in my learning!
It would be great if you could send!
I know C # more'm still new in this world! : D
[DOUBLEPOST=1473977819][/DOUBLEPOST]Dylan, I do not know if I'm creating a plugin in the right place!
I cloned the github project in my Visual Studio, then in Rust, Plugin created the plugin to help me in the development. as print I created as an example!
The problem is that I can not instantiate trough of:
public static readonly Oxide.Ext.MySql.Libraries.MySql _mySql = Interface.Oxide.GetLibrary <Oxide.Ext.MySql.Libraries.MySql> ();
This print is one exampleAttached Files:
-
-
I would not know how that works(in terms of visual studio). I use Visual Studio Code instead which doesn't include all of that fancy variable stuff. Ill send it to you though
-
The print was how the errors in your plugin!
[DOUBLEPOST=1473978045][/DOUBLEPOST]I do not know if I'm doing right!
[DOUBLEPOST=1473978224][/DOUBLEPOST]your plugin gave me a big advancement in the script!
I am very grateful to you for it!
Very much, thank you!Attached Files:
-
-
Please Wulf, Solved topic!



