1. I'm trying to put together the script PagSeguro with my cash system plugin the only way I found was
    using the mysql connection
    someone can give a simple example of mysql connection?
    would use the mysql connector?
     
  2. Wulf

    Wulf Community Admin

  3. would not need to import any class?
     
  4. I haven't actually tested this but normally this should work:
    Code:
    // Reference: Oxide.Ext.MySqlusing System.Collections.Generic;
    using System.Linq;
    using Oxide.Core;
    using Oxide.Ext.MySql;namespace Oxide.Plugins
    {    [Info("MySQL Example", "Mughisi", "1.0.0")]
        class MysqlExample : RustPlugin
        {
            Connection connection = Interface.Oxide.GetLibrary<Ext.MySql.Libraries.MySql>("MySql").OpenDb("localhost", 3306, "database_name", "username", "password");        void RunMySqlQuery()
            {
                Sql sql = Interface.Oxide.GetLibrary<Ext.MySql.Libraries.MySql>("MySql").NewSql();
                sql.Append("SELECT * FROM `mytable`");            List<Dictionary<string, string>> result = new List<Dictionary<string, string>>();
                Dictionary<string, string> entry;
                IEnumerable<Dictionary<string, object>> res = Interface.Oxide.GetLibrary<Ext.MySql.Libraries.MySql>("MySql").Query(sql, connection);            foreach (Dictionary<string, object> obj in res)
                {
                    List<string> tableKeys = obj.Select(x => x.Key).ToList<string>();
                    List<object> tableVals = obj.Select(x => x.Value).ToList<object>();                entry = new Dictionary<string, string>();                foreach (string key in tableKeys)
                        entry.Add(key, tableVals[tableKeys.IndexOf(key)].ToString());                result.Add(entry);
                }            foreach (Dictionary<string, string> line in result)
                {
                    Puts($"{line["field"]}");
                }
            }
        }
    }
     
  5. thank you
    [DOUBLEPOST=1427311711][/DOUBLEPOST]is returning this error
    [​IMG]
    [DOUBLEPOST=1427312138][/DOUBLEPOST]IEnumerable<Dictionary<string, object>> res = Interface.Oxide.GetLibrary<Ext.MySql.Libraries.MySql>("MySql").Query(sql, connection); error here
     
    Last edited by a moderator: Mar 25, 2015
  6. try adding the I18N dlls to your server, looks like missing encodings
     
  7. I did not understand
    sorry I am Brazilian
    then google has something that does not translate right
     
  8. These are the files Nogrod is talking about @igor1150. You'll have to put them in your RustDedicated_Data\Managed folder
     

    Attached Files:

  9. Note that `// Reference: Oxide.Ext.MySql` will no longer be needed if you're using the latest snapshot, or after the release later today.
     
  10. one more question how do I close the connection?

    sql.Append("delete from table where column ='" + Text + "'");
    Interface.Oxide.GetLibrary<Ext.MySql.Libraries.MySql>("MySql").Query(sql, connection);

    I am trying to delete so
    but is not deleting
    [DOUBLEPOST=1427400949][/DOUBLEPOST]sorry forgot to instantiate the object
    resolved
    [DOUBLEPOST=1427423350,1427400097][/DOUBLEPOST]after this latest update of oxide
    I'm having trouble
    q is telling the namespace does not exist

    using Oxide.Ext.MySql;

    [​IMG]
     
  11. Wulf

    Wulf Community Admin

    Please post the full log and your plugin's code.
     
  12. Code:
    12:01 [Info] Loading Oxide núcleo v2.0.588 ...
    12:01 [Info] Carregando extensões ...
    12:01 [Info] Loaded extensão CSharp v0.6.588 por bawNg
    12:01 [Info] extensão Loaded JavaScript v1.0.588 por Nogrod
    12:01 [Info] extensão Loaded Lua v1.0.588 por Óxido de Equipe
    12:01 [Info] extensão Loaded MySql v1.0.588 por Nogrod
    12:01 [Info] Loaded extensão Python v1.0.588 por Nogrod
    12:01 [Info] Loaded extensão Rust v1.0.588 por Óxido de Equipe
    12:01 [Info] extensão Loaded Rust: IO para v2.0.2 Oxide por playrust.io / Dcode
    12:01 [Info] Loaded extensão SQLite v1.0.588 por Nogrod
    12:01 [Info] Loaded Unity extensão v1.0.588 por Óxido de Equipe
    12:01 [Info] Carregando plugins ...
    12:01 [Info] plugin do Loaded Rust Núcleo v1.0.0 por Óxido de Equipe
    12:01 [Info] plugin do Loaded Unity Núcleo v1.0.0 por Óxido de Equipe
    12:01 [Info] Loaded Rust plugin: IO para v2.0.2 Oxide por playrust.io / Dcode
    12:01 [Error] CashSystem plug-in não conseguiu compilar! Código de saída: 1
    12:01 [Warning] C: \ steamcmd \ rust_server \ server \ plugins \ CashSystem.cs (8,13): error CS0234: O tipo de nome do namespace ou `Ext 'não existe no espaço de nomes` Oxide ". Você está faltando uma referência?
    C: \ steamcmd \ rust_server \ server \ plugins \ CashSystem.cs (18,9): error CS0246: O tipo ou nome do namespace 'Conexão' não pôde ser encontrado. Você está sentindo falta `Rede 'ou` Rust.Defines' usando directiva?
    12:05 [Info] descarregado Rust plugin: IO para v2.0.2 Oxide por playrust.io / Dcode
    Code:
    using System.Collections.Generic;
    using System;
    using System.Linq;
    using Oxide.Core;
    using Oxide.Ext.MySql;namespace Oxide.Plugins
    {
        [Info("CashSystem", "igor1150", 1.0)]
        class CashSystem : RustPlugin
        {
        Connection connection = Interface.Oxide.GetLibrary<Ext.MySql.Libraries.MySql>("MySql").OpenDb("localhost", 3306, "db", "Use", "pass");
           void VerificarPINMySQL(BasePlayer player,string pin)
            {          
                Sql sql = Interface.Oxide.GetLibrary<Ext.MySql.Libraries.MySql>("MySql").NewSql();
                sql.Append("SELECT TransacaoID,ProdValor,ProdQuantidade,StatusTransacao FROM `vendas`");
                IEnumerable<Dictionary<string, object>> res;
                try
                {
                    res = Interface.Oxide.GetLibrary<Ext.MySql.Libraries.MySql>("MySql").Query(sql, connection);
                }
                catch (Exception ex)
                {
                    SendReply(player, "erro tente mais tarde");
                    return;
                }
                if (res == null)
                {
                    SendReply(player, "erro tente mais tarde");
                    return;
                }
                int cash = 0;
                foreach (Dictionary<string, object> obj in res)
                {              
                    List<string> tableKeys = obj.Select(x => x.Key).ToList<string>();
                    List<object> tableVals = obj.Select(x => x.Value).ToList<object>();
                    if (tableVals[tableKeys.IndexOf("TransacaoID")].ToString() == pin)
                    {
                        if (tableVals[tableKeys.IndexOf("StatusTransacao")].ToString() == "Aprovado")
                        {
                            cash = Convert.ToInt32(tableVals[tableKeys.IndexOf("ProdValor")].ToString().Replace(",", "")) * Convert.ToInt32(tableVals[tableKeys.IndexOf("ProdQuantidade")]);
                            break;
                        }
                        else if (tableVals[tableKeys.IndexOf("StatusTransacao")].ToString() == "Cancelado")
                        {
                            SendReply(player, "O pagamento nao foi concluido codigo PIN nao liberado acesse sua conta do pagseguro para mais informacoes");
                            break;
                        }
                        else if (tableVals[tableKeys.IndexOf("StatusTransacao")].ToString() == "Aguardando Pagto")
                        {
                            SendReply(player, "O pagamento nao foi confirmado");
                            break;
                        }
                    }
                }
                if (cash > 0)
                {
                    sql = Interface.Oxide.GetLibrary<Ext.MySql.Libraries.MySql>("MySql").NewSql();
                    sql.Append("delete from vendas where TransacaoID ='" + pin + "'");
                    try
                    {
                        Interface.Oxide.GetLibrary<Ext.MySql.Libraries.MySql>("MySql").Query(sql, connection);
                    }
                    catch (Exception ex)
                    {
                        SendReply(player, "erro tente mais tarde");
                        return;
                    }                              SendReply(player, String.Concat("Cash adicionado com sucesso no valor de ", Convert.ToString(cash)));
                    AddCash(player, cash);
                }
                else
                {
                    SendReply(player, "Numero PIN nao encontrado");
                }        }
            [ChatCommand("pin")]
            void chatmysql(BasePlayer player, string command, string[] args)
            {
                if (args[0].ToString() == "" || args[0] == null)
                    SendReply(player, "Enter a PIN number");
                else
                    VerificarPINMySQL(player, args[0].ToString());
            }
        }
    }
     
    Last edited by a moderator: Mar 27, 2015
  13. Just ran a test myself and seems that the reference is still required to have the plugin compile so if you add "// Reference: Oxide.Ext.MySql" again on the top it should work.
     
  14. I did it to get tested
    if the problem was there
    but the problem was there
    [DOUBLEPOST=1427429175][/DOUBLEPOST]thank you @Mughisi
     
  15. I just fixed a bug which would cause references to not be detected from `using` statements. So the "// Reference: Oxide.Ext.MySql" will no longer be required using the next snapshot released later today.