Make check if version 10.97 then add new bytes else not@alissonfgp how to use 10.96 too (without debbugs), I make your changes but only working 10.97 with changes, 10.96 got debbug
msg.add<uint16_t>(page);
msg.AddByte((storeHistory.size() > entriesPerPage) ? 0x01 : 0x00);
to
msg.add<uint32_t>(page);
msg.add<uint32_t>((storeHistory.size() > entriesPerPage) ? 0x01 : 0x00);
and
msg.add<uint32_t>(offer.getPrice());
to
msg.add<uint32_t>(offer.getPrice());
msg.AddByte(0);
yo bro, you know what byte use to show the "orange" offers? the new status ? I use the c++ too... but I did not find thisThere are more bytes in the store. In store history you need to change. I use store in c++ but I hope you can edit in lua too.
Code:msg.add<uint16_t>(page); msg.AddByte((storeHistory.size() > entriesPerPage) ? 0x01 : 0x00); to msg.add<uint32_t>(page); msg.add<uint32_t>((storeHistory.size() > entriesPerPage) ? 0x01 : 0x00); and msg.add<uint32_t>(offer.getPrice()); to msg.add<uint32_t>(offer.getPrice()); msg.AddByte(0);
Yes there is new message type for that I will post later cuz I am not on my working PC now.yo bro, you know what byte use to show the "orange" offers? the new status ? I use the c++ too... but I did not find this
msg.add<uint32_t>(offer.getPrice());
to
msg.add<uint32_t>(offer.getPrice());
msg.AddByte(0x01);
msg.AddByte(time(nullptr) + 3600); // time where offer expires
msg.add<uint32_t>(offer.getPrice() + 10) // base price for offer
Also one question from me. How do u find these changes ?There are more bytes in the store. In store history you need to change. I use store in c++ but I hope you can edit in lua too.
Code:msg.add<uint16_t>(page); msg.AddByte((storeHistory.size() > entriesPerPage) ? 0x01 : 0x00); to msg.add<uint32_t>(page); msg.add<uint32_t>((storeHistory.size() > entriesPerPage) ? 0x01 : 0x00); and msg.add<uint32_t>(offer.getPrice()); to msg.add<uint32_t>(offer.getPrice()); msg.AddByte(0);
Send your function here.Hey @gunz can you send your void ProtocolGame::sendStoreOffers(StoreCategory& category) ??
please I use c++ code and got debbug when click onstore
void ProtocolGame::sendStoreOffers(StoreCategory& category)
{
NetworkMessage msg;
msg.addByte(0xFC);
msg.addString(category.getName());
msg.add<uint16_t>(category.getOffers().size());
for (auto& offer : category.getOffers()) {
msg.add<uint32_t>(offer.getId());
msg.addString(offer.getName());
msg.addString(offer.getDescription());
msg.add<uint32_t>(offer.getPrice());
msg.addByte(offer.getState());
msg.addByte(!g_store->executeOnRender(player, &offer));
msg.addByte(offer.getIcons().size());
for (const auto& icon : offer.getIcons()) {
msg.addString(icon);
}
msg.add<uint16_t>(offer.getSubOffers().size());
for (auto& subOffer : offer.getSubOffers()) {
msg.addString(subOffer.getName());
msg.addString(subOffer.getDescription());
msg.addByte(subOffer.getIcons().size());
for (const auto& icon : subOffer.getIcons()) {
msg.addString(icon);
}
msg.addString(subOffer.getParent()); //serviceType
}
}
writeToOutputBuffer(msg);
}
@gunz
Code:void ProtocolGame::sendStoreOffers(StoreCategory& category) { NetworkMessage msg; msg.addByte(0xFC); msg.addString(category.getName()); msg.add<uint16_t>(category.getOffers().size()); for (auto& offer : category.getOffers()) { msg.add<uint32_t>(offer.getId()); msg.addString(offer.getName()); msg.addString(offer.getDescription()); msg.add<uint32_t>(offer.getPrice()); msg.addByte(offer.getState()); msg.addByte(!g_store->executeOnRender(player, &offer)); msg.addByte(offer.getIcons().size()); for (const auto& icon : offer.getIcons()) { msg.addString(icon); } msg.add<uint16_t>(offer.getSubOffers().size()); for (auto& subOffer : offer.getSubOffers()) { msg.addString(subOffer.getName()); msg.addString(subOffer.getDescription()); msg.addByte(subOffer.getIcons().size()); for (const auto& icon : subOffer.getIcons()) { msg.addString(icon); } msg.addString(subOffer.getParent()); //serviceType } } writeToOutputBuffer(msg); }
void ProtocolGame::sendStoreOffers(StoreCategory& category)
{
NetworkMessage msg;
msg.addByte(0xFC);
msg.addString(category.getName());
msg.add<uint16_t>(category.getOffers().size());
for (auto& offer : category.getOffers()) {
msg.add<uint32_t>(offer.getId());
msg.addString(offer.getName());
msg.addString(offer.getDescription());
msg.add<uint32_t>(offer.getPrice());
msg.addByte(0);
msg.addByte(offer.getState());
msg.addByte(!g_store->executeOnRender(player, &offer));
msg.addByte(offer.getIcons().size());
for (const auto& icon : offer.getIcons()) {
msg.addString(icon);
}
msg.add<uint16_t>(offer.getSubOffers().size());
for (auto& subOffer : offer.getSubOffers()) {
msg.addString(subOffer.getName());
msg.addString(subOffer.getDescription());
msg.addByte(subOffer.getIcons().size());
for (const auto& icon : subOffer.getIcons()) {
msg.addString(icon);
}
msg.addString(subOffer.getParent()); //serviceType
}
}
writeToOutputBuffer(msg);
}
thanks for that information, now I will edit the lua one versionI dont see you implemented new changes. Im on phone now so I cant help you
void ProtocolGame::parseStoreOpen()
{
return sendStore();
}
void ProtocolGame::parseStoreSelectCategory(NetworkMessage& msg)
{
std::string categoryName = msg.getString();
for (auto& category : g_store->getCategories()) {
if (category.getName() == categoryName) {
return g_dispatcher.addTask(createTask(std::bind(&ProtocolGame::sendStoreOffers, getThis(), category)));
}
}
}
void ProtocolGame::parseStoreBuyOffer(NetworkMessage& msg)
{
uint32_t offerId = msg.get<uint32_t>();
StoreOfferType_t offerType = static_cast<StoreOfferType_t>(msg.getByte());
std::string param;
if (offerType == STORE_OFFERTYPE_NAMECHANGE) {
param = msg.getString();
}
auto offer = g_store->getOfferById(offerId);
if (!offer) {
sendStoreError(STORE_ERROR_PURCHASE, "Offer not found. Please reopen the store and try again.");
return;
}
if ((strcasecmp(offer->getName().c_str(), "name change") == 0) && offerType != STORE_OFFERTYPE_NAMECHANGE) {
requestPurchaseData(offerId, STORE_OFFERTYPE_NAMECHANGE);
return;
}
addGameTask(&Game::playerPurchaseStoreOffer, player->getID(), offerId, param);
}
void ProtocolGame::parseStoreOpenHistory(NetworkMessage& msg)
{
storeHistoryEntriesPerPage = msg.getByte();
g_dispatcher.addTask(createTask(std::bind(&ProtocolGame::sendStoreHistory, getThis(), 0, storeHistoryEntriesPerPage)));
}
void ProtocolGame::parseStoreRequestHistory(NetworkMessage& msg)
{
uint16_t page = msg.get<uint16_t>();
g_dispatcher.addTask(createTask(std::bind(&ProtocolGame::sendStoreHistory, getThis(), page, storeHistoryEntriesPerPage)));
}
void ProtocolGame::parseTransferCoins(NetworkMessage& msg)
{
std::string recipient = msg.getString();
uint16_t amount = msg.get<uint16_t>();
addGameTask(&Game::playerTransferCoins, player->getID(), recipient, amount);
}
void ProtocolGame::sendStoreError(StoreError_t errorType, const std::string& message)
{
NetworkMessage msg;
msg.addByte(0xE0);
msg.addByte(errorType);
msg.addString(message);
writeToOutputBuffer(msg);
}
void ProtocolGame::requestPurchaseData(uint32_t offerId, StoreOfferType_t offerType)
{
NetworkMessage msg;
msg.addByte(0xE1);
msg.add<uint32_t>(offerId);
msg.addByte(offerType);
writeToOutputBuffer(msg);
}
void ProtocolGame::sendCoinBalance()
{
NetworkMessage msg;
msg.addByte(0xF2);
msg.addByte(0x01);
msg.addByte(0xDF);
msg.addByte(0x01);
msg.add<uint32_t>(player->coinBalance); //total coins
msg.add<uint32_t>(player->coinBalance); //transferable coins
writeToOutputBuffer(msg);
}
void ProtocolGame::updateCoinBalance()
{
NetworkMessage msg;
msg.addByte(0xF2);
msg.addByte(0x00);
writeToOutputBuffer(msg);
g_dispatcher.addTask(
createTask(std::bind([](ProtocolGame_ptr client) {
auto coinBalance = IOAccount::getCoinBalance(client->player->getAccount());
client->player->coinBalance = coinBalance;
client->sendCoinBalance();
}, getThis()))
);
}
void ProtocolGame::sendStore()
{
NetworkMessage msg;
msg.addByte(0xFB);
msg.addByte(0x00);
//msg.add<uint32_t>(player->coinBalance);
//msg.add<uint32_t>(player->coinBalance);
msg.add<uint16_t>(g_store->getCategories().size());
for (auto& category : g_store->getCategories()) {
msg.addString(category.getName());
msg.addString(category.getDescription());
msg.addByte(category.getIcons().size());
for (const auto& icon : category.getIcons()) {
msg.addString(icon);
}
msg.addString(category.getParent());
}
writeToOutputBuffer(msg);
updateCoinBalance();
}
void ProtocolGame::sendStoreOffers(StoreCategory& category)
{
NetworkMessage msg;
msg.addByte(0xFC);
msg.addString(category.getName());
msg.add<uint16_t>(category.getOffers().size());
for (auto& offer : category.getOffers()) {
msg.add<uint32_t>(offer.getId());
msg.addString(offer.getName());
msg.addString(offer.getDescription());
msg.add<uint32_t>(offer.getPrice());
msg.AddByte(0x01);
msg.AddByte(time(nullptr) + 3600); // time where offer expires
msg.add<uint32_t>(offer.getPrice() + 10) // base price for offer
msg.AddByte(0);
msg.addByte(offer.getState());
msg.addByte(!g_store->executeOnRender(player, &offer));
msg.addByte(offer.getIcons().size());
for (const auto& icon : offer.getIcons()) {
msg.addString(icon);
}
msg.add<uint16_t>(offer.getSubOffers().size());
for (auto& subOffer : offer.getSubOffers()) {
msg.addString(subOffer.getName());
msg.addString(subOffer.getDescription());
msg.addByte(subOffer.getIcons().size());
for (const auto& icon : subOffer.getIcons()) {
msg.addString(icon);
}
msg.addString(subOffer.getParent()); //serviceType
}
}
writeToOutputBuffer(msg);
}
void ProtocolGame::sendStoreHistory(uint16_t page, uint32_t entriesPerPage)
{
// dispatcher thread
std::vector<StoreTransaction> storeHistory;
g_store->getTransactionHistory(player->getAccount(), page, entriesPerPage, storeHistory);
if (storeHistory.size() == 0) {
return sendStoreError(STORE_ERROR_HISTORY, "No entries yet.");
}
NetworkMessage msg;
msg.addByte(0xFD);
msg.add<uint32_t>(page);
msg.add<uint32_t>((storeHistory.size() > entriesPerPage) ? 0x01 : 0x00);
uint8_t entries = std::min<uint8_t>(entriesPerPage, static_cast<uint32_t>(storeHistory.size()));
msg.addByte(entries);
size_t count = 0;
for (const auto& entry : storeHistory) {
if (count++ == entriesPerPage) {
break;
}
msg.add<uint32_t>(entry.timestamp);
msg.addByte(0x00); // product type
msg.add<int32_t>(entry.coins);
msg.addString(entry.description);
}
writeToOutputBuffer(msg);
}
@gunz please man I think ur store is equal look:
Code:void ProtocolGame::parseStoreOpen() { return sendStore(); } void ProtocolGame::parseStoreSelectCategory(NetworkMessage& msg) { std::string categoryName = msg.getString(); for (auto& category : g_store->getCategories()) { if (category.getName() == categoryName) { return g_dispatcher.addTask(createTask(std::bind(&ProtocolGame::sendStoreOffers, getThis(), category))); } } } void ProtocolGame::parseStoreBuyOffer(NetworkMessage& msg) { uint32_t offerId = msg.get<uint32_t>(); StoreOfferType_t offerType = static_cast<StoreOfferType_t>(msg.getByte()); std::string param; if (offerType == STORE_OFFERTYPE_NAMECHANGE) { param = msg.getString(); } auto offer = g_store->getOfferById(offerId); if (!offer) { sendStoreError(STORE_ERROR_PURCHASE, "Offer not found. Please reopen the store and try again."); return; } if ((strcasecmp(offer->getName().c_str(), "name change") == 0) && offerType != STORE_OFFERTYPE_NAMECHANGE) { requestPurchaseData(offerId, STORE_OFFERTYPE_NAMECHANGE); return; } addGameTask(&Game::playerPurchaseStoreOffer, player->getID(), offerId, param); } void ProtocolGame::parseStoreOpenHistory(NetworkMessage& msg) { storeHistoryEntriesPerPage = msg.getByte(); g_dispatcher.addTask(createTask(std::bind(&ProtocolGame::sendStoreHistory, getThis(), 0, storeHistoryEntriesPerPage))); } void ProtocolGame::parseStoreRequestHistory(NetworkMessage& msg) { uint16_t page = msg.get<uint16_t>(); g_dispatcher.addTask(createTask(std::bind(&ProtocolGame::sendStoreHistory, getThis(), page, storeHistoryEntriesPerPage))); } void ProtocolGame::parseTransferCoins(NetworkMessage& msg) { std::string recipient = msg.getString(); uint16_t amount = msg.get<uint16_t>(); addGameTask(&Game::playerTransferCoins, player->getID(), recipient, amount); } void ProtocolGame::sendStoreError(StoreError_t errorType, const std::string& message) { NetworkMessage msg; msg.addByte(0xE0); msg.addByte(errorType); msg.addString(message); writeToOutputBuffer(msg); } void ProtocolGame::requestPurchaseData(uint32_t offerId, StoreOfferType_t offerType) { NetworkMessage msg; msg.addByte(0xE1); msg.add<uint32_t>(offerId); msg.addByte(offerType); writeToOutputBuffer(msg); } void ProtocolGame::sendCoinBalance() { NetworkMessage msg; msg.addByte(0xF2); msg.addByte(0x01); msg.addByte(0xDF); msg.addByte(0x01); msg.add<uint32_t>(player->coinBalance); //total coins msg.add<uint32_t>(player->coinBalance); //transferable coins writeToOutputBuffer(msg); } void ProtocolGame::updateCoinBalance() { NetworkMessage msg; msg.addByte(0xF2); msg.addByte(0x00); writeToOutputBuffer(msg); g_dispatcher.addTask( createTask(std::bind([](ProtocolGame_ptr client) { auto coinBalance = IOAccount::getCoinBalance(client->player->getAccount()); client->player->coinBalance = coinBalance; client->sendCoinBalance(); }, getThis())) ); } void ProtocolGame::sendStore() { NetworkMessage msg; msg.addByte(0xFB); msg.addByte(0x00); //msg.add<uint32_t>(player->coinBalance); //msg.add<uint32_t>(player->coinBalance); msg.add<uint16_t>(g_store->getCategories().size()); for (auto& category : g_store->getCategories()) { msg.addString(category.getName()); msg.addString(category.getDescription()); msg.addByte(category.getIcons().size()); for (const auto& icon : category.getIcons()) { msg.addString(icon); } msg.addString(category.getParent()); } writeToOutputBuffer(msg); updateCoinBalance(); } void ProtocolGame::sendStoreOffers(StoreCategory& category) { NetworkMessage msg; msg.addByte(0xFC); msg.addString(category.getName()); msg.add<uint16_t>(category.getOffers().size()); for (auto& offer : category.getOffers()) { msg.add<uint32_t>(offer.getId()); msg.addString(offer.getName()); msg.addString(offer.getDescription()); msg.add<uint32_t>(offer.getPrice()); msg.AddByte(0x01); msg.AddByte(time(nullptr) + 3600); // time where offer expires msg.add<uint32_t>(offer.getPrice() + 10) // base price for offer msg.AddByte(0); msg.addByte(offer.getState()); msg.addByte(!g_store->executeOnRender(player, &offer)); msg.addByte(offer.getIcons().size()); for (const auto& icon : offer.getIcons()) { msg.addString(icon); } msg.add<uint16_t>(offer.getSubOffers().size()); for (auto& subOffer : offer.getSubOffers()) { msg.addString(subOffer.getName()); msg.addString(subOffer.getDescription()); msg.addByte(subOffer.getIcons().size()); for (const auto& icon : subOffer.getIcons()) { msg.addString(icon); } msg.addString(subOffer.getParent()); //serviceType } } writeToOutputBuffer(msg); } void ProtocolGame::sendStoreHistory(uint16_t page, uint32_t entriesPerPage) { // dispatcher thread std::vector<StoreTransaction> storeHistory; g_store->getTransactionHistory(player->getAccount(), page, entriesPerPage, storeHistory); if (storeHistory.size() == 0) { return sendStoreError(STORE_ERROR_HISTORY, "No entries yet."); } NetworkMessage msg; msg.addByte(0xFD); msg.add<uint32_t>(page); msg.add<uint32_t>((storeHistory.size() > entriesPerPage) ? 0x01 : 0x00); uint8_t entries = std::min<uint8_t>(entriesPerPage, static_cast<uint32_t>(storeHistory.size())); msg.addByte(entries); size_t count = 0; for (const auto& entry : storeHistory) { if (count++ == entriesPerPage) { break; } msg.add<uint32_t>(entry.timestamp); msg.addByte(0x00); // product type msg.add<int32_t>(entry.coins); msg.addString(entry.description); } writeToOutputBuffer(msg); }
msg.AddByte(0x01);
msg.AddByte(time(nullptr) + 3600); // time where offer expires
msg.add<uint32_t>(offer.getPrice() + 10) // base price for offer
remove those 3 lines and it should work
Code:msg.AddByte(0x01); msg.AddByte(time(nullptr) + 3600); // time where offer expires msg.add<uint32_t>(offer.getPrice() + 10) // base price for offer
are you updating from 10.96 ?thanks, but I still got debbugs
any other idea ? how is ur store code in protocolgame
are you updating from 10.96 ?
I posted changes only from 10.96 to 10.97/98.I dont know what changed from 10.92My store stop working (debbuging) in 10.92+ I using 10.97+ now
I posted changes only from 10.96 to 10.97/98.I dont know what changed from 10.92
My code is very customized so diff won't help you. You can decompile flash client to get the proper bytes.If it was very uncomfortable, you could spend your code? I can see in diffchecker and fix this, o/ please?