Metin2 Coins shop (NPC)

Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Capturre

Member
Joined
Dec 29, 2019
Messages
99
Credits
0
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.

Edmund.
 
Back
Top