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

Need a little more help [Fixing Script]

Elda Swok

Searching New Project
Joined
Jun 18, 2008
Messages
703
Reaction score
9
Location
Pittsburgh, Pa.
Alright, so I'm trying to add new currency to my server but having a few difficulties. I have edited my Changegold.lua script to the following.

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
	},
	[ITEM_CRACKED_BONE] = {
		from = ITEM_CRYSTAL_COIN, effect = TEXTCOLOR_GREEN
	},
	[ITEM_CHIPPED_TOKEN] = {
		from = ITEM_CRACKED_BONE, effect = TEXTCOLOR_PURPLE
	},
	[ITEM_FLAWLESS_SKULL] = {
		from = ITEM_CHIPPED_TOKEN, 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

It will not change 100 CC into a cracked bone, or 100 cracked bones into a chipped token or 100 chipped tokens into a flawless skull. I'm not sure what I'm missing but it seems right to me.
 
Code:
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 = [COLOR="red"]itemid[/COLOR], effect = TEXTCOLOR_TEAL
	},
	[[COLOR="red"]itemid[/COLOR]] = {
		from = ITEM_CRYSTAL_COIN, to =[COLOR="red"] itemid[/COLOR],effect = TEXTCOLOR_GREEN
	},
	[[COLOR="red"]itemid[/COLOR]] = {
		from = [COLOR="red"]itemid[/COLOR], to = [COLOR="red"]itemid[/COLOR], effect = TEXTCOLOR_PURPLE
	},
	[COLOR="red"][itemid[/COLOR]] = {
		from = [COLOR="red"]itemid,[/COLOR] 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

ok look the the red marked words and edit them to the item id from , and to
 
Back
Top