Postado Dezembro 20, 2022 2 anos Olá pessoal, boa tarde! Encontrei aqui no fórum um script que ao usar o item ele vende o loot que encontra em minhas backpacks, porém ele mostra dessa forma: Eu gostaria que ao invés de mandar 3 mensagens que vendeu essas nightmares blades, viesse da seguinte forma por exemplo: Sold 3x nightmare blade for 105000 gold. Para que não fique spamado de mensagens toda vez que for utilizado o item caso tiver muito loot acumulado Script: - Spoiler local items = {} local sellTable = { [2537] = 4800, [2377] = 480, [2663] = 600, [2472] = 90000, [2475] = 7200, [2519] = 8000, [2497] = 6000, [2523] = 180000, [2494] = 108000, [2400] = 144000, [2491] = 2500, [2421] = 108000, [2646] = 240000, [2477] = 5000, [2656] = 10000, [2498] = 30000, [2647] = 600, [2534] = 15000, [7402] = 15000, [2466] = 20000, [2465] = 240, [2408] = 120000, [2518] = 1800, [2500] = 3000, [2470] = 30000, [2645] = 30000, [2434] = 2000, [2463] = 480, [2536] = 9000, [2387] = 240, [2396] = 1000, [2381] = 450, [2528] = 8000, [2409] = 1800, [2414] = 9000, [2427] = 11000, [2407] = 7200, [2383] = 960, [2392] = 4000, [2488] = 12000, [2525] = 250, [2423] = 1000, [2462] = 4800, [2520] = 30000, [2390] = 180000, [2417] = 500, [2436] = 6000, [5741] = 40000, [2378] = 500, [2487] = 12000, [2476] = 5000, [8891] = 15000, [2195] = 30000, [2391] = 7200, [8889] = 18000, [2432] = 8000, [2431] = 108000, [2492] = 40000, [2515] = 2000, [2430] = 2000, [2393] = 17000, [7419] = 10000, [2522] = 120000, [2514] = 50000, [7418] = 35000 } function get_items_container(cid, uid) local size = getContainerCap(uid) for slot = (size - 1), 0, -1 do local item = getContainerItem(uid, slot) if item.uid > 0 then if sellTable[item.itemid] then table.insert(items, item.itemid) elseif isContainer(item.uid) then get_items_container(cid, item.uid) end end end return items end function sellAllItems(cid, backpack) local items = get_items_container(cid, backpack) if #items <= 0 then return false end for i = 1, #items do local item = items[i] local money = sellTable[item] sell(cid, item, money) end return true end function sell(cid, item, money) doPlayerAddMoney(cid, money) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sold ".. getItemNameById(item) .." for ".. money .." gold.") doPlayerRemoveItem(cid, item, 1) end function onUse(cid, item, frompos, itemEx, topos) items = {} local backpack = getPlayerSlotItem(cid, CONST_SLOT_BACKPACK).uid sellAllItems(cid, backpack) return true end
Postado Dezembro 20, 2022 2 anos Solução local item, count, storage = {}, 0, 0 function onUse(cid, item, frompos, itemEx, topos) item = { [1] = { id = 2537, price = 4800 }, [2] = { id = 2377, price = 480 }, [3] = { id = 2663, price = 600 }, [4] = { id = 2472, price = 90000 }, } storage = 556655123 if getPlayerStorageValue(cid, storage) <= 0 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You want to sell multiple items. Be careful, because the equipment you are using can be sold too, keep them.") addEvent(function() if isPlayer(cid) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Use this item again to sell the items. REMEMBER TO STORE THE EQUIPMENT YOU ARE USING!") end end, 1500) setPlayerStorageValue(cid, storage, 1) else for i = 1, #item, 1 do count = getPlayerItemCount(cid, item[i].id) if count > 0 then doPlayerRemoveItem(cid, item[i].id, count) doPlayerAddMoney(cid, item[i].price * count) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sold " .. count .. "x " .. getItemNameById(item[i].id) .. " for " .. item[i].price .. " gold.") end end setPlayerStorageValue(cid, storage, 0) end return true end
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.