[Release] Buy Item Quantity From Marketplace

Experienced Elementalist
Joined
Oct 14, 2015
Messages
265
Reaction score
284
Requires Flash Source Files < Click here

If you are not using a custom FrontEnd you can get away with using this Published version with only the below changes made. > <

--------
Stage 1 Editing Flash Files
Open src\classes\warz\events\charPopup.as
Find
if (xp)
FrontEndEvents.eventBuyItem (charID, 0, charStoreItem.priceGD);
else
FrontEndEvents.eventBuyItem (charID, charStoreItem.price, 0);
Replace With
if (xp)
FrontEndEvents.eventBuyItem (charID, 0, charStoreItem.priceGD, 1);
else
FrontEndEvents.eventBuyItem (charID, charStoreItem.price, 0 , 1);


Open src\classes\warz\events\FrontEndEvents.as
Find
public static function eventBuyItem (itemID:uint, price:int, priceGD:int)
{
send("eventBuyItem", itemID, price, priceGD);
}
Replace With
public static function eventBuyItem (itemID:uint, price:int, priceGD:int, Quantity:int)
{
send("eventBuyItem", itemID, price, priceGD, Quantity);
}


Open src\classes\warz\frontend\MarketplaceScreen.as
Find
private var transactionsData:Array = null;
Add Below
private var BuyQuantity;
private var BuyItemID;
private var BuyGameDollar;
private var BuyGamePoints;

Find
public function ActionFunction (button:String)
{
....
}
Replace With
public function ActionFunction (button:String)
{
if (button == "BuyBtn")
{
Marketplace.BuyBtn.State = "off";
Marketplace.BuyBtn.gotoAndPlay("out");

if (SelectedItem)
{
var item:Item = SelectedItem.Item;
var storeItem:StoreItem = SelectedItem.StoreItem;

if (api.isDebug)
{
var inventItem:InventoryItem = api.getInventoryItemByID (item.itemID);


if (inventItem)
{
inventItem.quantity += 1;
}
else
api.addInventoryItem(api.InventoryDB.length, item.itemID, 1, 0, 0, false);

api.money.gc -= storeItem.price;
api.money.dollars -= storeItem.priceGD;

api.buyItemSuccessful ()
}
else
{
BuyQuantity = 1;
BuyItemID = item.itemID;
BuyGameDollar = storeItem.priceGD;
BuyGamePoints = storeItem.price;
api.Main.MsgBox.showInfoInputMsg("How many would you like to buy?", "", eventBuyQtyCallback);
}


}
}
else if (button.indexOf("PopupSlot") != -1)
{
var slot = int (button.slice (9)) - 1;
var storeSlot = Marketplace.Slots.getChildAt(slot);


if (storeSlot)
{
showDescription (storeSlot);
}
}
else if (button.indexOf("Tab") != -1)
{
var tab = int (button.slice (3)) - 1;
var Name = "Tab" + (SelectedTabID + 1);
Marketplace[Name].State = "off";
Marketplace[Name].gotoAndPlay("out");


updateStoreItemsList (tab);
showDescription (null);
}
}


public function eventBuyQtyCallback (state:Boolean, text:String=""):void
{
if (state)
{
var q:uint = uint(text);
if(q>0)
FrontEndEvents.eventBuyItem (BuyItemID, BuyGamePoints, BuyGameDollar, q);
}
}


Open src\Frontend.fla and Publish.
--------
Stage 2 Editing the API

Open server\src\Scripts\WZBackend-ASP.NET\WZBackend-ASP.NET.sln
The files you will need open are: api_ClanMgr.aspx.cs, api_ClanCreate.aspx.cs, api_CharSlots.aspx.cs, api_BuyItem3.aspx.cs

Inside api_ClanMgr.aspx.cs;
Find
sqcmd.Parameters.AddWithValue("@in_BuyDays", 2000);
Add Below
sqcmd.Parameters.AddWithValue("@in_Qty", 1);


Inside api_ClanCreate.aspx.cs;
Find
sqcmd.Parameters.AddWithValue("@in_BuyDays", 2000);
Add Below
sqcmd.Parameters.AddWithValue("@in_Qty", 1);

Inside api_CharSlots.aspx.cs;
Find
sqcmd.Parameters.AddWithValue("@in_BuyDays", 2000);
Add Below
sqcmd.Parameters.AddWithValue("@in_Qty", 1);

Inside api_BuyItem3.aspx.cs;
Find
string BuyIdx = web.Param("BuyIdx");
Add Below
string Qty = web.Param("Qty");

Find
sqcmd.Parameters.AddWithValue("@in_BuyDays", BuyItem3.GetBuyDaysFromIdx(BuyIdx));
Add Below
sqcmd.Parameters.AddWithValue("@in_Qty", Qty);

--------
Stage 3 Editing Function in Database
Open your Server DB


Open WarZ\Functions\WZ_BuyItemFN_Exec
Here is the full code

Open WarZ\Functions\WZ_BuyItem_GD

Here is the full code

Open WarZ\Functions\WZ_BuyItem_GP
Here is the full code
--------
Stage 4 Editing the Source

Client

Open FontEndWarZ.h
Find
int mStore_BuyPriceGD;
Add Below
int mStore_BuyQuantity;

Open FrontEndWarZ.cpp :: eventBuyItem
Find
mStore_BuyPriceGD = args[2].GetInt();
Add Below
mStore_BuyQuantity = args[3].GetInt(); // new quantity code
mStore_BuyPrice *= mStore_BuyQuantity; // make price take into account the new quantity!
mStore_BuyPriceGD *= mStore_BuyQuantity; // make price take into account the new quantity!

Find (unsigned int WINAPI FrontendWarZ::as_BuyItemThread(void* in_data))
int apiCode = gUserProfile.ApiBuyItem(This->mStore_BuyItemID, buyIdx, &This->m_inventoryID);
Replace With
int apiCode = gUserProfile.ApiBuyItem(This->mStore_BuyItemID, buyIdx, &This->m_inventoryID, This->mStore_BuyQuantity);

Find
int quantityToAdd = storecat_GetItemBuyStackSize(mStore_BuyItemID);
Replace With
int quantityToAdd = storecat_GetItemBuyStackSize(mStore_BuyItemID) * mStore_BuyQuantity;

Open UserProfile.cpp
Find
int CClientUserProfile::ApiBuyItem(int itemId, int buyIdx, __int64* out_InventoryID)
Replace With
int CClientUserProfile::ApiBuyItem(int itemId, int buyIdx, __int64* out_InventoryID, int qty)

Within (ApiBuyItem)
Find
req.AddParam("BuyIdx", buyIdx);
Add Below
req.AddParam("Qty", qty);

Open UserProfile.h
Find
int ApiBuyItem(int itemId, int buyIdx, __int64* out_InventoryID);
Replace
int ApiBuyItem(int itemId, int buyIdx, __int64* out_InventoryID, int qty);

Server
Open AsyncFuncs.cpp
Find
req.AddParam("BuyIdx", BuyIdx);
Add Below
req.AddParam("Qty", 1);
This will fix ingame store. As it does not yet have support for qty purchases will default to 1 / 1 stack.
--------

* Confirmed Working *

Please post any errors you receive on this thread and will gladly fix these for you.



Hope it all works regardless or atleast helps you make progress getting this system running.


<3 Hit that Likes button


Special Thanks @erickstyle for posting a fix and the community for feeding back bugs.
 
Last edited:
Re: Buy Item Quantity From Marketplace

i have this error

Code:
1>.\Sources\UI\FrontEndWarZ.cpp(2820) : error C2664: 'CClientUserProfile::ApiBuyItem' : cannot convert parameter 4 from 'int *' to 'int'
1>        There is no context in which this conversion is possible

0D773wi - [Release] Buy Item Quantity From Marketplace - RaGEZONE Forums
 
Re: Buy Item Quantity From Marketplace

i can not find the other things under frontendevents :L
Open src\classes\warz\FrontEnd\MarketPlace.as

sorry was inside for the rest.
i have this error

Code:
1>.\Sources\UI\FrontEndWarZ.cpp(2820) : error C2664: 'CClientUserProfile::ApiBuyItem' : cannot convert parameter 4 from 'int *' to 'int'
1>        There is no context in which this conversion is possible

GetRektBambi - [Release] Buy Item Quantity From Marketplace - RaGEZONE Forums

will take a look when I get home, just doing some shopping.
 
Re: Buy Item Quantity From Marketplace

i remove the "$"

int apiCode = gUserProfile.ApiBuyItem(This->mStore_BuyItemID, buyIdx, &This->m_inventoryID, This->mStore_BuyQuantity);

and compile ok.. i will continue
 
Re: Buy Item Quantity From Marketplace

i have this error

Code:
1>.\Sources\UI\FrontEndWarZ.cpp(2820) : error C2664: 'CClientUserProfile::ApiBuyItem' : cannot convert parameter 4 from 'int *' to 'int'
1>        There is no context in which this conversion is possible

GetRektBambi - [Release] Buy Item Quantity From Marketplace - RaGEZONE Forums
I have this error aswell :/
 
Re: Buy Item Quantity From Marketplace

Everything works fine but when i buy something it gives me only one... it doesn't give me the quantity i ask for.
 
Re: Buy Item Quantity From Marketplace

Have fixed the single item purchase

Inside the Marketplacescreen.fla
public function eventBuyQtyCallback (state:Boolean, text:String=""):void
{
if (state)
{
var q:uint = uint(text);
if(q>0)
FrontEndEvents.eventBuyItem (BuyItemID, BuyGamePoints, BuyGameDollar, q);
}
}
Red was the problem. Re-publish and should be fixed. I will uploaded a new swf. It was reading from variable initially set to 1 and never updated. It is not needed and will read directly from the box reply.
 
Re: Buy Item Quantity From Marketplace

@GetRektBambi

You could put the sql querys on pastebin? There he not mess anything. Please

Have done this :) Updated main thread

Updated: Check Main Thread for link (Fix for single purchase of items)

Anymore problems please let me know :)
 
Last edited:
Back