• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Action Adding a new coin

Rodo

New Member
Joined
Oct 23, 2007
Messages
575
Solutions
1
Reaction score
3
Location
Mexico
With this system you will be able to transform 100 crystal coins to a new coin without making new actions, only adding variables at lib, also you can use it to buy with it as a normal coin :)




Example:
___________________
crystal_coins_500k.gif
---->
z2jcvfrx2153.png

___________________
z2jcvfrx2153.png
---->
crystal_coins_500k.gif

___________________​


1. lib/000-constant.lua:


After:

Lua:
ITEM_CRYSTAL_COIN = 2160


Add:

Lua:
ITEM_SUPER_COIN = ID-OF-YOUR-NEW-COIN




2. data/actions/scripts/other/changegold.lua



Reeplace your script with this


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_SUPER_COIN, effect = TEXTCOLOR_TEAL
	},
	[ITEM_SUPER_COIN] = {
		from = ITEM_CRYSTAL_COIN, effect = TEXTCOLOR_WHITE
	}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if(getPlayerFlagValue(cid, PLAYERFLAG_CANNOTPICKUPITEM)) then
		return false
	end

	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
end


3. actions/actions.xml:


PHP:
	<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"/>
	<action itemid="XXXX" event="script" value="other/changegold.lua"/>



4. Items/items.xml


Add this tag to the coin

Lua:
        <attribute key="worth" value="1000000" />


That's it :peace:
 
Last edited:
you should also add to your "tutorial" that you need to add a worth of the item in items.xml..
 
Fixed an issue, changed the worth from 100000 to 1000000
 
Lua:
After ITEM_SUPER_COIN in lib/000-constants.lua add
ITEM_ULTRA_COIN = ID OF THE ULTRA COIN
2. data/actions/scripts/other/changegold.lua
after
[ITEM_SUPER_COIN]  = {
                from = ITEM_CRYSTAL_COIN, to = ITEM_ULTRA_COIN effect = TEXTCOLOR_WHITE
        }
add:
[ITEM_ULTRA_COIN = {
                from = ITEM_SUPER_COIN, effect = TEXTCOLOR_WHITE
        }
At Actions.xml add after the supercoin change XXXX to your ultra coin.
PHP:
<action itemid="XXXX" event="script"
value="other/changegold.lua"/>

In Items.xml
just add the attribute tag.
So under the ultracoin you have to add this
<attribute key="worth" value="100000000"  />
It's really easy really.

Rep++ if this helped :) Btw @OP Great guide :D. Rep++ to you
 
You don't need it, just reeplaze your script with mine. I can't understand why is so hard to read the instructions :(
 
Lol I was drunk and I wrote in items.xml something like 100000*100000 = 1000000000000 <LOOL> Now works, thanks :p
 
I know this is rather old, but no point in opening a new thread! How can I get this to work on Mystic Spirit; there's no 000-constant.lua for Mystic Spirit. (at least the version I'm working on)
 
Back
Top