MA

{PEDIDO} Comprar items em baús com 2 Tipos de moeda.

Por Magraozinho, 20 de abr. de 2016 em Scripts

script
suporte
action
5
1.5k
MagraozinhoM
20 de abril de 2016 às 00:44

Ola galera, eu tenho um script para comprar item com uma certa moeda de troca, porém queria saber como edito o script para aceitar 2 moedas de troca.. POR EXEMPLO: compro tal item clicando no bau com crystal coin dentro da BP, quero modificar o script para comprar com crystal coin ou scarab coin.. versão do ot 8.6         tfs 0.4

 

 

 

local coin = 2160 -- sua moeda vip
local lever = {
[6016] = {1000,2158},
[6017] = {1000,2154},
[6018] = {1000,2156},
}
local arrows = {8303,8302,8301} -- coloque o ID aqui
function onUse(cid,item,fromPosition,itemEx,toPosition)
                                  if doPlayerRemoveItem(cid,coin,lever[item.actionid][1]) == FALSE then
                                  return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Você não tem dinheiro suficiente (1000000 gold coins = 1000k = 1000 crystal coins).")
                                  end
                                                                doPlayerAddItem(cid,lever[item.actionid][2], isItemStackable(lever[item.actionid][2]) and 1 or 1)
                                                                doSendAnimatedText(toPosition,'Comprado!', TEXTCOLOR_BLUE)
                                                                doSendMagicEffect(toPosition,12)
                                return true
end

zipter98Z
20 de abril de 2016 às 15:52
local config = {    coin = {2160, xxx},              --Moeda VIP, scarab coin ID.    lever = {        [6016] = {{1000, scarab_coin_price}, 2158},        [6017] = {{1000, scarab_coin_price}, 2154},        [6018] = {{1000, scarab_coin_price}, 2156},    }}function onUse(cid,item,fromPosition,itemEx,toPosition)    if not doPlayerRemoveItem(cid, config.coin[1], config.lever[item.actionid][1][1]) then        if not doPlayerRemoveItem(cid, config.coin[2], config.lever[item.actionid][1][2]) then            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Você não tem dinheiro suficiente.")            return true        end    end        doPlayerAddItem(cid, config.lever[item.actionid][2], 1)    doSendAnimatedText(toPosition, 'Comprado!', TEXTCOLOR_BLUE)    doSendMagicEffect(toPosition, 12)    return trueend

 

miguel223M
20 de abril de 2016 às 16:28

function onUse(cid, item)

 

local t = {

{actionala = 29182, gainitemid = {12123, 4343, 1212}, lostitemid = {2160, 2152}},

{actionala = 29182, gainitemid = {12123, 4343, 1212}, lostitemid = {2160, 2152}},

{actionala = 29182, gainitemid = {12123, 4343, 1212}, lostitemid = {2160, 2152}}

}

 

for _, push in ipairs(t) do

 

if item.actionid == push.actionala then

 

if doPlayerRemoveItem(cid, push.lostitemid[1], 1) == TRUE then

 

for i = 1, #push.gainitemid then

doPlayerAddItem(cid, push.gainitemid, 1)

doPlayerSendCancel(cid, "You bought the items.")

doSendMagicEffect(getPlayerPosition(cid), 12)

end

 

elseif doPlayerRemoveItem(cid, push.lostitemid[2], 1) == TRUE then

 

for i = 1, #push.gainitemid then

doPlayerAddItem(cid, push.gainitemid, 1)

doPlayerSendCancel(cid, "You bought the items.")

doSendMagicEffect(getPlayerPosition(cid), 12)

end

 

else

doPlayerSendCancel(cid, "You dont have the request items.")

doSendMagicEffect(getPlayerPosition(cid), 2)

end

 

end

 

end

 

return true

end

Editado Abril 20 por miguel223

miguel223M
20 de abril de 2016 às 16:31

Ficou faltando o i entre [] após push.gainitemid, não tá aparecendo, então acrescenta ai no script.

MagraozinhoM
20 de abril de 2016 às 22:30

Muito obrigado aos 2, os 2 scripts me ajudaram de formas diferentes... REP pros 2..  

 

TÓPICO FECHADO

Editado Abril 20 por Magraozinho