Adding Custom Currencies

Newbie Spellweaver
Joined
Oct 31, 2016
Messages
17
Reaction score
0
Hi there.

I googled a bit and saw that many servers have custom currencies and NPCs selling stuff with that currency.
After doing some research I didn't find any source or tutorials on how to add custom currencies or the download-links were already down.

Now here's my question? Where do I start building my own currency and adding a VendorType for this currency?

Any help would be appreciated.

-HowltheHusky
 
I can't really get too much out of that source. It only tells me that there are multiple numbers that can define the VenderType, but I don't really know where to define which number does what to that vendor. Looking at Project.h didn't do anything aswell.
Same for AddVenderItem2. It just tells me that the functions adds an item to given NPC ._.
 
Ok i will tell you in what files you need to script.
The rest is up to you.

Item.cpp Look at GetChipcost.

Mover.cpp Look at if(pCharacter->m_nVenderType == 1)

Project.cpp Look at for( i = 0; i < lpCharacter->m_venderItemAry2[ j ].GetSize(); i++)

Project.cpp Look at else if( script.Token == "AddVenderItem2" || script.Token == "AddVendorItem2")

Wndfield.cpp Look at if(g_pPlayer->m_Inventory.GetAtItemNum( II_CHP_RED ) - (int)((CItemElem*)lpShortcut->m_dwData)->GetChipCost() >= 0)

WndShop.cpp Look at else if(m_nBuyType == 1)
dwCost = m_pItemElem->GetChipCost();

WndItemCtrl.cpp look at if( bRander == 0 && g_pPlayer->m_Inventory.GetAtItemNum( II_CHP_RED ) < (int)pItemElem->GetChipCost() )

WndManger.cpp Look at else if(lpCharacter->m_nVenderType == 1)
nCost = pItemElem->GetChipCost();

WndManager.cpp Look at if(lpCharacter && lpCharacter->m_nVenderType == 1)

DPSrvr.cpp if( lpChar && lpChar->m_nVenderType !=1

DPSrvr.cpp if( lpChar && ( lpChar->m_nVenderType == 1 && pUser->m_Inventory.GetAtItemNum( II_CHP_RED ) < (int)( pItemElem->GetChipCost() * nNum ) ) )

DPSrvr.cpp if( lpChar && lpChar->m_nVenderType == 1 )

All of the above points to RedChips.

So with this you should be aible to create new Currency. The only thing you need to do is read and change/Add things so you have an new currency.

1. Example

Item.cpp
Code:
#if __VER >= 11 // __GUILDCOMBATCHIP
DWORD CItemBase::GetChipCost()
{
	ItemProp *pProp = GetProp();
	if( pProp == NULL )		
		return -1;
	if( pProp->dwReferValue1 == 0xFFFFFFFF )	
		return -1;

	return pProp->dwReferValue1;
}
#endif // __GUILDCOMBATCHIP

Now add this
Code:
#ifdef __NPC_SILVER
DWORD CItemBase::GetSilverCost()
{
	ItemProp *pProp = GetProp();
	if( pProp == NULL )		
		return -1;
	if( pProp->dwReferValue1 == 0xFFFFFFFF )	
		return -1;

	return pProp->dwReferValue1;
}
#endif

See how its done?
 
Wow that is more than I expected, thanks a bunch, I will give it a shot. Let's see if a programming newb like me can figure it out. :D
 
Last edited:
Check void CDPSrvr::OnBuyChipItem inside DPSrvr

There you will see if( lpChar && lpChar->m_nVenderType != 1 ) return.

Simple means if the m_nVenderType is something else then 1 then do nothing.

DPSrvr.cpp
Code:
if( pUser->m_Inventory.GetAtItemNum( II_CHP_RED ) < (int)( pItemElem->GetChipCost() * nNum ) )
		{
			// Ĩ °³¼ö ºÎÁ· ÅØ½ºÆ® Ãâ·Â
			pUser->AddDefinedText( TID_GAME_LACKCHIP );
			return;
		}
[code]

Here you must do it like this
[code]
if( lpChar && lpChar->m_nVenderType == 1 && pUser->m_Inventory.GetAtItemNum( II_CHP_RED ) < (int)( pItemElem->GetChipCost() * nNum ) )
		{
			pUser->AddDefinedText( TID_GAME_LACKCHIP );
			return;
		}

Cause if you create more VenderTypes then you need to define it like this other wise it will give problems.

Example

Code:
#ifdef __NPC_EVENT
		if( lpChar->m_nVenderType == 5 && pUser->m_Inventory.GetAtItemNum( 224930 ) < (int)( pItemElem->GetEveCost() * nNum ) )
		{
			pUser->AddDefinedText( TID_GAME_LACKCHIP );
			return;
		}
#endif	
		if( lpChar && lpChar->m_nVenderType == 1 && pUser->m_Inventory.GetAtItemNum( II_CHP_RED ) < (int)( pItemElem->GetChipCost() * nNum ) )
		{
			pUser->AddDefinedText( TID_GAME_LACKCHIP );
			return;
		}

If i dont check it the m_nVendertype = 1 or = 5 then it will be confused so it will say you dont have enough Red Chips if i wanted to buy something with silver hearts.

Its an lot to take in if you just started. But it look way more difficult then it is.
Is an mater of copy paste with altering stuff so that it fits what you need.
 
I'm running into a slight problem. In Item.cpp I added a placeholder function for my own currency like this:

Code:
DWORD CItemBase::GetHuskyCost()
{
    ItemProp *pProp = GetProp();
    if( pProp == NULL )        
        return -1;
    if( pProp->dwReferValue1 == 0xFFFFFFFF )    
        return -1;

    return pProp->dwReferValue1;
}

However, it keeps telling me this:

Code:
\Users\Howl\Desktop\Flyff Repack (v15) (rev3.1)\Source\SRC\_Common\Item.cpp(160) : error C2039: 'GetHuskyCost' : is not a member of 'CItemBase'
\Users\Howl\Desktop\Flyff Repack (v15) (rev3.1)\Source\SRC\_Common\Mover.cpp(1381) : error C2039: 'GetHuskyCost' : is not a member of 'CItemElem'

Am I doing something wrong here?
 
As I was reading your answer I was already compiling it again with the function being added. It starts to feel like getting into the code is harder than I thought. Once you figured it out it becomes quite easy.

Will update how it goes.

Update 1: Neuz compiled successfully. Now let's get to the World Server :^)
Update 2: World Server also compiled successfully, updated the *.res Files and now trying it out.
Update 3: Chips are successfully added ingame.
HuskyChips - Adding Custom Currencies - RaGEZONE Forums


Now... How the heck do I set the "Husky Chip" cost to an item? Do I have to modify the propItem.txt?

Also: I edited Isruel to the folliwing:

Code:
{
    setting
    {
        AddMenu( MMI_DIALOG );
        AddMenu( MMI_TRADE  );
        SetVenderType(3);
        AddVenderItem3( 0, II_SYS_SYS_SCR_SMELPROT4);
        
        SetImage
        (
        IDS_CHARACTER_INC_000071
        );
        m_szDialog= "MaFl_Isruel.txt";
    }

    SetName
    (
    IDS_CHARACTER_INC_000072
    );

    AddVendorSlot( 0,
    IDS_CHARACTER_INC_000073
    );
}

When I press "Trade" on her, nothing happens.
 
Last edited:
Back