Ir para conteúdo
  • Cadastre-se

(Resolvido)[TALK] -=[TFS]=- 0.4 v8.60 Queria que vendesse tudo de uma vez no comando !sellall e 1 de cada no comando !sell


Ir para solução Resolvido por MatteusDeli,

Posts Recomendados

local sellTable = {
[2498] = 40000,
[2475] = 6000,
[2497] = 9000,
[2491] = 5000,
[2462] = 4000,
[2663] = 500,
[2458] = 35,
[2459] = 30,
[2645] = 400000,
[2195] = 40000,
[2646] = 100000,
[2472] = 100000,
[2492] = 60000,
[2494] = 90000,
[2466] = 30000,
[2487] = 20000,
[2476] = 5000,
[2656] = 15000,
[2500] = 2500,
[2463] = 400,
[2465] = 200,
[2464] = 100,
[2470] = 80000,
[2488] = 15000,
[2477] = 6000,
[2647] = 500,
[2487] = 100,
[2514] = 80000,
[2520] = 40000,
[2523] = 150000,
[2522] = 100000,
[2534] = 25000,
[2536] = 8000,
[2537] = 4000,
[2519] = 5000,
[2528] = 4000,
[2515] = 200,
[2518] = 1500,
[2525] = 100,
[2390] = 150000,
[2408] = 100000,
[2400] = 90000,
[2393] = 10000,
[2407] = 6000,
[2396] = 4000,
[2392] = 3000,
[2409] = 1500,
[2383] = 800,
[2377] = 400,
[2413] = 70,
[2406] = 30,
[2376] = 25,
[2414] = 10000,
[2431] = 90000,
[2427] = 7500,
[2432] = 10000,
[2430] = 2000,
[2387] = 200,
[2381] = 200,
[2378] = 100,
[2388] = 20,
[2391] = 6000,
[2421] = 90000,
[2436] = 1000,
[2434] = 2000,
[2423] = 200,
[2417] = 60,
[2398] = 30,
}

function on_search_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
			doPlayerAddMoney(cid, sellTable[item.itemid])
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sold ".. getItemNameById(item.itemid) .." for ".. sellTable[item.itemid] .." gold.")
			doRemoveItem(item.uid, 1)
		elseif isContainer(item.uid) then
			on_search_container(cid, item.uid)
		end
	end
end
end

function onSay(cid, words, param, channel)
on_search_container(cid, getPlayerSlotItem(cid, CONST_SLOT_BACKPACK).uid)
return true
end

 

Vende um item de cada no sell e vende tudo de uma vez no sellall...

Ficando assim.

<talkaction words="!sell;sellall" event="script" value="sellall.lua"/>

 

91-thais.png

Link para o post
Compartilhar em outros sites
  • Solução

@Muvuka Boa noite.

 

local items = {}

local sellTable = {
  [2498] = 40000,
  [2475] = 6000,
  [2497] = 9000,
  [2491] = 5000,
  [2462] = 4000,
  [2663] = 500,
  [2458] = 35,
  [2459] = 30,
  [2645] = 400000,
  [2195] = 40000,
  [2646] = 100000,
  [2472] = 100000,
  [2492] = 60000,
  [2494] = 90000,
  [2466] = 30000,
  [2487] = 20000,
  [2476] = 5000,
  [2656] = 15000,
  [2500] = 2500,
  [2463] = 400,
  [2465] = 200,
  [2464] = 100,
  [2470] = 80000,
  [2488] = 15000,
  [2477] = 6000,
  [2647] = 500,
  [2487] = 100,
  [2514] = 80000,
  [2520] = 40000,
  [2523] = 150000,
  [2522] = 100000,
  [2534] = 25000,
  [2536] = 8000,
  [2537] = 4000,
  [2519] = 5000,
  [2528] = 4000,
  [2515] = 200,
  [2518] = 1500,
  [2525] = 100,
  [2390] = 150000,
  [2408] = 100000,
  [2400] = 90000,
  [2393] = 10000,
  [2407] = 6000,
  [2396] = 4000,
  [2392] = 3000,
  [2409] = 1500,
  [2383] = 800,
  [2377] = 400,
  [2413] = 70,
  [2406] = 30,
  [2376] = 25,
  [2414] = 10000,
  [2431] = 90000,
  [2427] = 7500,
  [2432] = 10000,
  [2430] = 2000,
  [2387] = 200,
  [2381] = 200,
  [2378] = 100,
  [2388] = 20,
  [2391] = 6000,
  [2421] = 90000,
  [2436] = 1000,
  [2434] = 2000,
  [2423] = 200,
  [2417] = 60,
  [2398] = 30,
}

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 onSay(cid, words, param, channel)

  items = {}
  local backpack = getPlayerSlotItem(cid, CONST_SLOT_BACKPACK).uid

  if (words == "!sellall") then
    sellAllItems(cid, backpack)
    return true
  end

  if (words == "!sell") then
    if (param == nil) then
      return false
    end

    sellItem(cid, param, backpack)
    return true
  end

  return true
end

function sellItem(cid, item, backpack)
  local items = get_items_container(cid, backpack)

  if #items <= 0 then
    return false
  end

  local itemId = items[1]
  local money = sellTable[itemId]

  local itemName = getItemNameById(itemId)

  if string.lower(itemName) ~= string.lower(item) then
    return false
  end

  sell(cid, itemId, money)
  return true
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

 

Link para o post
Compartilhar em outros sites

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

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo