• 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!

Currency Exchange System Explained

Ravauvial

Member
Joined
Mar 19, 2009
Messages
186
Reaction score
8
Location
Stanwood, Washington, USA
This is the entire script as in TFS 8.54 Mystic Spirit.

changegold.lua Explained:

Now in data/actions/scripts/other/changegold.lua


Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)

 <!-- 100 gold to 1 platinum -->
	if item.itemid == ITEM_GOLD_COIN and item.type == ITEMCOUNT_MAX then  <!-- This says check gold if max 100 -->
		doChangeTypeItem(item.uid, item.type - item.type) <!-- then change it to up note: 1 -->
		doPlayerAddItem(cid, ITEM_PLATINUM_COIN, 1) <!-- platinum coin = 1 -->
		doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_PLATINUMBLUE) <!-- print to screen in blue $$$ -->

 <!-- 100 platinum to 1 crystal -->
	elseif item.itemid == ITEM_PLATINUM_COIN and item.type == ITEMCOUNT_MAX then <!-- This says check platinum if max 100 -->
		doChangeTypeItem(item.uid, item.type - item.type) <!-- then change it to -->
		doPlayerAddItem(cid, ITEM_CRYSTAL_COIN, 1) <!-- crystal coin = 1 -->
		doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_TEAL) <!-- print to screen in teal $$$ -->
 <!-- Add new code 1 here -->

 <!-- This changes 1 platinum to 100 gold -->
	elseif item.itemid == ITEM_PLATINUM_COIN and item.type < ITEMCOUNT_MAX then <!-- This says check platinum if max 1 -->
		doChangeTypeItem(item.uid, item.type - 1) <!-- then change it to down note: -1 -->
		doPlayerAddItem(cid, ITEM_GOLD_COIN, ITEMCOUNT_MAX) <!-- This add 100 to player gold -->
		doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_YELLOW) <!-- print to screen in yellow $$$ -->

 <!-- This changes 1 crystal to 100 platinum -->
	elseif item.itemid == ITEM_CRYSTAL_COIN then <!-- This says check crystal if max 1 -->
		doChangeTypeItem(item.uid, item.type - 1) <!-- then change it to down note: -1 -->
		doPlayerAddItem(cid, ITEM_PLATINUM_COIN, ITEMCOUNT_MAX) <!-- This add 100 to player platinum -->
		doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_PLATINUMBLUE) <!-- print to screen in blue $$$ -->
 <!-- Add new code 2 here -->
	else
		return FALSE
	end
	return TRUE
end

so to add a new coin Scarab you need to add this:

Code 1
Code:
	elseif item.itemid == ITEM_CRYSTAL_COIN and item.type == ITEMCOUNT_MAX then
		doChangeTypeItem(item.uid, item.type - item.type)
		doPlayerAddItem(cid, ITEM_SCARAB_COIN, 1)
		doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_GREEN)

Code 2
Code:
	elseif item.itemid == ITEM_SCARAB_COIN then
		doChangeTypeItem(item.uid, item.type - 1)
		doPlayerAddItem(cid, ITEM_CRYSTAL_COIN, ITEMCOUNT_MAX)
		doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_TEAL)

You also need to change or add this to these files:

Go into data/global.lua
Near the bottom you will see this

Code:
ITEM_GOLD_COIN = 2148
ITEM_PLATINUM_COIN = 2152
ITEM_CRYSTAL_COIN = 2160

Now after the crystal coin add this:

Code:
ITEM_SCARAB_COIN = 2159

Now in data/actions/action.xml
find this:

Code:
	<!-- Change gold -->
	<action itemid="2148" event="script" value="other/changegold.lua"/>
	<action itemid="2152" event="script" value="other/changegold.lua"/>
	<action itemid="2160" event="script" value="other/changegold.lua"/>

and add one of these:

Code:
	<action itemid="2159" script="other/changegold.lua"/> <!-- Scarab Coin -->

Last but important to make NPC's see your new Money
Now in data/items/item.xml
you search for this:

Code:
	<item id="2159" article="a" name="scarab coin">
		<attribute key="weight" value="100"/>
	</item>

and add this:
Code:
	<item id="2159" article="a" name="scarab coin">
		<attribute key="weight" value="100"/>
this line --->	<attribute key="worth" value="100000000" />
	</item>

That is it should work great.

The items you can use are:

Christmas Token = 6527 or you can change it to Ivory Coin in Item.xml
Scarab Coin = 2159
Gold Nugget = 2157
Gold Ingot = 9971

I hope this helps everyone with the Currency exchange system
 
Just an FYI for anyone curious!

IF YOUR DISTRO DOESN'T HAVE A GLOBAL.LUA

Go to Data/LIB/000-CONSTANT

and thats where you will add

Code:
 ITEM_SCARAB_COIN = 2159


+rep if it helped you!


__SUPOMGLOL
 
Last edited:
Other than my server not having a global.lua, this worked wonderfully! And I hope other people use this post too, its so simple and works fine! +rep'd!


thanks!


__SUPOMGLOL
 
Also, I notice the OP is from Washington as well! I feel nice supporting WASHINGTON OT's! 8) Long Live Seattle!
 

Similar threads

Back
Top