Foi mal pela demora, fiquei sem internet quase o dia todo.
Em data/XML/channels.xml, você deverá criar canais relativos a cada opção de troca, seguindo o modelo:
<channel id="ID_do_canal" name="Nome_do_canal">
<vocation id="10"/>
</channel>
Exemplos:
<channel id="22" name="20 Devoted Token (Tier 1-2)">
<vocation id="10"/>
</channel>
<channel id="23" name="70 Mighty Token (Tier 1-3)">
<vocation id="10"/>
</channel>
Depois, na mesma pasta, vocations.xml:
<vocation id="10" name="Held Machine" description="a pokemon trainer" needpremium="0" gaincap="0" gainhp="15" gainmana="0" gainhpticks="2" gainhpamount="3" gainmanaticks="0" gainmanaamount="0" manamultiplier="1.1" attackspeed="-1" soulmax="251" gainsoulticks="-1" fromvoc="1">
<formula meleeDamage="0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
<skill fist="1.0" club="1.0" sword="1.0" axe="1.0" distance="1.0" shielding="1.0" fishing="3.0" experience="1.0"/>
</vocation>
data/actions/scripts, código da máquina de troca:
function onUse(cid)
doPlayerSetVocation(cid, 10)
openChannelDialog(cid)
return true
end
data/creaturescripts/scripts:
local trade_options = {
--[channel_id] = {token = {token_itemid, amount}, results = {held_itemid, held_itemid, held_itemid, ...}},
}
function onJoinChannel(cid, channelId, users, isTv)
local option = trade_options[channelId]
if not option then
return false
end
doPlayerSetVocation(cid, 1)
if doPlayerRemoveItem(cid, option.token[1], option.token[2]) then
local result = option.results[math.random(#option.results)]
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "In trade of "..option.token[2].."x "..getItemNameById(option.token[1])..", you received: "..getItemNameById(result)..".")
doPlayerAddItem(cid, result, 1)
else
doPlayerSendTextMessage(cid, 27, "You do not have "..option.token[2].."x "..getItemNameById(option.token[1])..".")
end
return false
end
Configure na tabela trade_options as opções de troca, seguindo o modelo:
[ID_do_canal] = {token = {ID_do_token, quantidade}, results = {IDs_dos_helds}},
Tag:
<event type="joinchannel" name="Held_Machine" event="script" value="nome_do_arquivo.lua"/>
Em login.lua:
registerCreatureEvent(cid, "Held_Machine")