Ir para conteúdo

(Resolvido)-=[TFS]=- 0.4 8.60 [SCRIPT] alavanca puxa e ganha cada item de uma alavanca diferente mais alavanca tem mesmo id

Featured Replies

Postado
local config = {
    [60000] = {items = {{6542, 1}}, coin = 11192, price = 100},
    [60001] = {items = {{6543, 1}}, coin = 11192, price = 100},
    [60002] = {items = {{6544, 1}}, coin = 11192, price = 100},
    [60003] = {items = {{6545, 1}}, coin = 11192, price = 100},
    [60004] = {items = {{6544, 1}, coin = 11192, price = 100},
    [60005] = {items = {{2328, 1}, coin = 11192, price = 100},
    [60006] = {items = {{6541, 1}, coin = 11192, price = 100},
    [60007] = {items = {{8300, 1}, coin = 11192, price = 100}
}

local function concatstr(table)
    local str = ''
    for a, b in pairs(table) do
        str = str .. (#table > 1 and (#table - 1 > a and b .. ', ' or #table - 1 == a and b .. ' and ' or #table == a and b) or #table == 1 and b)
    end
    return str
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local v = config[item.uid]
    if getPlayerItemCount(cid, v.coin) < v.price then
        return doPlayerSendCancel(cid, "Sorry, you need " .. v.price .. " " .. (getItemNameById(v.coin) .. (v.price > 1 and 's' or '')) .. ".")
    end
    local cap = 0
    for a, b in ipairs(v.items) do
        cap = cap + getItemWeightById(b[1]) * b[2]
    end
    if getPlayerFreeCap(cid) < cap then
        return doPlayerSendCancel(cid, "You need " .. cap .. " capacity to obtain " .. (#v.items > 1 and 'those' or 'this') .. " item.")
    end
    local item_name = {}
    for _, item in ipairs(v.items) do
        table.insert(item_name, (item[2] > 1 and item[2] .. ' ' or '') .. getItemNameById(item[1]))
        if isItemStackable(item[1]) or item[2] == 1 then
            doPlayerAddItem(cid, item[1], item[2])
        else
            for i = 1, item[2] do
                doPlayerAddItem(cid, item[1], 1)
            end
        end
    end
    doPlayerRemoveItem(cid, v.coin, v.price)
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You bought a " .. concatstr(item_name) .. " for " .. v.price .. " " .. (getItemNameById(v.coin) .. (v.price > 1 and 's' or '')) .. ".")
    doSendMagicEffect(getThingPosition(cid), CONST_ME_STUN)
    doPlayerSave(cid)
    return true
end

 

COMO MONTA ESSE SCRIPT EU SEI QUE É NA PASTA  ACTION MAIS EU NAO SEI COMO UMA VEZ MONTEI E PEGO AGORA PERDI A MENTE COMPLEMTAMENTE QUEM PODER AJUDAR EU AGRADEÇO.

Resolvido por Aragllov

Ir para solução

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo