Jump to content

ImAlive

Inactive Member
  • Posts

    4
  • Joined

  • Last visited

  • Feedback

    0%

Posts posted by ImAlive

  1. 34 minutes ago, Amun said:

    I don't get it.. mine's working just fine.

    Here's the code, I've also commented to see what's what:

    char_change_empire.cpp

      Hide contents

    int CHARACTER::ChangeEmpire(BYTE empire)
    {
        if (GetEmpire() == empire)
            return 1;//return 1 means you're trying to change to the same empire. Aka: you're already there..

        char szQuery[1024 + 1];
        DWORD dwAID;
        DWORD dwPID[4];
        memset(dwPID, 0, sizeof(dwPID));

        {//get all the players on this account
            snprintf(szQuery, sizeof(szQuery),        //pid5 after pid4 if you have lykan                            //pid5=%u if you have lykan
                     "SELECT id, pid1, pid2, pid3, pid4 FROM player_index%s WHERE pid1=%u OR pid2=%u OR pid3=%u OR pid4=%u AND empire=%u",
                                         //add one more GetPlayerID() if you have lykan
                     get_table_postfix(), GetPlayerID(), GetPlayerID(), GetPlayerID(), GetPlayerID(), GetEmpire());

            std::unique_ptr<SQLMsg> msg(DBManager::instance().DirectQuery(szQuery));

            if (msg->Get()->uiNumRows == 0)
            {
                return 0;//return 0 is unknown or query error
            }

            MYSQL_ROW row = mysql_fetch_row(msg->Get()->pSQLResult);

            str_to_number(dwAID, row[0]);
            str_to_number(dwPID[0], row[1]);
            str_to_number(dwPID[1], row[2]);
            str_to_number(dwPID[2], row[3]);
            str_to_number(dwPID[3], row[4]);
            // str_to_number(dwPID[4], row[5]);//if you have lykan.
        }

        const int loop = 4;//number of characters available(should be 5 if you have lykan)

        {
            DWORD dwGuildID[4];
            CGuild *pGuild[4];
            SQLMsg *pMsg = NULL;

            for (int i = 0; i < loop; ++i)
            {

                snprintf(szQuery, sizeof(szQuery), "SELECT guild_id FROM guild_member%s WHERE pid=%u", get_table_postfix(), dwPID[i]);

                pMsg = DBManager::instance().DirectQuery(szQuery);

                
                if (pMsg != NULL)//query failed
                {
                    if (pMsg->Get()->uiNumRows > 0)//query didn't fail, we've got some results.
                    {
                        MYSQL_ROW row = mysql_fetch_row(pMsg->Get()->pSQLResult);
                        str_to_number(dwGuildID[i], row[0]);

                        pGuild[i] = CGuildManager::instance().FindGuild(dwGuildID[i]);//look for a guild

                        if (pGuild[i] != NULL)//we found a guild on one of the accounts
                        {
                            M2_DELETE(pMsg);
                            return 2;
                        }
                    }
                    else // we didn't get any results
                    {
                        dwGuildID[i] = 0;
                        pGuild[i] = NULL;
                    }
                    M2_DELETE(pMsg);
                }
            }
        }

        {//return 3 means one of the characters is married.
            for (int i = 0; i < loop; ++i)
            {
                if (marriage::CManager::instance().IsEngagedOrMarried(dwPID[i]) == true)
                    return 3;
            }
        }

        {
            //don't forget to add your 5th pid if you have lykan.
            snprintf(szQuery, sizeof(szQuery), "UPDATE player_index%s SET empire=%u WHERE pid1=%u OR pid2=%u OR pid3=%u OR pid4=%u AND empire=%u",
                     get_table_postfix(), empire, GetPlayerID(), GetPlayerID(), GetPlayerID(), GetPlayerID(), GetEmpire());

            std::unique_ptr<SQLMsg> msg(DBManager::instance().DirectQuery(szQuery));

            if (msg->Get()->uiAffectedRows > 0)
            {
                SetChangeEmpireCount();
                SetEmpire(empire);
                UpdatePacket();
                return 999;//it means everything ran as expected.
            }
        }

        return 0;//unexpectedly, we've reached the final destination. How did this happen ?
    }

    This should do the trick.

     

    Good luck !

    Thank you very much i will try it and keep you updated!

  2. Let me explain an other time.

    So lets say i have 2 characters in 1 account which they both are in blue kingdom.

    Character1 is a part of a guild while character 2 isn't okay?

    So when i try to change kingdom with the character1 it wouldn't let me because it will say you are a member of a guild BUT if i try to change kingdom from character2 it would let me!

    So im on BOTH characters to red kingdom for example and the character 1 is at red kingdom and he is a member at a guild from blue kingdom!

    Thanks for your help guys!

  3. So my server has a bug .

    Lets say my account has 2 players one without clan and one with clan on the red kingdom for example

    so when i try to change kingdom with the player that is a member of a clan it wouldnt let me but if i change character to the one without a clan it would let me change a kingdom so im on blue kingdom (for example) with a red kingdom's clan!!

    help 

    THANKS

×
×
  • 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.