Ir para conteúdo

Featured Replies

Postado
Spoiler

local items = {
    --[chance] = {id, count}, 
    [80] = {2160, 50},
    [60] = {2160, 100},
    [50] = {2160, 500},
    [40] = {2160, 1000},
    [30] = {2160, 2500},
    [10] = {2160, 5000}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
local t, c, chk = {}, 0, false
for _, v in pairs(items) do 
table.insert(t, _)
end
table.sort(t)
for _, v in pairs(t) do
if math.random(1,100) < v then
c = v
break
end
end
local i,slots = items[c], 0
if items[c] then
local s = getAllContainerFree(getPlayerSlotItem(cid, CONST_SLOT_BACKPACK).uid)
if not isItemStackable(i[1]) then
slots = i[2]
else
slots = math.ceil(i[2]/100)
end
if getPlayerFreeCap(cid) <= i[2]*getItemWeightById(i[1],1) or s < slots then
chk = true
end
if chk == true and isInArray({2148, 2152, 2160}, tonumber(i[1])) then
local dp = i[1] == tonumber(2160) and (i[2]*10000) or i[1] == 2152 and (i[2]*100) or i[2]
m = " Due to reward's weight, it was sent to your bank account."
doPlayerSetBalance(cid, getPlayerBalance(cid) + dp)
doRemoveItem(item.uid,1)
else
m = " You reward is too heavy or need more spaces in your backpack. Take out some items and try again."
end
if chk == false then
if not isItemStackable(i[1]) then
for index = 1, i[2] do
doPlayerAddItem(cid, i[1], 1)
end
else
doPlayerAddItem(cid, i[1], i[2])
end
doRemoveItem(item.uid, 1)
end
if isInArray({2152, 2160}, tonumber(i[1])) then
text = i[1] == 2152 and (i[2]/10).."K" or (i[1] == 2160 and i[2] < 100) and (i[2]*10).." K" or i[1] == 2160 and (i[2]/100).." KK"
else
text = i[2] .. " " .. getItemNameById(i[1]) .. "" .. (i[2] > 1 and "s" or "") 
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You received: ".. text .."." .. (chk == true and m or ""))
end
return true
end

function getContainerSlotsFree(container) -- by vodka
return getContainerCap(container)-getContainerSize(container)
end

function getAllContainerFree(container) -- by vodka
local containers,soma = {},0
for i = 0, getContainerSize(container)-1 do
local item = getContainerItem(container, i)
if isContainer(item.uid) then
table.insert(containers, item.uid)
end
end
for _, check in pairs(containers) do
soma = soma + getContainerSlotsFree(check)
end
return (soma + getContainerSlotsFree(container))
end

 

 

Editado por Dwarfer (veja o histórico de edições)

Contato:

 

  • Respostas 6
  • Visualizações 472
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

Postado
  • Autor
Em 31/08/2017 em 18:17, Dwarfer disse:
  Mostrar conteúdo oculto


local items = {
    --[chance] = {id, count}, 
    [80] = {2160, 50},
    [60] = {2160, 100},
    [50] = {2160, 500},
    [40] = {2160, 1000},
    [30] = {2160, 2500},
    [10] = {2160, 5000}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
local t, c, chk = {}, 0, false
for _, v in pairs(items) do 
table.insert(t, _)
end
table.sort(t)
for _, v in pairs(t) do
if math.random(1,100) < v then
c = v
break
end
end
local i,slots = items[c], 0
if items[c] then
local s = getAllContainerFree(getPlayerSlotItem(cid, CONST_SLOT_BACKPACK).uid)
if not isItemStackable(i[1]) then
slots = i[2]
else
slots = math.ceil(i[2]/100)
end
if getPlayerFreeCap(cid) <= i[2]*getItemWeightById(i[1],1) or s < slots then
chk = true
end
if chk == true and isInArray({2148, 2152, 2160}, tonumber(i[1])) then
local dp = i[1] == tonumber(2160) and (i[2]*10000) or i[1] == 2152 and (i[2]*100) or i[2]
m = " Due to reward's weight, it was sent to your bank account."
doPlayerSetBalance(cid, getPlayerBalance(cid) + dp)
doRemoveItem(item.uid,1)
else
m = " You reward is too heavy or need more spaces in your backpack. Take out some items and try again."
end
if chk == false then
if not isItemStackable(i[1]) then
for index = 1, i[2] do
doPlayerAddItem(cid, i[1], 1)
end
else
doPlayerAddItem(cid, i[1], i[2])
end
doRemoveItem(item.uid, 1)
end
if isInArray({2152, 2160}, tonumber(i[1])) then
text = i[1] == 2152 and (i[2]/10).."K" or (i[1] == 2160 and i[2] < 100) and (i[2]*10).." K" or i[1] == 2160 and (i[2]/100).." KK"
else
text = i[2] .. " " .. getItemNameById(i[1]) .. "" .. (i[2] > 1 and "s" or "") 
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You received: ".. text .."." .. (chk == true and m or ""))
end
return true
end

function getContainerSlotsFree(container) -- by vodka
return getContainerCap(container)-getContainerSize(container)
end

function getAllContainerFree(container) -- by vodka
local containers,soma = {},0
for i = 0, getContainerSize(container)-1 do
local item = getContainerItem(container, i)
if isContainer(item.uid) then
table.insert(containers, item.uid)
end
end
for _, check in pairs(containers) do
soma = soma + getContainerSlotsFree(check)
end
return (soma + getContainerSlotsFree(container))
end

 

 

 

Aew, show de bola!!! Obrigado novamente!!

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