SOLVED:
ITEMCOUNT_MAX didn't exist in global.lua, all I had to do was to define it.
Thanks to Colandus for pointing it out.
Distro:
OTServ 0.6.4 STABLE
Problem:
When I use 1 coin, it disappears.
When I use 100 coins, nothing happens.
No errors in console.
Scripts:
changegold.lua
actions.xml
global.lua
ITEMCOUNT_MAX didn't exist in global.lua, all I had to do was to define it.
Thanks to Colandus for pointing it out.
Distro:
OTServ 0.6.4 STABLE
Problem:
When I use 1 coin, it disappears.
When I use 100 coins, nothing happens.
No errors in console.
Scripts:
changegold.lua
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, 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
actions.xml
Code:
<action itemid="2148" script="custom/changegold.lua"/>
<action itemid="2152" script="custom/changegold.lua"/>
<action itemid="2160" script="custom/changegold.lua"/>
global.lua
Code:
ITEM_GOLD_COIN = 2148
ITEM_PLATINUM_COIN = 2152
ITEM_CRYSTAL_COIN = 2160
Last edited: