• This small function makes it possible to store the exchange logs in a table with player name, vnum item, date, map_index and yang




    Open exchange.cpp


    Search fonction :


    C
    1. bool CExchange::Done()







    And in this fonction search:

    C
    1. item->SetExchanging(false);


    In this part search :

    C
    1. if (item->GetVnum() >= 80003 && item->GetVnum() <= 80007)
    2. {
    3. LogManager::instance().GoldBarLog(victim->GetPlayerID(), item->GetID(), EXCHANGE_TAKE, "");
    4. LogManager::instance().GoldBarLog(GetOwner()->GetPlayerID(), item->GetID(), EXCHANGE_GIVE, "");
    5. }


    Add these lines, that will send INSERT into the player_exchange table:


    C
    1. std::string NomObjet = item->GetName(); // store the name of the item
    2. char tempNomObjet[64+1]; // Create a table of a size equal to the name of the stored item
    3. DBManager::instance().EscapeString(tempNomObjet, sizeof(tempNomObjet), NomObjet.c_str(), NomObjet.size()); // Convers special characters such as "é'"etc into a value that can be inserted into MYSQL
    4. std::unique_ptr<SQLMsg> msg(DBManager::instance().DirectQuery("INSERT INTO player_echange%s (pseudo, pseudo2, item, yang, map_index, date) VALUES('%s', '%s', '%s', '%lld', '%d', now())", get_table_postfix(), GetOwner()->GetName(), victim->GetName(), tempNomObjet, m_lGold, GetOwner()->GetMapIndex())); // Retrieve the exchange log


    Search line :


    C
    1. if (m_lGold)

    Add that query for the yang


    C
    1. std::unique_ptr<SQLMsg> msg(DBManager::instance().DirectQuery("INSERT INTO player_echange%s (pseudo, pseudo2, item, yang, map_index, date) VALUES('%s', '%s', '%s', '%lld', '%d', now())", get_table_postfix(), GetOwner()->GetName(), victim->GetName(), "YANG", m_lGold, GetOwner()->GetMapIndex())); // Retrieve the log exchange

    It done !


    Now you need to create a tabele in Navicat (database player)



    Warning : uniqueptr exist only under gcc48 to gcc6, if you are still under gcc42 replace all unique_ptr with auto_ptr


    Best regards, Winchester
    Jin

    2 Mal editiert, zuletzt von Winchester2 ()

  • Dieses Thema enthält 9 weitere Beiträge, die nur für registrierte Benutzer sichtbar sind, bitte registrieren Sie sich oder melden Sie sich an um diese lesen zu können.