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

How to make 100 Gold Ingots to 1 Gold Nugget?

Jeppezz

Map/Script Beginner
Joined
Mar 1, 2008
Messages
19
Reaction score
0
Location
Sweden
I need some help with this script so I can "exchange" 100 Gold Ingots to 1 Gold Nugget,

I tried myself but it didn't work.. Got plenty of errors in console like "expected ( near line 12" and so on,

Here is the script

ID of the Gold Nugget : 2157

What should I add?

changegolde.lua -

Lua:
local ITEM_GOLD_INGOT = 9971
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_YELLOW
	}
}

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 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) then
		doChangeTypeItem(item.uid, item.type - 1)
		doPlayerAddItem(cid, coin.from, ITEMCOUNT_MAX)
		doSendAnimatedText(fromPosition, "$$$", coins[coin.from].effect)
	end
	return true
end

I know that I have to add in actions.xml and items.xml maybe? ,

Just need help with lua :p
Please help, thanks.
 
try this changegold.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_GOLD_INGOT] = {
from = ITEM_CRYSTAL_COIN, to = ITEM_GOLD_INGOTCOIN, effect = TEXTCOLOR_LIGHTBLUE
},
[ITEM_CRYSTAL_COIN] = {
from = ITEM_PLATINUM_COIN, effect = TEXTCOLOR_TEAL
}
}

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

and in actions add


<action itemid="2157" event="script" value="changegold.lua"/>
 
Code:
local ITEM_GOLD_INGOT, ITEM_GOLD_NUGGET = 9971, 2157
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, to = ITEM_GOLD_NUGGET, effect = TEXTCOLOR_YELLOW
	},
	[ITEM_GOLD_NUGGET] = {
		from = ITEM_GOLD_INGOT, effect = TEXTCOLOR_YELLOW
	}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	local coin = coins[item.itemid]
	if(getPlayerFlagValue(cid, PLAYERFLAG_CANNOTPICKUPITEM) or not coin) then
		return false
	elseif(coin.to 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) then
		doChangeTypeItem(item.uid, item.type - 1)
		doPlayerAddItem(cid, coin.from, ITEMCOUNT_MAX)
		doSendAnimatedText(fromPosition, "$$$", coins[coin.from].effect)
	end
	return true
end
 
Code:
local ITEM_GOLD_INGOT, ITEM_GOLD_NUGGET = 9971, 2157
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, to = ITEM_GOLD_NUGGET, effect = TEXTCOLOR_YELLOW
	},
	[ITEM_GOLD_NUGGET] = {
		from = ITEM_GOLD_INGOT, effect = TEXTCOLOR_YELLOW
	}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	local coin = coins[item.itemid]
	if(getPlayerFlagValue(cid, PLAYERFLAG_CANNOTPICKUPITEM) or not coin) then
		return false
	elseif(coin.to 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) then
		doChangeTypeItem(item.uid, item.type - 1)
		doPlayerAddItem(cid, coin.from, ITEMCOUNT_MAX)
		doSendAnimatedText(fromPosition, "$$$", coins[coin.from].effect)
	end
	return true
end

Worked, Thanks.
 
items.xml, add worth attribute to it.
Code:
	<item id="2157" article="a" name="gold nugget" plural="gold nuggets">
		<attribute key="weight" value="10"/>
[B][COLOR="Red"]		<attribute key="worth" value="1000000"/>[/COLOR][/B]
	</item>
 
items.xml, add worth attribute to it.
Code:
	<item id="2157" article="a" name="gold nugget" plural="gold nuggets">
		<attribute key="weight" value="10"/>
[B][COLOR="Red"]		<attribute key="worth" value="1000000"/>[/COLOR][/B]
	</item>

ooo cool i didnt know there was a worth attribute thanks
 
Back
Top