Jump to content

Coins Ingame SHOP!


Recommended Posts

Hi everone!
I watch the servers, and i find one, whos use a little interesting system, so i tried to code that.
The system, how they add some NPC, where you can buy items, but not for yang.
Maybe for gaya, or other currency what you would to use.
Here we go.
At first, please make backup from the file, or do the tutorial as clever what you can.

Open : shop.cpp
Search : void CShop::SetShopItems(

Add after this function

static void _buy_from_cash(LPCHARACTER ch)
{
if (ch)
{
SQLMsg * pMsg = DBManager::instance().DirectQuery("select cash from account.account WHERE id = %d",ch->GetDesc()->GetAccountTable().id);
if (pMsg->Get()->uiNumRows > 0)
{
MYSQL_ROW row = mysql_fetch_row(pMsg->Get()->pSQLResult);
ch->ChatPacket(CHAT_TYPE_COMMAND, "BFC %s", row[0]);
delete pMsg;
}
}
}
//Now search : int CShop::Buy(

Search in this function : if (ch->GetGold() < (int) dwPrice)
Replace wtih : if (ch->GetGold() < (int) dwPrice && !(GetNPCVnum() == ID))

Add next line after the function :

else if (GetNPCVnum() == ID)
{
CharacterVectorInteractor::iterator it = i.begin();
DWORD fiyat = r_item.price;

long ep = ch->Ep_Miktar();
if (ep < fiyat)
{
return NOT_ENOUGH_CASH;
}
else
ch->Set_Ep(ch->Ep_Miktar()-fiyat);
_buy_from_cash(ch);
}

ID = the NPC vnum where you want buy from coins.

Thats all.

Good luck for all.
Tested and work perfectly.
 

  • Like 1
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

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

×
×
  • Create New...