• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

[SUPPORT] Adding a higher currency

Grehy

Killroy
Joined
Nov 21, 2008
Messages
2,631
Reaction score
33
Location
United States
Hello! I'm trying to make it that so when you have 100 crystal coins, you can turn them into a gold ingot. Right now, when I use 100 crystal coins, I get the little message over my head, but the coins just dissapear. Heres the error I get in console;

[02/05/2009 02:51:11] Lua Script Error: [Action Interface]
[02/05/2009 02:51:11] data/actions/scripts/other/changegold.lua:onUse

[02/05/2009 02:51:11] luaDoPlayerAddItem(). Item not found

Here is my changegold.lua file;

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.itemid == ITEM_GOLD_COIN and item.type == ITEMCOUNT_MAX then
		doChangeTypeItem(item.uid, item.type - item.type)
		doPlayerAddItem(cid, ITEM_PLATINUM_COIN, 1)
		doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_LIGHTBLUE)
		
	elseif item.itemid == ITEM_PLATINUM_COIN and item.type == ITEMCOUNT_MAX then
		doChangeTypeItem(item.uid, item.type - item.type)
		doPlayerAddItem(cid, ITEM_CRYSTAL_COIN, 1)
		doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_TEAL)
		
	elseif item.itemid == ITEM_PLATINUM_COIN and item.type < ITEMCOUNT_MAX then
		doChangeTypeItem(item.uid, item.type - 1)
		doPlayerAddItem(cid, ITEM_GOLD_COIN, ITEMCOUNT_MAX)
		doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_YELLOW)
		
	elseif item.itemid == ITEM_CRYSTAL_COIN and item.type < ITEMCOUNT_MAX then 
		doChangeTypeItem(item.uid, item.type - 1)
		doPlayerAddItem(cid, ITEM_PLATINUM_COIN, ITEMCOUNT_MAX)
		doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_LIGHTBLUE)
		
	elseif item.itemid == ITEM_CRYSTAL_COIN and item.type == ITEMCOUNT_MAX then
		doChangeTypeItem(item.uid, item.type - item.type)
		doPlayerAddItem(cid, ITEM_GOLD_INGOT, 1)
		doSendAnimatedText(fromPosition, "BIG MONEY", TEXTCOLOR_LIGHTBLUE)
		
    elseif item.itemid == ITEM_GOLD_INGOT and item.type < ITEMCOUNT_MAX then
		doChangeTypeItem(item.uid, item.type - item.type)
		doPlayerAddItem(cid, ITEM_CRYSTAL_COIN, ITEMCOUNT_MAX)
		doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_LIGHTBLUE)
		
	elseif item.itemid == ITEM_GOLD_INGOT and item.type == ITEMCOUNT_MAX then
		doChangeTypeItem(item.uid, item.type - item.type)
		doPlayerAddItem(cid, ITEM_CRYSTAL_COIN, 1000)
		doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_LIGHTBLUE)
		
		
	else
		return FALSE
	end
	return TRUE
end

Any help would be GREATLY appreciated, you can expect some rep. Thanks!


P.S, using TFS 3 beta
 
It was a little wrong so here it is fixed:

PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.itemid == ITEM_GOLD_COIN and item.type == ITEMCOUNT_MAX then
		doChangeTypeItem(item.uid, item.type - item.type)
		doPlayerAddItem(cid, ITEM_PLATINUM_COIN, 1)
		doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_LIGHTBLUE)
		
	elseif item.itemid == ITEM_PLATINUM_COIN and item.type == ITEMCOUNT_MAX then
		doChangeTypeItem(item.uid, item.type - item.type)
		doPlayerAddItem(cid, ITEM_CRYSTAL_COIN, 1)
		doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_TEAL)
		
	elseif item.itemid == ITEM_PLATINUM_COIN and item.type < ITEMCOUNT_MAX then
		doChangeTypeItem(item.uid, item.type - 1)
		doPlayerAddItem(cid, ITEM_GOLD_COIN, ITEMCOUNT_MAX)
		doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_YELLOW)
		
	elseif item.itemid == ITEM_CRYSTAL_COIN and item.type < ITEMCOUNT_MAX then 
		doChangeTypeItem(item.uid, item.type - 1)
		doPlayerAddItem(cid, ITEM_PLATINUM_COIN, ITEMCOUNT_MAX)
		doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_LIGHTBLUE)
		
	elseif item.itemid == ITEM_CRYSTAL_COIN and item.type == ITEMCOUNT_MAX then
		doChangeTypeItem(item.uid, item.type - item.type)
		doPlayerAddItem(cid, ITEM_GOLD_INGOT, 1)
		doSendAnimatedText(fromPosition, "BIG MONEY", TEXTCOLOR_LIGHTBLUE)
		
    elseif item.itemid == ITEM_GOLD_INGOT and item.type < ITEMCOUNT_MAX then
		doChangeTypeItem(item.uid, item.type - item.type)
		doPlayerAddItem(cid, ITEM_CRYSTAL_COIN, 1)
		doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_LIGHTBLUE)
		
	elseif item.itemid == ITEM_GOLD_INGOT and item.type == ITEMCOUNT_MAX then
		doChangeTypeItem(item.uid, item.type - item.type)
		doPlayerAddItem(cid, ITEM_CRYSTAL_COIN, ITEMCOUNT_MAX)
		doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_LIGHTBLUE)
		
		
	else
		return FALSE
	end
	return TRUE
end

And also remember to define ITEM_GOLD_INGOT in constants.lua or just change it to integer!
 
PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.itemid == ITEM_GOLD_COIN and item.type == ITEMCOUNT_MAX then
        doChangeTypeItem(item.uid, item.type - item.type)
        doPlayerAddItem(cid, ITEM_PLATINUM_COIN, 1)
        doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_LIGHTBLUE)
        
    elseif item.itemid == ITEM_PLATINUM_COIN and item.type == ITEMCOUNT_MAX then
        doChangeTypeItem(item.uid, item.type - item.type)
        doPlayerAddItem(cid, ITEM_CRYSTAL_COIN, 1)
        doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_TEAL)
        
    elseif item.itemid == ITEM_PLATINUM_COIN and item.type < ITEMCOUNT_MAX then
        doChangeTypeItem(item.uid, item.type - 1)
        doPlayerAddItem(cid, ITEM_GOLD_COIN, ITEMCOUNT_MAX)
        doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_YELLOW)
        
    elseif item.itemid == ITEM_CRYSTAL_COIN and item.type < ITEMCOUNT_MAX then 
        doChangeTypeItem(item.uid, item.type - 1)
        doPlayerAddItem(cid, ITEM_PLATINUM_COIN, ITEMCOUNT_MAX)
        doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_LIGHTBLUE)
        
    elseif item.itemid == ITEM_CRYSTAL_COIN and item.type == ITEMCOUNT_MAX then
        doChangeTypeItem(item.uid, item.type - item.type)
        doPlayerAddItem(cid, ITEM_GOLD_INGOT, 1)
        doSendAnimatedText(fromPosition, "BIG MONEY", TEXTCOLOR_LIGHTBLUE)
        
    elseif item.itemid == ITEM_GOLD_INGOT and item.type < ITEMCOUNT_MAX then
        doChangeTypeItem(item.uid, item.type - item.type)
        doPlayerAddItem(cid, ITEM_CRYSTAL_COIN, ITEMCOUNT_MAX)
        doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_LIGHTBLUE)
        
    elseif item.itemid == ITEM_GOLD_INGOT and item.type == ITEMCOUNT_MAX then
        doChangeTypeItem(item.uid, item.type - item.type)
        doPlayerAddItem(cid, ITEM_CRYSTAL_COIN, ITEMCOUNT_MAX)
        doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_LIGHTBLUE)
        
        
    else
        return FALSE
    end
    return TRUE
end

REMEMBER YOU NEED TO DEFINE ITEM_GOLD_INGOT IN CONSTANTS.LUA!
 
Code:
ITEM_GOLD_COIN = 2148
ITEM_PLATINUM_COIN = 2152
ITEM_CRYSTAL_COIN = 2160
ITEM_GOLD_INGOT = 9971


I did, gold ingots still don't change back to crystal.
 
This should work

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.itemid == ITEM_GOLD_COIN and item.type == ITEMCOUNT_MAX then
		doChangeTypeItem(item.uid, item.type - item.type)
		doPlayerAddItem(cid, ITEM_PLATINUM_COIN, 1)
		doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_GREY)
	elseif item.itemid == ITEM_PLATINUM_COIN and item.type == ITEMCOUNT_MAX then
		doChangeTypeItem(item.uid, item.type - item.type)
		doPlayerAddItem(cid, ITEM_CRYSTAL_COIN, 1)
		doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_TEAL)
	elseif item.itemid == ITEM_PLATINUM_COIN and item.type < ITEMCOUNT_MAX then
		doChangeTypeItem(item.uid, item.type - 1)
		doPlayerAddItem(cid, ITEM_GOLD_COIN, ITEMCOUNT_MAX)
		doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_YELLOW)
	elseif item.itemid == ITEM_CRYSTAL_COIN and item.type < ITEMCOUNT_MAX then
		doChangeTypeItem(item.uid, item.type - 1)
		doPlayerAddItem(cid, ITEM_PLATINUM_COIN, ITEMCOUNT_MAX)
		doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_GREY)
	elseif item.itemid == ITEM_CRYSTAL_COIN and item.type == ITEMCOUNT_MAX then
		doChangeTypeItem(item.uid, item.type - item.type)
		doPlayerAddItem(cid, ITEM_GOLD_INGOT, 1)
		doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_YELLOW)
	elseif item.itemid == ITEM_GOLD_INGOT and item.type == ITEMCOUNT_MAX or item.type < ITEMCOUNT_MAX then
		doChangeTypeItem(item.uid, item.type - 1)
		doPlayerAddItem(cid, ITEM_CRYSTAL_COIN, ITEMCOUNT_MAX)
		doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_TEAL)
	else
		return FALSE
	end
	return TRUE
end
 
Here you have configurable one, which will be included in TFS:
LUA:
local coins = {
	[ITEM_GOLD_COIN] = {to = ITEM_PLATINUM_COIN, effect = TEXTCOLOR_YELLOW},
	[ITEM_PLATINUM_COIN] = {from = ITEM_GOLD_COIN, to = ITEM_CRYSTAL_COIN, effect = TEXTCOLOR_LIGHTBLUE},
	[ITEM_CRYSTAL_COIN] = {from = ITEM_PLATINUM_COIN, effect = TEXTCOLOR_TEAL}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	local coin = coins[item.itemid]
	if(not coin) then
		return FALSE
	end

	if(coin.to ~= nil and item.type == ITEMCOUNT_MAX) then
		doChangeTypeItem(item.uid, item.type - item.type)
		doPlayerAddItem(cid, coin.to, 1)
		doSendAnimatedText(fromPosition, "$$$", coins[coin.to].effect)
	elseif(coin.from ~= nil) then
		doChangeTypeItem(item.uid, item.type - 1)
		doPlayerAddItem(cid, coin.from, ITEMCOUNT_MAX)
		doSendAnimatedText(fromPosition, "$$$", coins[coin.from].effect)
	end
	return TRUE

So for your INGOT money, you'll need to use this set on coins:
LUA:
local coins = {
        [ITEM_GOLD_COIN] = {to = ITEM_PLATINUM_COIN, effect = TEXTCOLOR_YELLOW},
        [ITEM_PLATINUM_COIN] = {from = ITEM_GOLD_COIN, to = ITEM_CRYSTAL_COIN, effect = TEXTCOLOR_LIGHTBLUE},
        [ITEM_CRYSTAL_COIN] = {from = ITEM_PLATINUM_COIN, to = ITEM_GOLD_INGOT, effect = TEXTCOLOR_TEAL},
	[ITEM_GOLD_INGOT] = {from = ITEM_CRYSTAL_COIN, effect = TEXTCOLOR_LIGHTBLUE}
}

(Just replace it in previous script)
 
Tried the scripts posted in the 2 posts before me, gold ingots still will not change back into crystal, but crystals > gold ingots will work.


I appreciate all the help so far!
 
Tried the scripts posted in the 2 posts before me, gold ingots still will not change back into crystal, but crystals > gold ingots will work.


I appreciate all the help so far!

Ive tryed same thing and for some reason gold ingots dont work.
You can use Item 6527 rename it what ever you want it works fine.

Just a idea.
 
Did you add them into your actions.xml file? You need to declare the gold ingot item id in it.
 
Did you add them into your actions.xml file? You need to declare the gold ingot item id in it.

I can't believe I forgot that, thanks!


Problem solved, thanks everyone! [I will start "rep'ing" ;) ]


Is there anything else I need to do? NPC's won't accept the ingots as money, what else do I need to change?
 
You need to add them into items.xml for example this one (Crystal Coin)
<item id="2160" article="a" name="crystal coin" plural="crystal coins">
<attribute key="weight" value="10"/>
<attribute key="worth" value="10000"/>
</item>
You must modify the bold line
 
Back
Top