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

Problem with changing cc to gold ingots

Status
Not open for further replies.

Krzkru

New Member
Joined
Jan 10, 2013
Messages
89
Reaction score
1
Location
Poland
Hello, i got this error when i run server:
Clipboard02.jpg

what am i doing wrong?

my changegold:

PHP:
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 ~= 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

actions.xml:
PHP:
	<action itemid="2148;2152;2160;9971" event="script" value="other/changegold.lua"/>
 
Try this:
Code:
local coins = {
	[ITEM_GOLD_COIN] = {
		to = ITEM_PLATINUM_COIN, effect = COLOR_YELLOW
	},
	[ITEM_PLATINUM_COIN] = {
		from = ITEM_GOLD_COIN, to = ITEM_CRYSTAL_COIN, effect = COLOR_LIGHTBLUE
	},
	[ITEM_CRYSTAL_COIN] = {
		from = ITEM_PLATINUM_COIN, effect = COLOR_TEAL,  to = ITEM_GOLD_INGOT, effect = TEXTCOLOR_TEAL
	},
	[ITEM_GOLD_IGNOT] = {
		from = ITEM_CRYSTAL_COIN, effect = COLOR_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 ~= 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
 
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 = 2157, effect = TEXTCOLOR_RED
	},
    [2157] = {
		from = ITEM_CRYSTAL_COIN, to = 9971, effect = TEXTCOLOR_TEAL
	},
	[9971] = {
		from = 2157, effect = TEXTCOLOR_LIGHTGREEN
	}
}
 
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)

Then go to data/actions/actions.xml and make and find changegold.lua
Replace those lines with:
XML:
<action itemid="2148" script="other/changegold.lua" />
<action itemid="2152" script="other/changegold.lua" />
<action itemid="2160" script="other/changegold.lua" />
<action itemid="2157" script="other/changegold.lua" />
<action itemid="9971" script="other/changegold.lua" />
 
#Up
Clipboard03.jpg

Thanks for trying but still doesnt work...

#Edit
Done like that and it works:

PHP:
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_LIGHTGREEN
	}
}
 
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

actions.xml:
PHP:
<action itemid="2148;2152;2160;9971" event="script" value="other/changegold.lua"/>
 
Last edited:
Status
Not open for further replies.
Back
Top