Ir para conteúdo
Entre para seguir isso  
Tio Gordo

Usando Scarab Coins como dinheiro

Recommended Posts

Tio Gordo    8
Tio Gordo

Bem, tive essa ideia a um tempo e aproveitei o tópico de um colega e assim estarei disponibilizando o método de utilizá-lo como dinheiro. Note, que vamos configurar desde a criação da moeda, que valerá 1kk até às ações de changegold, aquele ato de "comer" o dinheiro com o clique para ele se transformar na moeda seguinte.

 

Antes de tudo, devemos diminuir o peso da scarab coin, pois ela é muito pesada.

 

- Abra a pasta data\items e o arquivo items.xml

<item id="2159" article="a" name="scarab coin"> <attribute key="weight" value="10"/> <attribute key="worth" value="1000000"/></item>

 

OBS.: Não esqueça de colocar o value="10" em weight.

Bem, agora que o peso está arrumado, devemos declarar que a scarab coin agora é dinheiro. Existem dois métodos distintos que dependem do servidor, a única coisa que muda é o arquivo a ser alterado;postarei as duas maneiras:

 

1º método:

~Vá até o diretório data\lib\constant.lua e procure pela tag:

[color=#333333]ITEM_CRYSTAL_COIN = 2160[/color]

Após ela, adicione:

[color=#333333]ITEM_SCARAB_COIN = 2159[/color]

~ Feito isso, vá até data\lib\function.lua e procure essa tag:

function getPlayerMoney(cid)

return((getPlayerItemCount(cid, ITEM_CRYSTAL_COIN)*10000) + (getPlayerItemCount(cid, ITEM_PLATINUM_COIN)*100) + getPlayerItemCount(cid, ITEM_GOLD_COIN))end

Onde está escrito return, adicione essa tag entre os " (( ".

[color=#66CC66]([/color]getPlayerItemCount[color=#66CC66]([/color]cid, ITEM_SCARAB_COIN[color=#66CC66])[/color] [color=#66CC66]*[/color] [color=#CC66CC]1000000[/color][color=#66CC66])[/color] +

~Agora vamos configurar a troca de crystal coin para scarab coin:

Abra o diretório data\actions\ e o arquivo actions.xml; procure por esta tag:

[color=#333333]<action itemid="2160" script="other/changegold.lua"/>[/color]

Adicione esta tag:

[color=#333333]<action itemid="2159" script="other/changegold.lua"/>[/color]

~Feito isso, devemos configurar agora o script, para isso, baste irmos no diretório data\actions\scripts e abrir o arquivo changegold.lua, substitua o código lá escrito por este:

function onUse(cid, item, fromPosition, itemEx, toPosition)

if item.itemid == ITEM_GOLD_COIN and item.type== ITEMCOUNT_MAX then

doChangeTypeItem(item.uid, item.type - item.type)

doPlayerAddItem(cid, ITEM_PLATINUM_COIN, 1)

doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_LIGHTBLUE)

elseif item.itemid == ITEM_PLATINUM_COIN and item.type== ITEMCOUNT_MAX then

doChangeTypeItem(item.uid, item.type - item.type)

doPlayerAddItem(cid, ITEM_CRYSTAL_COIN, 1)

doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_TEAL)

elseif item.itemid == ITEM_CRYSTAL_COIN and item.type== ITEMCOUNT_MAX then

doChangeTypeItem(item.uid, item.type - item.type)

doPlayerAddItem(cid, ITEM_SCARAB_COIN, 1)

doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_GREEN)

elseif item.itemid == ITEM_PLATINUM_COIN and item.type< ITEMCOUNT_MAX then

doChangeTypeItem(item.uid, item.type - 1)

doPlayerAddItem(cid, ITEM_GOLD_COIN, ITEMCOUNT_MAX)

doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_YELLOW)

elseif item.itemid == ITEM_CRYSTAL_COIN then

doChangeTypeItem(item.uid, item.type - 1)

doPlayerAddItem(cid, ITEM_PLATINUM_COIN, ITEMCOUNT_MAX)

doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_LIGHTBLUE)

elseif item.itemid == ITEM_SCARAB_COIN then

doChangeTypeItem(item.uid, item.type - 1)

doPlayerAddItem(cid, ITEM_CRYSTAL_COIN, ITEMCOUNT_MAX)

doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_GREEN)

else

return FALSE

end

return TRUE

end

2º método:

~Vá até o diretório data\global.lua e procure pela tag:

[color=#333333]ITEM_CRYSTAL_COIN = 2160[/color]

Após ela, adicione:

[color=#333333]ITEM_SCARAB_COIN = 2159[/color]

~ Feito isso, vá até data\global.luae procure essa tag:

function getPlayerMoney(cid)

return((getPlayerItemCount(cid, ITEM_CRYSTAL_COIN)*10000) + (getPlayerItemCount(cid, ITEM_PLATINUM_COIN)*100) + getPlayerItemCount(cid, ITEM_GOLD_COIN))end

Onde está escrito return, adicione essa tag entre os " (( ".

[color=#66CC66]([/color]getPlayerItemCount[color=#66CC66]([/color]cid, ITEM_SCARAB_COIN[color=#66CC66])[/color] [color=#66CC66]*[/color] [color=#CC66CC]1000000[/color][color=#66CC66])[/color] +

~Agora vamos configurar a troca de crystal coin para scarab coin:

Abra o diretório data\actions\ e o arquivo actions.xml; procure por esta tag:

[color=#333333]<action itemid="2160" script="other/changegold.lua"/>[/color]

Adicione esta tag:

[color=#333333]<action itemid="2159" script="other/changegold.lua"/>[/color]

~Feito isso, devemos configurar agora o script, para isso, baste irmos no diretório data\actions\scripts e abrir o arquivo changegold.lua, substitua o código lá escrito por este:

function onUse(cid, item, fromPosition, itemEx, toPosition)

if item.itemid == ITEM_GOLD_COIN and item.type== ITEMCOUNT_MAX then

doChangeTypeItem(item.uid, item.type - item.type)

doPlayerAddItem(cid, ITEM_PLATINUM_COIN, 1)

doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_LIGHTBLUE)

elseif item.itemid == ITEM_PLATINUM_COIN and item.type== ITEMCOUNT_MAX then

doChangeTypeItem(item.uid, item.type - item.type)

doPlayerAddItem(cid, ITEM_CRYSTAL_COIN, 1)

doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_TEAL)

elseif item.itemid == ITEM_CRYSTAL_COIN and item.type== ITEMCOUNT_MAX then

doChangeTypeItem(item.uid, item.type - item.type)

doPlayerAddItem(cid, ITEM_SCARAB_COIN, 1)

doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_GREEN)

elseif item.itemid == ITEM_PLATINUM_COIN and item.type< ITEMCOUNT_MAX then

doChangeTypeItem(item.uid, item.type - 1)

doPlayerAddItem(cid, ITEM_GOLD_COIN, ITEMCOUNT_MAX)

doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_YELLOW)

elseif item.itemid == ITEM_CRYSTAL_COIN then

doChangeTypeItem(item.uid, item.type - 1)

doPlayerAddItem(cid, ITEM_PLATINUM_COIN, ITEMCOUNT_MAX)

doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_LIGHTBLUE)

elseif item.itemid == ITEM_SCARAB_COIN then

doChangeTypeItem(item.uid, item.type - 1)

doPlayerAddItem(cid, ITEM_CRYSTAL_COIN, ITEMCOUNT_MAX)

doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_GREEN)

else

return FALSE

end

return TRUE

end

 

Note, que este dinheiro pode ser utilizado com os NPCS, como forma de compra e venda de itens.

 

Créditos para: Ravauvial e para mim por ter adicionado explicações, correção de sintaxe e tradução.

 

Espero ter ajudado alguém,

abraço galerinha, aproveitem e divirtam-se!

Compartilhar este post


Link para o post
vHp    6
vHp

Mais um tutorial exemplar, muito bom, parabéns!

Compartilhar este post


Link para o post
MaXwEllDeN    13
MaXwEllDeN

Muito legal, só faltava dar uma identadinha básica ai não é... :/

Compartilhar este post


Link para o post
Oneshot    24
Oneshot

Bom tutorial, rapaz.

 

Esse clássico script de troca de dinheiro pode ser encurtado, certo?

Compartilhar este post


Link para o post
Criticoo    4
Criticoo
Bom tutorial, rapaz.

 

Esse clássico script de troca de dinheiro pode ser encurtado, certo?

 

sem dúvida disso,meu amigo!

Compartilhar este post


Link para o post
vyctor17    35
vyctor17
Bom tutorial, rapaz.

 

Esse clássico script de troca de dinheiro pode ser encurtado, certo?

 

pode e muito, mais bom tutorial

Compartilhar este post


Link para o post
Miltonhit    4
Miltonhit

bom tuto, mais pode ser bem encurtado, tente usar tabelas, com um for que já resolve seu problema..

Compartilhar este post


Link para o post
kelvin1123    0
kelvin1123

Sobre a tag

function getPlayerMoney(cid)

return((getPlayerItemCount(cid, ITEM_CRYSTAL_COIN)*10000) + (getPlayerItemCount(cid, ITEM_PLATINUM_COIN)*100) + getPlayerItemCount(cid, ITEM_GOLD_COIN))end

 

Não consegui achar function.lua, e meu server n tem global.lua.

Ajuda ?!

Compartilhar este post


Link para o post
Tio Gordo    8
Tio Gordo

@kelvin1123

 

Qual é seu servidor e qual a versão?

Compartilhar este post


Link para o post
Visitante
Este tópico está impedido de receber novos posts.
Entre para seguir isso  
  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×