Great OfflineShoplarda Artık Edit Modunu Kapatmayın

hasanmacit

UsProject / discord: hasanmacit
Süper Moderatör
Geliştirici
Yardımsever Üye
Mesaj
4.606
Çözümler
194
Beğeni
4.314
Puan
1.850
Ticaret Puanı
6
çünkü fixini paylaşıyorum.

C++:
Genişlet Daralt Kopyala
ACMD(do_shop_update_item)
{

    if (ch->IsObserverMode() || ch->GetExchange() || ch->IsOpenSafebox() || ch->GetShopOwner() || ch->IsCubeOpen() || ch->GetMyShop())
        return;
    extern ACMD(do_shop_refresh_items);
    char arg1[256];
    one_argument(argument, arg1, sizeof(arg1));
    if (!*arg1)
        return;
    std::vector<std::string> args;
    boost::split(args, arg1, boost::is_any_of("|"));
#ifdef ENABLE_OFFLINE_SHOP_USE_CHEQUE
    if (args.size() == 4)
#else
    if (args.size() == 3)
#endif
    {
        return;
    }
    DWORD shop_id;
    str_to_number(shop_id, args[1].c_str());
    bool myShop=false;
    {
        CharacterVectorInteractor i;
        if (CHARACTER_MANAGER::instance().GetCharactersByRaceNum(30000, i))
        {
            CharacterVectorInteractor::iterator it = i.begin();
            while (it != i.end()) {
                LPCHARACTER pc = *it++;
                if (pc)
                    if (pc->GetRaceNum() == 30000 && pc->GetPrivShop() == shop_id) {
                        myShop=true;
                        break;
                    }


            }
        }
    }
    if(!myShop)
    {
        SQLMsg * pkMsg(DBManager::instance().DirectQuery("SELECT id from player_shop WHERE id = %d and player_id=%d", shop_id, ch->GetPlayerID()));
        SQLResult * pRes = pkMsg->Get();
        myShop=pRes->uiNumRows>0;
    }
    if (myShop)
    {

        {
            TPacketShopUpdateItem packet;
            packet.shop_id = shop_id;
            packet.shop_locked = true;
            db_clientdesc->DBPacket(HEADER_GD_SHOP_UPDATE_ITEM, 0, &packet, sizeof(packet));
        }
        /*
        /update_shop_item price|%d|%d|%d)
        /update_shop_item remove|%d|%d
        /update_shop_item add|%d|%d|%d|%d|%s

        */
        if (args.size() == 4)
        {
            DWORD item_id;
            str_to_number(item_id, args[2].c_str());
            long long price;
            str_to_number(price, args[3].c_str());
#ifdef ENABLE_OFFLINE_SHOP_USE_CHEQUE
            DWORD cheque;
            str_to_number(cheque, args[4].c_str());
#endif
            if (price <= 0 || item_id <= 0)
                return;
            {
                SQLMsg * pkMsg(DBManager::instance().DirectQuery("SELECT id from player_shop_items WHERE id = %d and shop_id=%d", item_id, shop_id));
                SQLResult * pRes = pkMsg->Get();
                if (pRes->uiNumRows > 0)
                    DBManager::instance().DirectQuery("UPDATE player_shop_items SET price=%lld WHERE id = %d and shop_id=%d", price, item_id, shop_id);
#ifdef ENABLE_OFFLINE_SHOP_USE_CHEQUE
                if (pRes->uiNumRows > 0)
                    DBManager::instance().DirectQuery("UPDATE player_shop_items SET cheque=%d WHERE id = %d and shop_id=%d", cheque, item_id, shop_id);
#endif


            }
            }
        else if (args.size() == 3)
        {
            DWORD item_id;
            str_to_number(item_id, args[2].c_str());
            if (item_id <= 0)
                return;
            {

                std::string shop_name(LC_TEXT( "SHOP_NAME"));
                boost::replace_all(shop_name, "#PLAYER_NAME#", ch->GetName());
                boost::replace_all(shop_name, "#ID#", "");


                char szSockets[1024] = { '\0' };
                char *tempSockets = szSockets;
                for (int i = 0; i < ITEM_SOCKET_MAX_NUM; i++)
                {
                    tempSockets += sprintf(tempSockets, "socket%d", i);

                    if (i<ITEM_SOCKET_MAX_NUM - 1)
                        tempSockets += sprintf(tempSockets, ",");
                }
                char szAttrs[1024] = { '\0' };
                char *tempAttrs = szAttrs;
                for (int i = 0; i < ITEM_ATTRIBUTE_MAX_NUM; i++)
                {
                    if (i < 7)
                        tempAttrs += sprintf(tempAttrs, "attrtype%d,attrvalue%d", i, i);
                    else
                        tempAttrs += sprintf(tempAttrs, "applytype%d,applyvalue%d", i - 7, i - 7);
                    if (i<ITEM_ATTRIBUTE_MAX_NUM - 1)
                        tempAttrs += sprintf(tempAttrs, ",");
                }

                SQLMsg * pkMsg(DBManager::instance().DirectQuery("SELECT vnum,count,%s,%s from player_shop_items where shop_id='%d' and id=%d", szSockets,szAttrs,shop_id, item_id));
                SQLResult * pRes = pkMsg->Get();
                if (pRes->uiNumRows>0)
                {
                    MYSQL_ROW row;
                    while ((row = mysql_fetch_row(pRes->pSQLResult)) != NULL)
                    {

                        int col = 0;
                        char query[8192];
                        sprintf(query, "INSERT INTO player_gift SET owner_id=%d,reason='%s',`from`=replace(\"%s\",' ','_'),status='WAIT',date_add=NOW()", ch->GetPlayerID(), LC_TEXT( "SHOP_ITEM_REASON"), shop_name.c_str());
                        sprintf(query, "%s, vnum='%s'", query, row[col++]);
                        sprintf(query, "%s, count='%s'", query, row[col++]);
                        for (int s = 0; s < ITEM_SOCKET_MAX_NUM; s++)
                            sprintf(query, "%s, socket%d='%s'", query, s, row[col++]);
               
                        for (int ia = 0; ia < ITEM_ATTRIBUTE_MAX_NUM; ia++)
                        {
                            if (ia < 7)
                            {
                                sprintf(query, "%s, attrtype%d='%s'", query, ia, row[col++]);
                                sprintf(query, "%s, attrvalue%d='%s'", query, ia, row[col++]);
                            }
                            else
                            {
                                sprintf(query, "%s, applytype%d='%s'", query, ia-7,row[col++]);
                                sprintf(query, "%s, applyvalue%d='%s'", query, ia-7,row[col++]);
                            }
                        }
                        SQLMsg * pkMsg(DBManager::instance().DirectQuery(query));
                        SQLResult * pRes = pkMsg->Get();
                        DWORD gift_id = pRes->uiInsertID;
                        if (gift_id > 0)
                            GetGift(ch, gift_id);                      
                       
                        DBManager::instance().DirectQuery("delete from player_shop_items where id='%d'", item_id);
                        DBManager::instance().DirectQuery("UPDATE player_shop SET item_count=item_count-1 WHERE id = %d", shop_id);
                    }
                }

            }
        }

#ifdef ENABLE_OFFLINE_SHOP_USE_CHEQUE
        else if (args.size() == 7)
#else
        else if (args.size() == 6)
#endif
        {
            BYTE display_pos;
            str_to_number(display_pos, args[2].c_str());

            if (display_pos < 0)
                return;
            WORD pos;
            str_to_number(pos, args[3].c_str());
            if (pos < 0)
                return;

            BYTE window_type;
            str_to_number(window_type, args[4].c_str());
            if (window_type < 0)
                return;

            #ifdef ACCE_LENNT_FIX
            if(ch->IsAcceOpen())
                Acce_close(ch);
            #endif
            long long price;

            str_to_number(price, args[5].c_str());
            if (price <= 0)
                return;

#ifdef ENABLE_OFFLINE_SHOP_USE_CHEQUE
            DWORD cheque;
            str_to_number(cheque, args[6].c_str());
            if (cheque < 0)
                return;
#endif

        #ifdef FULL_YANG
            {
                long long nTotalMoney=price;
                SQLMsg * pkMsg(DBManager::instance().DirectQuery("SELECT price from player_shop_items where shop_id='%d'", szSockets,szAttrs,shop_id));
                SQLResult * pRes = pkMsg->Get();
                if (pRes->uiNumRows>0)
                {
                    MYSQL_ROW row;
                    while ((row = mysql_fetch_row(pRes->pSQLResult)) != NULL)
                    {
                        long long temp;
                        str_to_number(temp,row[0]);
                        nTotalMoney+=temp;
                    }
                }
                if (GOLD_MAX <= nTotalMoney)
                {
                    sys_err("[OVERFLOW_GOLD] Overflow (GOLD_MAX) id %u name %s", GetPlayerID(), GetName());
                    ChatPacket(CHAT_TYPE_INFO, LC_TEXT("20?? ©©E?¡í ??¡ÆuC??¨Ï ¡íoA¢§?¡í ?¡©?o¡Æ¢§ ??¢©?¢¥?¢¥?"));
                    return;
                }
            }
        #endif
            LPITEM item = ch->GetItem(TItemPos(window_type, pos));
            if (item)
            {
                const TItemTable * item_table = item->GetProto();

                if (item_table && (IS_SET(item_table->dwAntiFlags, ITEM_ANTIFLAG_GIVE | ITEM_ANTIFLAG_MYSHOP)))
                {
                    ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT( "??¡¤a?¡© ???????? ¡Æ©©?I¡íoA¢§?¢§?¡© ?C¢¬?C? ?o ??¢©?¢¥?¢¥?."));
                    return;
                }

                if (item->IsEquipped())
                {
                    ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT( "????A©¬?I ???????? ¡Æ©©?I¡íoA¢§?¢§?¡© ?C¢¬?C? ?o ??¢©?¢¥?¢¥?."));
                    return;
                }

                if (item->isLocked())
                {
                    ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT( "¡íc?eA©¬?I ???????? ¡Æ©©?I¡íoA¢§?¢§?¡© ?C¢¬?C? ?o ??¢©?¢¥?¢¥?."));
                    return;
                }
                if (item->GetOwner() != ch)
                {
                    return;
                }
#ifdef SOULBIND_SYSTEM
                if (item->IsSoulBind())
                {
                    ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT( "You can't sell in private shop item with soul bind."));
                    return;
                }
#endif
                char query[1024];
                sprintf(query, "INSERT INTO player_shop_items SET");
                sprintf(query, "%s player_id='%d'", query, ch->GetPlayerID());
                sprintf(query, "%s, shop_id='%d'", query, shop_id);
                sprintf(query, "%s, vnum='%d'", query, item->GetVnum());
                sprintf(query, "%s, count='%d'", query, item->GetCount());
                sprintf(query, "%s, price='%lld'", query, price);
#ifdef ENABLE_OFFLINE_SHOP_USE_CHEQUE
                sprintf(query, "%s, cheque='%d'", query, cheque);
#endif

                sprintf(query, "%s, display_pos='%u'", query, display_pos);
                for (int s = 0; s < ITEM_SOCKET_MAX_NUM; s++)
                {
                    sprintf(query, "%s, socket%d='%ld'", query, s, item->GetSocket(s));

                }

                for (int ia = 0; ia < ITEM_ATTRIBUTE_MAX_NUM; ia++)
                {
                    const TPlayerItemAttribute& attr = item->GetAttribute(ia);
                    if (ia < 7)
                    {
                        sprintf(query, "%s, attrtype%d='%u'", query, ia, attr.bType);
                        sprintf(query, "%s, attrvalue%d='%d'", query, ia, attr.sValue);
                    }
                    else
                    {
                        sprintf(query, "%s, applytype%d='%u'", query, ia-7, attr.bType);
                        sprintf(query, "%s, applyvalue%d='%d'", query, ia-7, attr.sValue);
                    }
                }

                DBManager::instance().DirectQuery(query);
                ITEM_MANAGER::Instance().RemoveItem(item, "Priv shop");
                DBManager::instance().DirectQuery("UPDATE player_shop SET item_count=item_count +1 WHERE id = %d", shop_id);
            }
            else
                return;



        }
        else
            return;
        ch->LoadPrivShops();
        char buf[32];
        sprintf(buf, "refresh_shop_items %d", shop_id);
        interpret_command(ch, buf, strlen(buf));
        CharacterVectorInteractor i;
        if (CHARACTER_MANAGER::instance().GetCharactersByRaceNum(30000, i))
        {
            CharacterVectorInteractor::iterator it = i.begin();
            while (it != i.end()) {
                LPCHARACTER pc = *it++;
                if (pc)
                    if (pc->GetRaceNum() == 30000 && pc->GetPrivShop() == shop_id) {
                        pc->UpdateShopItems();
                        return;
                    }


            }
        }

        TPacketShopUpdateItem packet;
        packet.shop_id = shop_id;
        packet.shop_locked = false;
        db_clientdesc->DBPacket(HEADER_GD_SHOP_UPDATE_ITEM, 0, &packet, sizeof(packet));
        }
    }

güle güle kullanın

kanıt

 
hasan bide bu konu ile alakası yok ama . sistem ekleme videolarından great shopu ekledim aynı şekilde , TM SF filese...sorunsuz eklendi ama reboot atınca veya chleri kapatıp açınca pazarlar gözükmüyor. ama pazar paketine tıklayınca pazarlar var gözüküyor.
 
hasan bide bu konu ile alakası yok ama . sistem ekleme videolarından great shopu ekledim aynı şekilde , TM SF filese...sorunsuz eklendi ama reboot atınca veya chleri kapatıp açınca pazarlar gözükmüyor. ama pazar paketine tıklayınca pazarlar var gözüküyor.
Onun anlatımında sorun yaşamaması senin yaşamayacağın anlamına gelmez. Anlatımda boş filese ekleme yapıyor fakat senin filesinde aynı şekilde boş altyapı değildir diye düşünüyorum. Bir virgün parantez falan bişey bile atlasan binbir sorun çıkıyor.
 
hasan bide bu konu ile alakası yok ama . sistem ekleme videolarından great shopu ekledim aynı şekilde , TM SF filese...sorunsuz eklendi ama reboot atınca veya chleri kapatıp açınca pazarlar gözükmüyor. ama pazar paketine tıklayınca pazarlar var gözüküyor.
Onun anlatımında sorun yaşamaması senin yaşamayacağın anlamına gelmez. Anlatımda boş filese ekleme yapıyor fakat senin filesinde aynı şekilde boş altyapı değildir diye düşünüyorum. Bir virgün parantez falan bişey bile atlasan binbir sorun çıkıyor.
melih kesinlikle haklı ben altyapıya eklemiştim ve sorun yaşamamıştım ama tahminim input_db.cpp de createshops diye bir kod vardı boot kısmına eklenicek eğer onu eklememişsen yada hatalı eklemişsen sorun ondan kaynaklıdır.
 
Hasanmacit'e sormuştum aslında. :)
Önceki yorumunuzda zaten siz belirtmişsiniz.
 
galiba ben vermesem kimse vermicekti

C++:
Genişlet Daralt Kopyala
ACMD(do_shop_update_item)
{

    if (ch->IsObserverMode() || ch->GetExchange() || ch->IsOpenSafebox() || ch->GetShopOwner() || ch->IsCubeOpen() || ch->GetMyShop())
        return;
    extern ACMD(do_shop_refresh_items);
    char arg1[256];
    one_argument(argument, arg1, sizeof(arg1));
    if (!*arg1)
        return;
    std::vector<std::string> args;
    boost::split(args, arg1, boost::is_any_of("|"));
#ifdef ENABLE_OFFLINE_SHOP_USE_CHEQUE
    if (args.size() == 4)
#else
    if (args.size() == 3)
#endif
    {
        return;
    }
    DWORD shop_id;
    str_to_number(shop_id, args[1].c_str());
    bool myShop=false;
    {
        CharacterVectorInteractor i;
        if (CHARACTER_MANAGER::instance().GetCharactersByRaceNum(30000, i))
        {
            CharacterVectorInteractor::iterator it = i.begin();
            while (it != i.end()) {
                LPCHARACTER pc = *it++;
                if (pc)
                    if (pc->GetRaceNum() == 30000 && pc->GetPrivShop() == shop_id) {
                        myShop=true;
                        break;
                    }


            }
        }
    }
    if(!myShop)
    {
        std::unique_ptr<SQLMsg> pkMsg(DBManager::instance().DirectQuery("SELECT id from player_shop WHERE id = %d and player_id=%d", shop_id, ch->GetPlayerID()));
        SQLResult * pRes = pkMsg->Get();
        myShop=pRes->uiNumRows>0;
    }
    if (myShop)
    {

        {
            TPacketShopUpdateItem packet;
            packet.shop_id = shop_id;
            packet.shop_locked = true;
            db_clientdesc->DBPacket(HEADER_GD_SHOP_UPDATE_ITEM, 0, &packet, sizeof(packet));
        }
        /*
        /update_shop_item price|%d|%d|%d)
        /update_shop_item remove|%d|%d
        /update_shop_item add|%d|%d|%d|%d|%s

        */
        if (args.size() == 4)
        {
            DWORD item_id;
            str_to_number(item_id, args[2].c_str());
            long long price;
            str_to_number(price, args[3].c_str());
#ifdef ENABLE_OFFLINE_SHOP_USE_CHEQUE
            DWORD cheque;
            str_to_number(cheque, args[4].c_str());
#endif
            if (price <= 0 || item_id <= 0)
                return;
            {
                std::unique_ptr<SQLMsg> pkMsg(DBManager::instance().DirectQuery("SELECT id from player_shop_items WHERE id = %d and shop_id=%d", item_id, shop_id));
                SQLResult * pRes = pkMsg->Get();
                if (pRes->uiNumRows > 0)
                    DBManager::instance().DirectQuery("UPDATE player_shop_items SET price=%lld WHERE id = %d and shop_id=%d", price, item_id, shop_id);
#ifdef ENABLE_OFFLINE_SHOP_USE_CHEQUE
                if (pRes->uiNumRows > 0)
                    DBManager::instance().DirectQuery("UPDATE player_shop_items SET cheque=%d WHERE id = %d and shop_id=%d", cheque, item_id, shop_id);
#endif


            }
            }
        else if (args.size() == 3)
        {
            DWORD item_id;
            str_to_number(item_id, args[2].c_str());
            if (item_id <= 0)
                return;
            {

                std::string shop_name(LC_TEXT( "SHOP_NAME"));
                boost::replace_all(shop_name, "#PLAYER_NAME#", ch->GetName());
                boost::replace_all(shop_name, "#ID#", "");


                char szSockets[1024] = { '\0' };
                char *tempSockets = szSockets;
                for (int i = 0; i < ITEM_SOCKET_MAX_NUM; i++)
                {
                    tempSockets += sprintf(tempSockets, "socket%d", i);

                    if (i<ITEM_SOCKET_MAX_NUM - 1)
                        tempSockets += sprintf(tempSockets, ",");
                }
                char szAttrs[1024] = { '\0' };
                char *tempAttrs = szAttrs;
                for (int i = 0; i < ITEM_ATTRIBUTE_MAX_NUM; i++)
                {
                    if (i < 7)
                        tempAttrs += sprintf(tempAttrs, "attrtype%d,attrvalue%d", i, i);
                    else
                        tempAttrs += sprintf(tempAttrs, "applytype%d,applyvalue%d", i - 7, i - 7);
                    if (i<ITEM_ATTRIBUTE_MAX_NUM - 1)
                        tempAttrs += sprintf(tempAttrs, ",");
                }

                std::unique_ptr<SQLMsg> pkMsg(DBManager::instance().DirectQuery("SELECT vnum,count,%s,%s from player_shop_items where shop_id='%d' and id=%d", szSockets,szAttrs,shop_id, item_id));
                SQLResult * pRes = pkMsg->Get();
                if (pRes->uiNumRows>0)
                {
                    MYSQL_ROW row;
                    while ((row = mysql_fetch_row(pRes->pSQLResult)) != NULL)
                    {

                        int col = 0;
                        char query[8192];
                        sprintf(query, "INSERT INTO player_gift SET owner_id=%d,reason='%s',`from`=replace(\"%s\",' ','_'),status='WAIT',date_add=NOW()", ch->GetPlayerID(), LC_TEXT( "SHOP_ITEM_REASON"), shop_name.c_str());
                        sprintf(query, "%s, vnum='%s'", query, row[col++]);
                        sprintf(query, "%s, count='%s'", query, row[col++]);
                        for (int s = 0; s < ITEM_SOCKET_MAX_NUM; s++)
                            sprintf(query, "%s, socket%d='%s'", query, s, row[col++]);
              
                        for (int ia = 0; ia < ITEM_ATTRIBUTE_MAX_NUM; ia++)
                        {
                            if (ia < 7)
                            {
                                sprintf(query, "%s, attrtype%d='%s'", query, ia, row[col++]);
                                sprintf(query, "%s, attrvalue%d='%s'", query, ia, row[col++]);
                            }
                            else
                            {
                                sprintf(query, "%s, applytype%d='%s'", query, ia-7,row[col++]);
                                sprintf(query, "%s, applyvalue%d='%s'", query, ia-7,row[col++]);
                            }
                        }
                        std::unique_ptr<SQLMsg> pkMsg(DBManager::instance().DirectQuery(query));
                        SQLResult * pRes = pkMsg->Get();
                        DWORD gift_id = pRes->uiInsertID;
                        if (gift_id > 0)
                            GetGift(ch, gift_id);                     
                      
                        DBManager::instance().DirectQuery("delete from player_shop_items where id='%d'", item_id);
                        DBManager::instance().DirectQuery("UPDATE player_shop SET item_count=item_count-1 WHERE id = %d", shop_id);
                    }
                }

            }
        }

#ifdef ENABLE_OFFLINE_SHOP_USE_CHEQUE
        else if (args.size() == 7)
#else
        else if (args.size() == 6)
#endif
        {
            BYTE display_pos;
            str_to_number(display_pos, args[2].c_str());

            if (display_pos < 0)
                return;
            WORD pos;
            str_to_number(pos, args[3].c_str());
            if (pos < 0)
                return;

            BYTE window_type;
            str_to_number(window_type, args[4].c_str());
            if (window_type < 0)
                return;

            #ifdef ACCE_LENNT_FIX
            if(ch->IsAcceOpen())
                Acce_close(ch);
            #endif
            long long price;

            str_to_number(price, args[5].c_str());
            if (price <= 0)
                return;

#ifdef ENABLE_OFFLINE_SHOP_USE_CHEQUE
            DWORD cheque;
            str_to_number(cheque, args[6].c_str());
            if (cheque < 0)
                return;
#endif

        #ifdef FULL_YANG
            {
                long long nTotalMoney=price;
                std::unique_ptr<SQLMsg> pkMsg(DBManager::instance().DirectQuery("SELECT price from player_shop_items where shop_id='%d'", szSockets,szAttrs,shop_id));
                SQLResult * pRes = pkMsg->Get();
                if (pRes->uiNumRows>0)
                {
                    MYSQL_ROW row;
                    while ((row = mysql_fetch_row(pRes->pSQLResult)) != NULL)
                    {
                        long long temp;
                        str_to_number(temp,row[0]);
                        nTotalMoney+=temp;
                    }
                }
                if (GOLD_MAX <= nTotalMoney)
                {
                    sys_err("[OVERFLOW_GOLD] Overflow (GOLD_MAX) id %u name %s", GetPlayerID(), GetName());
                    ChatPacket(CHAT_TYPE_INFO, LC_TEXT("20?? ©©E?¡í ??¡ÆuC??¨Ï ¡íoA¢§?¡í ?¡©?o¡Æ¢§ ??¢©?¢¥?¢¥?"));
                    return;
                }
            }
        #endif
            LPITEM item = ch->GetItem(TItemPos(window_type, pos));
            if (item)
            {
                const TItemTable * item_table = item->GetProto();

                if (item_table && (IS_SET(item_table->dwAntiFlags, ITEM_ANTIFLAG_GIVE | ITEM_ANTIFLAG_MYSHOP)))
                {
                    ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT( "??¡¤a?¡© ???????? ¡Æ©©?I¡íoA¢§?¢§?¡© ?C¢¬?C? ?o ??¢©?¢¥?¢¥?."));
                    return;
                }

                if (item->IsEquipped())
                {
                    ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT( "????A©¬?I ???????? ¡Æ©©?I¡íoA¢§?¢§?¡© ?C¢¬?C? ?o ??¢©?¢¥?¢¥?."));
                    return;
                }

                if (item->isLocked())
                {
                    ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT( "¡íc?eA©¬?I ???????? ¡Æ©©?I¡íoA¢§?¢§?¡© ?C¢¬?C? ?o ??¢©?¢¥?¢¥?."));
                    return;
                }
                if (item->GetOwner() != ch)
                {
                    return;
                }
#ifdef SOULBIND_SYSTEM
                if (item->IsSoulBind())
                {
                    ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT( "You can't sell in private shop item with soul bind."));
                    return;
                }
#endif
                char query[1024];
                sprintf(query, "INSERT INTO player_shop_items SET");
                sprintf(query, "%s player_id='%d'", query, ch->GetPlayerID());
                sprintf(query, "%s, shop_id='%d'", query, shop_id);
                sprintf(query, "%s, vnum='%d'", query, item->GetVnum());
                sprintf(query, "%s, count='%d'", query, item->GetCount());
                sprintf(query, "%s, price='%lld'", query, price);
#ifdef ENABLE_OFFLINE_SHOP_USE_CHEQUE
                sprintf(query, "%s, cheque='%d'", query, cheque);
#endif

                sprintf(query, "%s, display_pos='%u'", query, display_pos);
                for (int s = 0; s < ITEM_SOCKET_MAX_NUM; s++)
                {
                    sprintf(query, "%s, socket%d='%ld'", query, s, item->GetSocket(s));

                }

                for (int ia = 0; ia < ITEM_ATTRIBUTE_MAX_NUM; ia++)
                {
                    const TPlayerItemAttribute& attr = item->GetAttribute(ia);
                    if (ia < 7)
                    {
                        sprintf(query, "%s, attrtype%d='%u'", query, ia, attr.bType);
                        sprintf(query, "%s, attrvalue%d='%d'", query, ia, attr.sValue);
                    }
                    else
                    {
                        sprintf(query, "%s, applytype%d='%u'", query, ia-7, attr.bType);
                        sprintf(query, "%s, applyvalue%d='%d'", query, ia-7, attr.sValue);
                    }
                }

                DBManager::instance().DirectQuery(query);
                ITEM_MANAGER::Instance().RemoveItem(item, "Priv shop");
                DBManager::instance().DirectQuery("UPDATE player_shop SET item_count=item_count +1 WHERE id = %d", shop_id);
            }
            else
                return;



        }
        else
            return;
        ch->LoadPrivShops();
        char buf[32];
        sprintf(buf, "refresh_shop_items %d", shop_id);
        interpret_command(ch, buf, strlen(buf));
        CharacterVectorInteractor i;
        if (CHARACTER_MANAGER::instance().GetCharactersByRaceNum(30000, i))
        {
            CharacterVectorInteractor::iterator it = i.begin();
            while (it != i.end()) {
                LPCHARACTER pc = *it++;
                if (pc)
                    if (pc->GetRaceNum() == 30000 && pc->GetPrivShop() == shop_id) {
                        pc->UpdateShopItems();
                        return;
                    }


            }
        }

        TPacketShopUpdateItem packet;
        packet.shop_id = shop_id;
        packet.shop_locked = false;
        db_clientdesc->DBPacket(HEADER_GD_SHOP_UPDATE_ITEM, 0, &packet, sizeof(packet));
        }
    }
 
Bu şekilde hata alıyorum.


Ekran Alıntısı.webp
 
Fix amacına uygun olarak çalışıyor. İtem kopyalama olayı engellenmiş. Ancak beraberinde birden fazla eksiği beraberinde getiriyor.
Daha önceden bunu eklemiştim ancak şimdi incelediğimde bazı sorunların olduğunu gördüm.

Bunlar;
1-) İtemin fiyatının değişmemesi.
2-) Düzenleme moduna girildiğinde pazarı kilitlememesi. Dolayısıyla düzenleme yaparken bile pazar açık oluyor ve alışveriş yapılabiliyor.
3-) Kodlarda bazı kısımların hiç olmaması ve bazı kısımların ise orjinalin dışına çıkarak değiştirilmesi.

Biraz kurcaladıktan sonra bu fixi orjinal kodlarla birleştirdim ve yukarıda saydığım 3 sorunu da ortadan kaldırdım. Aşağıda bu fix ile beraber kullandığım şekli paylaşıyorum, aynı sorunu yaşayanlar kodları karşılaştırabilirler.
Verdiğim kodlar FULL_YANG sisteminde denenmemiştir.

C++:
Genişlet Daralt Kopyala
ACMD(do_shop_update_item)
{

    if (ch->IsObserverMode() || ch->GetExchange())
        return;
    extern ACMD(do_shop_refresh_items);
    char arg1[256];
    one_argument(argument, arg1, sizeof(arg1));
    if (!*arg1)
        return;
    std::vector<std::string> args;
    boost::split(args, arg1, boost::is_any_of("|"));
    if (args.size()<2) {
        return;
    }
    DWORD shop_id = 0;
    str_to_number(shop_id, args[1].c_str());
    LPCHARACTER pc_shop = _GetOfflineShop(shop_id);
    bool edit_mode=false;
    bool myShop=false;
    if(pc_shop)
    {
        if(pc_shop->GetPrivShopOwner() != ch->GetPlayerID())
            return;
        edit_mode = pc_shop->GetShopEditMode();
    }else{
        SQLMsg * pkMsg(DBManager::instance().DirectQuery("SELECT id,edit_mode from player_shop WHERE id = %d and player_id=%d", shop_id, ch->GetPlayerID()));
        SQLResult * pRes = pkMsg->Get();
        if (!pRes->uiNumRows)
            return;
        MYSQL_ROW row;
        if((row = mysql_fetch_row(pRes->pSQLResult)) != NULL)
            str_to_number(edit_mode,row[1]);
    }
   
    {
        CharacterVectorInteractor i;
        if (CHARACTER_MANAGER::instance().GetCharactersByRaceNum(30000, i))
        {
            CharacterVectorInteractor::iterator it = i.begin();
            while (it != i.end()) {
                LPCHARACTER pc = *it++;
                if (pc)
                    if (pc->GetRaceNum() == 30000 && pc->GetPrivShop() == shop_id) {
                        myShop=true;
                        break;
                    }


            }
        }
    }
    if(!myShop)
    {
        std::unique_ptr<SQLMsg> pkMsg(DBManager::instance().DirectQuery("SELECT id from player_shop WHERE id = %d and player_id=%d", shop_id, ch->GetPlayerID()));
        SQLResult * pRes = pkMsg->Get();
        myShop=pRes->uiNumRows>0;
    }


    /*
    /update_shop_item edit|%d
    /update_shop_item price|%d|%d|%d)
    /update_shop_item remove|%d|%d
    /update_shop_item add|%d|%d|%d|%d|%s

    */
    if (args.size() == 2)
    {
        _UpdateOfflineShop(shop_id, args[0] == "edit_tick", args[0] == "edit_start");
        return;
    }
    if(!edit_mode)
    {
        do_shop_refresh_items(ch,args[1].c_str(),0,0);
        ch->ChatPacket(CHAT_TYPE_INFO,LC_TEXT("SHOP_NO_EDIT_MODE"));
        return;
    }
   
   
    if (myShop)
    {
    #ifdef ENABLE_OFFLINE_SHOP_USE_CHEQUE
        if (args.size() == 5)
    #else
        if (args.size() == 4)
    #endif
        {
            DWORD item_id = 0;
            str_to_number(item_id, args[2].c_str());
            long long price = 0;
            str_to_number(price, args[3].c_str());
    #ifdef ENABLE_OFFLINE_SHOP_USE_CHEQUE
            DWORD cheque = 0;
            str_to_number(cheque, args[4].c_str());
    #endif
            if (price <= 0 || item_id <= 0)
                return;
            {
                SQLMsg * pkMsg(DBManager::instance().DirectQuery("SELECT id from player_shop_items WHERE id = %d and shop_id=%d", item_id, shop_id));
                SQLResult * pRes = pkMsg->Get();
                if (pRes->uiNumRows > 0)
                    DBManager::instance().DirectQuery("UPDATE player_shop_items SET price=%lld WHERE id = %d and shop_id=%d", price, item_id, shop_id);
    #ifdef ENABLE_OFFLINE_SHOP_USE_CHEQUE
                    if (pRes->uiNumRows > 0)
                        DBManager::instance().DirectQuery("UPDATE player_shop_items SET cheque=%d WHERE id = %d and shop_id=%d", cheque, item_id, shop_id);
    #endif
            }
        }
        else if (args.size() == 3)
        {
            DWORD item_id = 0;
            str_to_number(item_id, args[2].c_str());
            if (item_id <= 0)
                return;
            {

                std::string shop_name(LC_TEXT( "SHOP_NAME"));
                boost::replace_all(shop_name, "#PLAYER_NAME#", ch->GetName());
                boost::replace_all(shop_name, "#ID#", "");


                char szSockets[1024] = { '\0' };
                char *tempSockets = szSockets;
                for (int i = 0; i < ITEM_SOCKET_MAX_NUM; i++)
                {
                    tempSockets += sprintf(tempSockets, "socket%d", i);

                    if (i<ITEM_SOCKET_MAX_NUM - 1)
                        tempSockets += sprintf(tempSockets, ",");
                }
                char szAttrs[1024] = { '\0' };
                char *tempAttrs = szAttrs;
                for (int i = 0; i < ITEM_ATTRIBUTE_MAX_NUM; i++)
                {
                    if (i < 7)
                        tempAttrs += sprintf(tempAttrs, "attrtype%d,attrvalue%d", i, i);
                    else
                        tempAttrs += sprintf(tempAttrs, "applytype%d,applyvalue%d", i - 7, i - 7);
                    if (i<ITEM_ATTRIBUTE_MAX_NUM - 1)
                        tempAttrs += sprintf(tempAttrs, ",");
                }

                SQLMsg * pkMsg(DBManager::instance().DirectQuery("SELECT vnum,count,%s,%s from player_shop_items where shop_id='%d' and id=%d", szSockets,szAttrs,shop_id, item_id));
                SQLResult * pRes = pkMsg->Get();
                if (pRes->uiNumRows>0)
                {
                    MYSQL_ROW row;
                    while ((row = mysql_fetch_row(pRes->pSQLResult)) != NULL)
                    {

                        int col = 0;
                        char query[8192];
                        sprintf(query, "INSERT INTO player_gift SET owner_id=%d,reason='%s',`from`=replace(\"%s\",' ','_'),status='WAIT',date_add=NOW()", ch->GetPlayerID(), LC_TEXT( "SHOP_ITEM_REASON"), shop_name.c_str());
                        sprintf(query, "%s, vnum='%s'", query, row[col++]);
                        sprintf(query, "%s, count='%s'", query, row[col++]);
                        for (int s = 0; s < ITEM_SOCKET_MAX_NUM; s++)
                            sprintf(query, "%s, socket%d='%s'", query, s, row[col++]);

                        for (int ia = 0; ia < ITEM_ATTRIBUTE_MAX_NUM; ia++)
                        {
                            if (ia < 7)
                            {
                                sprintf(query, "%s, attrtype%d='%s'", query, ia, row[col++]);
                                sprintf(query, "%s, attrvalue%d='%s'", query, ia, row[col++]);
                            }
                            else
                            {
                                sprintf(query, "%s, applytype%d='%s'", query, ia-7,row[col++]);
                                sprintf(query, "%s, applyvalue%d='%s'", query, ia-7,row[col++]);
                            }
                        }
                        SQLMsg * pkMsg(DBManager::instance().DirectQuery(query));
                        SQLResult * pRes = pkMsg->Get();
                        DWORD gift_id = pRes->uiInsertID;
                        if (gift_id > 0)
                        {
                            GetGift(ch, gift_id);
                            DBManager::instance().DirectQuery("delete from player_shop_items where id='%d'", item_id);
                            DBManager::instance().DirectQuery("UPDATE player_shop SET item_count=item_count-1 WHERE id = %d", shop_id);

                        }
                    }
                }

            }
        }

    #ifdef ENABLE_OFFLINE_SHOP_USE_CHEQUE
        else if (args.size() == 7)
    #else
        else if (args.size() == 6)
    #endif
        {
            BYTE display_pos = 0;
            str_to_number(display_pos, args[2].c_str());

            if (display_pos < 0)
                return;
            WORD pos = 0;
            str_to_number(pos, args[3].c_str());
            if (pos < 0)
                return;

            BYTE window_type = 0;
            str_to_number(window_type, args[4].c_str());
            if (window_type < 0)
                return;

            #ifdef ACCE_LENNT_FIX
            if(ch->IsAcceOpen())
                Acce_close(ch);
            #endif
            long long price = 0;

            str_to_number(price, args[5].c_str());
            if (price <= 0)
                return;
    #ifdef ENABLE_OFFLINE_SHOP_USE_CHEQUE
                DWORD cheque = 0;
                str_to_number(cheque, args[6].c_str());
                if (cheque < 0)
                    return;
    #endif
    #ifndef FULL_YANG
            {
                long long nTotalMoney=price;
                SQLMsg * pkMsg(DBManager::instance().DirectQuery("SELECT price from player_shop_items where shop_id='%d'",shop_id));
                SQLResult * pRes = pkMsg->Get();
                if (pRes->uiNumRows>0)
                {
                    MYSQL_ROW row;
                    while ((row = mysql_fetch_row(pRes->pSQLResult)) != NULL)
                    {
                        long long temp = 0;
                        str_to_number(temp,row[0]);
                        nTotalMoney+=temp;
                    }
                }
                if (GOLD_MAX <= nTotalMoney)
                {
                    //sys_err("[OVERFLOW_GOLD] Overflow (GOLD_MAX) id %u name %s", ch->GetPlayerID(), ch->GetName());
                    ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("20ld lÉR» AE°úÇDz© »óÁ^R» zLö°^ lr¨R´D´U"));
                    do_shop_refresh_items(ch,args[1].c_str(),0,0);
                    return;
                }
            }
        #endif
            LPITEM item = ch->GetItem(TItemPos(window_type, pos));
            if (item)
            {
                const TItemTable * item_table = item->GetProto();

                if (item_table && (IS_SET(item_table->dwAntiFlags, ITEM_ANTIFLAG_GIVE | ITEM_ANTIFLAG_MYSHOP)))
                {
                    ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT( "RZ·áC lCRELURş °lRλóÁ^z^L CǸLÇN Lö lr¨R´D´U."));
                    do_shop_refresh_items(ch,args[1].c_str(),0,0);
                    return;
                }

                if (item->IsEquipped())
                {
                    ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT( "RlşnÁßRÎ lCRELURş °lRλóÁ^z^L CǸLÇN Lö lr¨R´D´U."));
                    do_shop_refresh_items(ch,args[1].c_str(),0,0);
                    return;
                }

                if (item->isLocked())
                {
                    ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT( "»çzëÁßRÎ lCRELURş °lRλóÁ^z^L CǸLÇN Lö lr¨R´D´U."));
                    do_shop_refresh_items(ch,args[1].c_str(),0,0);
                    return;
                }
                if (item->GetOwner() != ch)
                {
                    do_shop_refresh_items(ch,args[1].c_str(),0,0);
                    return;
                }
    #ifdef SOULBIND_SYSTEM
                if (item->IsSoulBind())
                {
                    ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT( "You can't sell in private shop item with soul bind."));
                    do_shop_refresh_items(ch,args[1].c_str(),0,0);
                    return;
                }
    #endif
                char query[1024];
                sprintf(query, "INSERT INTO player_shop_items SET");
                sprintf(query, "%s player_id='%d'", query, ch->GetPlayerID());
                sprintf(query, "%s, shop_id='%d'", query, shop_id);
                sprintf(query, "%s, vnum='%d'", query, item->GetVnum());
                sprintf(query, "%s, count='%d'", query, item->GetCount());
                sprintf(query, "%s, price='%lld'", query, price);
    #ifdef ENABLE_OFFLINE_SHOP_USE_CHEQUE
                    sprintf(query, "%s, cheque='%d'", query, cheque);
    #endif

                sprintf(query, "%s, display_pos='%u'", query, display_pos);
                for (int s = 0; s < ITEM_SOCKET_MAX_NUM; s++)
                {
                    sprintf(query, "%s, socket%d='%ld'", query, s, item->GetSocket(s));

                }

                for (int ia = 0; ia < ITEM_ATTRIBUTE_MAX_NUM; ia++)
                {
                    const TPlayerItemAttribute& attr = item->GetAttribute(ia);
                    if (ia < 7)
                    {
                        sprintf(query, "%s, attrtype%d='%u'", query, ia, attr.bType);
                        sprintf(query, "%s, attrvalue%d='%d'", query, ia, attr.sValue);
                    }
                    else
                    {
                        sprintf(query, "%s, applytype%d='%u'", query, ia-7, attr.bType);
                        sprintf(query, "%s, applyvalue%d='%d'", query, ia-7, attr.sValue);
                    }
                }

                DBManager::instance().DirectQuery(query);
                ITEM_MANAGER::Instance().RemoveItem(item, "Priv shop");
                DBManager::instance().DirectQuery("UPDATE player_shop SET item_count=item_count +1 WHERE id = %d", shop_id);
            }
            else
                return;
            ch->LoadPrivShops();
        char buf[32];
        sprintf(buf, "refresh_shop_items %d", shop_id);
        interpret_command(ch, buf, strlen(buf));
        CharacterVectorInteractor i;
        if (CHARACTER_MANAGER::instance().GetCharactersByRaceNum(30000, i))
        {
            CharacterVectorInteractor::iterator it = i.begin();
            while (it != i.end()) {
                LPCHARACTER pc = *it++;
                if (pc)
                    if (pc->GetRaceNum() == 30000 && pc->GetPrivShop() == shop_id) {
                        pc->UpdateShopItems();
                        return;
                    }


            }
        }

        TPacketShopUpdateItem packet;
        packet.shop_id = shop_id;
        packet.shop_locked = false;
        db_clientdesc->DBPacket(HEADER_GD_SHOP_UPDATE_ITEM, 0, &packet, sizeof(packet));
        }
    }

}
 
Geri
Üst