• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Solved [TFS 0.3.2] NPC acknowledging custom currencies as CHANGE? +Rep [SOLVED]

Guitar Freak

_LüA_n☺b_
Joined
Dec 27, 2008
Messages
831
Reaction score
13
Location
Caracas, Venezuela
EDIT: Everything is solved now, thanks Rudolf! And Mikuch from before ;)

<----Solved---->

Hey there guys, I have a custom currency working fine on my server being 1 "gold token" = 100cc each, which is 1 million each.

It works correctly on my "buying talkactions" like !buyaol, but I cant get it to work with NPCs.

So Im wondering how is it possible to make it so the new NPCSystem (the one with "trade/offer" window) accepts the new currency normally like if they were crystal coins or anything else. When I dont have the custom currency on me it shows the items in grey (not available), when I have it on me it shows them in white (available), but still when I try to buy them it tells me I dont have enough money.

OR, if easier, to make an npc (with the trade system ofc) that only accepts the custom currency.

Any ideas?

+Rep of course.

Cheers~
 
Last edited:
not sure but check in
data/lib/function.lua

PHP:
function getPlayerMoney(cid)
        return ((getPlayerItemCount(cid, ITEM_CRYSTAL_COIN) * 10000) + (getPlayerItemCount(cid, ITEM_PLATINUM_COIN) * 100) + getPlayerItemCount(cid, ITEM_GOLD_COIN))
end
 
not sure but check in
data/lib/function.lua

PHP:
function getPlayerMoney(cid)
        return ((getPlayerItemCount(cid, ITEM_CRYSTAL_COIN) * 10000) + (getPlayerItemCount(cid, ITEM_PLATINUM_COIN) * 100) + getPlayerItemCount(cid, ITEM_GOLD_COIN))
end

Yep it was there and it worked perfectly mate, +Rep for ya. Would've never guessed it would be there.

Thanks!

PS: I have a last question, this one doesnt really matters that much I can live without it ;) But would be good if anybody knew how to do it.

Im currently testing 2 custom currencies on the server, they are both working and thanks to Mikuch they are now both accepted normally from NPCs, but, when I buy something with the highest currency (1 whatever token = 100 golden tokens = 100 mill), the "rest" of the money the NPC gives me back comes in crystal coins/plats/gold, instead of whatever tokens/golden tokens and crystal coins/plats/gold, so if I buy something that costs like 20k with the highest currency, I get the backpack/floor flooded with packs of 100 cc :p

So is it possible that the NPCs recognize the new currencies also for the "change" he gives me back after buying an item?

Cheers~
 
PS: I have a last question, this one doesnt really matters that much I can live without it ;) But would be good if anybody knew how to do it.

Im currently testing 2 custom currencies on the server, they are both working and thanks to Mikuch they are now both accepted normally from NPCs, but, when I buy something with the highest currency (1 whatever token = 100 golden tokens = 100 mill), the "rest" of the money the NPC gives me back comes in crystal coins/plats/gold, instead of whatever tokens/golden tokens and crystal coins/plats/gold, so if I buy something that costs like 20k with the highest currency, I get the backpack/floor flooded with packs of 100 cc :p

So is it possible that the NPCs recognize the new currencies also for the "change" he gives me back after buying an item?

Bump on that one~ I still cant figure out how to make that work properly >.<

Anyone?
 
Bumpek!

Im still in the need for this one:

Im currently testing 2 custom currencies on the server, they are both working and thanks to Mikuch they are now both accepted normally from NPCs, but, when I buy something with the highest currency (1 whatever token = 100 golden tokens = 100 mill), the "rest" (change) of the money the NPC gives me back comes in crystal coins/plats/gold, instead of whatever tokens/golden tokens and crystal coins/plats/gold, so if I buy something that costs like 20k with the highest currency being 1 = 100 million, I will get like 9283012389 gp change in cc/plats/gold, therefore Ill get the backpack+floor flooded with packs of 100 cc, and debug :p

So is it possible that the NPCs recognize the new currencies also for the "change" he gives me back after buying an item?

Ive played around with many scripts and editing everything I can but I cant make it work, maybe Im looking on the wrong places but someone told me this can only be done by editing the sources however Im not any good at it, but I know some people here are ;)

Anyone knows how to do this? Ill definitely +Rep and love you forever if you make this work, lol. :thumbup:

Cheers!
 
Bumpek!

Im still in the need for this one:

Im currently testing 2 custom currencies on the server, they are both working and thanks to Mikuch they are now both accepted normally from NPCs, but, when I buy something with the highest currency (1 whatever token = 100 golden tokens = 100 mill), the "rest" (change) of the money the NPC gives me back comes in crystal coins/plats/gold, instead of whatever tokens/golden tokens and crystal coins/plats/gold, so if I buy something that costs like 20k with the highest currency being 1 = 100 million, I will get like 9283012389 gp change in cc/plats/gold, therefore Ill get the backpack+floor flooded with packs of 100 cc, and debug :p

So is it possible that the NPCs recognize the new currencies also for the "change" he gives me back after buying an item?

Ive played around with many scripts and editing everything I can but I cant make it work, maybe Im looking on the wrong places but someone told me this can only be done by editing the sources however Im not any good at it, but I know some people here are ;)

Anyone knows how to do this? Ill definitely +Rep and love you forever if you make this work, lol. :thumbup:

Cheers!

Bring
Up
My
Pony? :confused:
 
Come on it's been over a month since I first asked this on my first thread, really nobody knows about this?

I guess you would have to register those currencies at source-code, because NPC is using hard-coded function to give you the *amount* of money back.

Code:
void Game::addMoney(Cylinder* cylinder, int32_t money, uint32_t flags /*= 0*/)
{
	int32_t crys = money / 10000;
	money -= crys * 10000;
	int32_t plat = money / 100;
	money -= plat * 100;
	int32_t gold = money;

	if(crys != 0)
	{
		do
		{
			Item* remaindItem = Item::CreateItem(ITEM_COINS_CRYSTAL, std::min(100, crys));

			ReturnValue ret = internalAddItem(NULL, cylinder, remaindItem, INDEX_WHEREEVER, flags);
			if(ret != RET_NOERROR)
				internalAddItem(NULL, cylinder->getTile(), remaindItem, INDEX_WHEREEVER, FLAG_NOLIMIT);

			crys -= std::min(100, crys);
		}
		while(crys > 0);
	}

	if(plat != 0)
	{
		Item* remaindItem = Item::CreateItem(ITEM_COINS_PLATINUM, plat);

		ReturnValue ret = internalAddItem(NULL, cylinder, remaindItem, INDEX_WHEREEVER, flags);
		if(ret != RET_NOERROR)
			internalAddItem(NULL, cylinder->getTile(), remaindItem, INDEX_WHEREEVER, FLAG_NOLIMIT);
	}

	if(gold != 0)
	{
		Item* remaindItem = Item::CreateItem(ITEM_COINS_GOLD, gold);

		ReturnValue ret = internalAddItem(NULL, cylinder, remaindItem, INDEX_WHEREEVER, flags);
		if(ret != RET_NOERROR)
			internalAddItem(NULL, cylinder->getTile(), remaindItem, INDEX_WHEREEVER, FLAG_NOLIMIT);
	}
}
 
I guess you would have to register those currencies at source-code, because NPC is using hard-coded function to give you the *amount* of money back.

Code:
void Game::addMoney(Cylinder* cylinder, int32_t money, uint32_t flags /*= 0*/)
{
	int32_t crys = money / 10000;
	money -= crys * 10000;
	int32_t plat = money / 100;
	money -= plat * 100;
	int32_t gold = money;

	if(crys != 0)
	{
		do
		{
			Item* remaindItem = Item::CreateItem(ITEM_COINS_CRYSTAL, std::min(100, crys));

			ReturnValue ret = internalAddItem(NULL, cylinder, remaindItem, INDEX_WHEREEVER, flags);
			if(ret != RET_NOERROR)
				internalAddItem(NULL, cylinder->getTile(), remaindItem, INDEX_WHEREEVER, FLAG_NOLIMIT);

			crys -= std::min(100, crys);
		}
		while(crys > 0);
	}

	if(plat != 0)
	{
		Item* remaindItem = Item::CreateItem(ITEM_COINS_PLATINUM, plat);

		ReturnValue ret = internalAddItem(NULL, cylinder, remaindItem, INDEX_WHEREEVER, flags);
		if(ret != RET_NOERROR)
			internalAddItem(NULL, cylinder->getTile(), remaindItem, INDEX_WHEREEVER, FLAG_NOLIMIT);
	}

	if(gold != 0)
	{
		Item* remaindItem = Item::CreateItem(ITEM_COINS_GOLD, gold);

		ReturnValue ret = internalAddItem(NULL, cylinder, remaindItem, INDEX_WHEREEVER, flags);
		if(ret != RET_NOERROR)
			internalAddItem(NULL, cylinder->getTile(), remaindItem, INDEX_WHEREEVER, FLAG_NOLIMIT);
	}
}

Exactly what I wanted to know, I looked on sources before but I was looking on npc.cpp and similar, dont know why I didnt think of game.cpp.. duh U_u

Thanks a lot mate, they're all working perfectly now :thumbup:

+Repped of course!
 
Back
Top