Jump to content

Recommended Posts

  • Premium

hello I can help pass data from MySQL to a struct and then to read the struct.

I have done this:

typedef struct TPackettest22
{
    BYTE tipo;
    int cantidad;

} TPackettest22;

int CHARACTER::GetbApplyOn ()
{
    TPackettest22 ps;

    return ps.tipo;
}

int CHARACTER::GetlApplyValue ()
{
    TPackettest22 ps;

    return ps.cantidad;
}

void CHARACTER::LoadtestR ()
{
    TPackettest22 ps;

    std::unique_ptr<SQLMsg> pmsg(DBManager::instance().DirectQuery("SELECT bApplyOn,lApplyValue FROM player.teststruct WHERE DwID=%d ", GetPlayerID()));
    if ( pmsg->Get()->uiNumRows > 0 )
    {
        MYSQL_ROW row = mysql_fetch_row(pmsg->Get()->pSQLResult);
        
        str_to_number(ps.tipo, row[0]);
        str_to_number(ps.cantidad, row[1]);
    }
}

ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("LOAD_TEST: tipo %d cantidad %d"), ch->GetbApplyOn(), ch->GetlApplyValue());

result:

AC9zd.png

should leave: LOAD_TEST: Type 9 Number 1000

Edited by Metin2 Dev
Core X - External 2 Internal
Link to comment
https://metin2.dev/topic/12261-pass-data-to-a-struct/
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Don't use any images from : imgur, turkmmop, freakgamers, inforge, hizliresim... Or your content will be deleted without notice...
Use : https://metin2.download/media/add/

Please use https://metin2.download/ when uploading files smaller than 100MB, otherwise the approval will take longer due to manual upload.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.