Jump to content

[C++]MP Cuando compran items Offline Shop - Great


NazoX

Mensajes recomendados

Como algunos tienen problema con la versión publicada, pondré aquí en que parte va cada línea, ya que en el otro solo te pone "añade" y listo.

Requisitos:

-Ultima versión de Great Offline Shop

-Comprobar que te funcionase la Offline shop, pues hay veces que directamente ni se prueba y de por si no funciona

-Si no te  funciona con esta guía es porque no es la misma versión o necesitas adaptarla de otra forma.

 

1- Vamos al source game en nuestro servidor, y abrimos el archivo input.h y buscamos:

Quote

    protected:
        CPacketInfoGG     m_packetInfoGG;
};

ahora, antes de eso añadimos:

Quote

        void        SendOfflineShopMessage(LPDESC d, const char * c_pData);

tendría que quedarte algo así:

70820f72b489ec99dc4a20d13a6c98a2.png

2-Ahora nos vamos al archivo input2_p2p.cpp y a los includes añadimos:

Quote

#include "buffer_manager.h"

2,1-Ahora buscamos:

Quote

int CInputP2P::Analyze(LPDESC d, BYTE bHeader, const char * c_pData)
{
    if (test_server)
        sys_log(0, "CInputP2P::Anlayze[Header %d]", bHeader);

    int iExtraLen = 0;

    switch (bHeader)
    {
        case HEADER_GG_SETUP:
            Setup(d, c_pData);
            break;

Antes de esta función añadimos:

Quote

void CInputP2P::SendOfflineShopMessage(LPDESC d, const char * c_pData)
{
    TPacketGGOfflineShopMessage * p = (TPacketGGOfflineShopMessage *)c_pData;
    LPCHARACTER ch = CHARACTER_MANAGER::instance().FindByPID(p->dwTargetPID);

    if (ch)
    {
        LPDESC pkVictimDesc = ch->GetDesc();

        if (pkVictimDesc)
        {
            char msg[CHAT_MAX_LEN + 1];
            snprintf(msg, sizeof(msg), LC_TEXT("Your item %s sold, buyer is: %s."), p->szItemName, p->szName);

            TPacketGCWhisper pack;

            int len = MIN(CHAT_MAX_LEN, strlen(msg) + 1);

            pack.bHeader = HEADER_GC_WHISPER;
            pack.wSize = sizeof(TPacketGCWhisper)+len;
            pack.bType = WHISPER_TYPE_SYSTEM;
            strlcpy(pack.szNameFrom, "[Offline Shop]", sizeof(pack.szNameFrom));

            TEMP_BUFFER buf;

            buf.write(&pack, sizeof(TPacketGCWhisper));
            buf.write(msg, len);
            pkVictimDesc->Packet(buf.read_peek(), buf.size());
        }
    }
}

y así se tendría que ver:

014e7943bb8502f05c8c0a0cc2234df1.png

Ahora volvemos a buscar:

Quote

int CInputP2P::Analyze(LPDESC d, BYTE bHeader, const char * c_pData)

y al final del todo antes de :

Quote

return (iExtraLen);

añadimos:

Quote

        case HEADER_GG_OFFLINE_SHOP_SEND_MESSAGE:
            SendOfflineShopMessage(d, c_pData);
            break;    

tiene que quedar así:

68a5917c55ba430ee44af07fc795ed9c.png

3-Ahora abrimos nuestro packet.h y buscamos lo siguiente:

Quote

HEADER_GG_CHECK_AWAKENESS

y debajo añadimos:

Quote

HEADER_GG_OFFLINE_SHOP_SEND_MESSAGE    = 53,

*nota* Es recomendable verificar que no se está utilizando el packet 53 para evitar problemas de paquetes,

fd9295b8c564faa9d6fdd50c05cbaa54.png

Ahora vamos al final del todo, y antes de :

Quote

#pragma pack()
#endif

agregamos:

Quote

typedef struct SPacketGGOfflineShopMessage
{
    BYTE    bHeader;
    DWORD    dwTargetPID;
    char    szName[CHARACTER_NAME_MAX_LEN + 1];
    char    szItemName[ITEM_NAME_MAX_LEN + 1];
} TPacketGGOfflineShopMessage;

0e62e1b77bdd9c72519c1676d72b61e6.png

5-Nos dirigimos a packet_info.cpp y buscamos:

Quote

Set(HEADER_GG_CHECK_AWAKENESS,        sizeof(TPacketGGCheckAwakeness),    "CheckAwakeness",        false);

y debajo añadimos:

Quote

Set(HEADER_GG_OFFLINE_SHOP_SEND_MESSAGE, sizeof(TPacketGGOfflineShopMessage), "OfflineShopUpdateMessage", false);

c9cd1ce37c15e84a41ba02c4782cc760.png

6.Ahora abrimos shop.cpp y añadimos en los includes:

Quote

#include "p2p.h"

6-Ahora buscamos:

Quote

#ifdef FULL_YANG
            snprintf(buf, sizeof(buf), "%s %u(%s) %lld %u", pkNewItem->GetName(), mpid, m_pkPC->GetName(), dwPrice, pkNewItem->GetCount());
            LogManager::instance().ItemLog(ch, pkNewItem, szBuy.c_str(), buf);
            snprintf(buf, sizeof(buf), "%s %u(%s) %lld %u", pkNewItem->GetName(), ch->GetPlayerID(), ch->GetName(), dwPrice, pkNewItem->GetCount());
            LogManager::instance().ItemLog(m_pkPC, pkNewItem, szSell.c_str(), buf);
#else
            snprintf(buf, sizeof(buf), "%s %u(%s) %u %u", pkNewItem->GetName(), mpid, m_pkPC->GetName(), dwPrice, pkNewItem->GetCount());
            LogManager::instance().ItemLog(ch, pkNewItem, szBuy.c_str(), buf);
            snprintf(buf, sizeof(buf), "%s %u(%s) %u %u", pkNewItem->GetName(), ch->GetPlayerID(), ch->GetName(), dwPrice, pkNewItem->GetCount());
            LogManager::instance().ItemLog(m_pkPC, pkNewItem, szSell.c_str(), buf);
#endif

*Nota* si no lo encuentras, o tienes varios (solo deberías tener este), se añade en la función:

Quote

#ifdef OFFLINE_SHOP
#include "char.h"
int CShop::Buy(LPCHARACTER ch, BYTE pos)

bien, debajo del ifdef FULL_YANG añadimos:

Quote

            LPCHARACTER BuyPMCh = CHARACTER_MANAGER::instance().FindByPID(m_pkPC->GetPrivShopOwner());
            if (BuyPMCh)
            {
                char msg[CHAT_MAX_LEN + 1];
                snprintf(msg, sizeof(msg), LC_TEXT("Your item %s x%u sold, buyer is: %s."), pkNewItem->GetName(), pkNewItem->GetCount(), ch->GetName());
                LPDESC pkVictimDesc = BuyPMCh->GetDesc();
                if (pkVictimDesc)
                {
                    TPacketGCWhisper pack;
                    int len = MIN(CHAT_MAX_LEN, strlen(msg) + 1);
                    pack.bHeader = HEADER_GC_WHISPER;
                    pack.wSize = sizeof(TPacketGCWhisper)+len;
                    pack.bType = WHISPER_TYPE_SYSTEM;
                    strlcpy(pack.szNameFrom, "[Offline Shop]", sizeof(pack.szNameFrom));
                    TEMP_BUFFER buf;
                    buf.write(&pack, sizeof(TPacketGCWhisper));
                    buf.write(msg, len);
                    pkVictimDesc->Packet(buf.read_peek(), buf.size());
                }
            }
            else
            {
                TPacketGGOfflineShopMessage p;
                p.bHeader = HEADER_GG_OFFLINE_SHOP_SEND_MESSAGE;
                p.dwTargetPID = m_pkPC->GetPlayerID();
                strlcpy(p.szItemName, pkNewItem->GetName(), sizeof(p.szItemName));
                strlcpy(p.szName, ch->GetName(), sizeof(p.szName));
                P2P_MANAGER::instance().Send(&p, sizeof(TPacketGGOfflineShopMessage));
            }

 

159463598c4027a742f402516e7c352d.png

y este será el resultado:

Debes iniciar sesión para ver el contenido del enlace en esta publicación.

 

Enlace para comentar
Compartir en otros sitios

hace 1 hora, ♥ TesT ♥ dijo:

estaria bueno si tuebises la shop q dejes el link jaja gracias

La versión que tengo yo es un poco diferente a la que hay pública, pero puedes usar esta que también es funcional

Debes iniciar sesión para ver el contenido del enlace en esta publicación.

Enlace para comentar
Compartir en otros sitios

Unirse a la conversación

Puedes publicar ahora y registrarte más tarde. Si tienes una cuenta, regístrate para publicar con su cuenta.

Guest
Responder a este tema...

×   Has pegado contenido con formato .   Eliminar formato

  Only 75 emoji are allowed.

×   Tu enlace se ha incorporado automáticamente.   Mostrar un enlace en su lugar

×   Se ha restaurado el contenido anterior. .   Borrar editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recientemente navegando por este tema   0 miembros

    • No hay usuarios registrados visitando esta página.
×
×
  • Crear nuevo...