jareczekjsp
Member
Nie I can add new Money to my server Golden nuggets? Id 2157 ? I MUST COMPILE ENGINE ?
local newmoney = NEW_MONEY_ID <-- change here
local coins = {
[12416] = {to = 2148},
[2148] = {to = 2152, from = 12416},
[2152] = {to = 2160, from = 2148},
[2160] = {from = 2152, to = NEW_MONEY_ID},
[NEW_MONEY_ID] = {from = 2160},
}
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, to = ITEM_RUBY_COIN, effect = COLOR_TEAL
},
[ITEM_RUBY_COIN] = {
from = ITEM_CRYSTAL_COIN, effect = COLOR_RED
}
}
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
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, to = ITEM_RUBY_COIN, effect = COLOR_TEAL
},
[ITEM_RUBY_COIN] = {
to = ITEM_CRYSTAL_COIN, effect = COLOR_RED
}
}
Not worked :/, originally is this way, i just tried to reproduce same logic:@potinho
try this:
Lua: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, to = ITEM_RUBY_COIN, effect = COLOR_TEAL }, [ITEM_RUBY_COIN] = { to = ITEM_CRYSTAL_COIN, effect = COLOR_RED } }
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
}
}
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
If you can, please ^^I have a script on my server that allows me to convert Crystal Coins to Ruby Coins. In addition, you can transform them into any other item you like, with a colorful visual effect ($$), whenever you want. If interested, I can share the script with you.
If you want, I can send you the script as soon as I get home. It is quite simple and works perfectly.
function onUse(cid, item, frompos, item2, topos)
if item.itemid == 2160 and item.type == 100 then
doRemoveItem(item.uid,item.type)
doPlayerAddItem(cid,11510,1)
doSendAnimatedText(getPlayerPosition(cid), "$$$$", TEXTCOLOR_RED)
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"You turned 1 Ruby Coin into 100 Crystal Coins")
elseif item.itemid == 2160 and item.type < 100 then
doRemoveItem(item.uid,1)
doSendAnimatedText(getPlayerPosition(cid), "$$", 23)
doPlayerAddItem(cid,2152,100)
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"You have turned 1 Crystal Coin into 100 Platium Coins")
end
end
function onUse(cid, item, frompos, item2, topos)
if item.itemid == 2160 and item.type == 100 then
doRemoveItem(item.uid, item.type)
doPlayerAddItem(cid, 38915, 1)
doSendAnimatedText("$$$$", getPlayerPosition(cid), 180)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You turned 100 Crystal Coins into 1 Ruby Coin")
elseif item.itemid == 2160 and item.type < 100 then
doRemoveItem(item.uid, 1)
doSendAnimatedText("$$", getPlayerPosition(cid), 172)
doPlayerAddItem(cid, 2152, 100)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have turned 1 Crystal Coin into 100 Platium Coins")
end
end
don't know if this should work for you...If you can, please ^^
ITEM_RUBY_COIN
?data/lib/000-constant.lua
ITEM_GOLD_COIN = 2148
ITEM_PLATINUM_COIN = 2152
ITEM_CRYSTAL_COIN = 2160
ITEM_RUBY_COIN = 2157
<!-- Change gold -->
<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="2148" event="script" value="other/changegold.lua"/>
If I use what you suggested, is it possible for the NPC or some NPCs to allow purchasing directly using Ruby Coins, without having to turn them into Crystal Coins first? On my server, every time I need to convert to Crystal Coins to buy something, it becomes a nuisance.What for? Why use another script for something as simple.
Keep the things simple and organized.
@potinho Did you even defined value for that constITEM_RUBY_COIN
?
data/lib/000-constant.lua
Lua:ITEM_GOLD_COIN = 2148 ITEM_PLATINUM_COIN = 2152 ITEM_CRYSTAL_COIN = 2160 ITEM_RUBY_COIN = 2157
Edit:
Seems like you already found that out
But for others it was about:
XML:<!-- Change gold --> <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="2148" event="script" value="other/changegold.lua"/>
you also need the "worth" attribute on items.xmlIf I use what you suggested, is it possible for the NPC or some NPCs to allow purchasing directly using Ruby Coins, without having to turn them into Crystal Coins first? On my server, every time I need to convert to Crystal Coins to buy something, it becomes a nuisance.