
lisandra
Membro
-
Registro em
-
Última visita
Histórico de Curtidas
-
lisandra deu reputação a Wend II em Dado da Sorteitemid -> ID do item.
chance -> Chance, em porcentagem, de sair o item.
count -> Quantidade do item.
local items = { --[itemid] = {chance, count}, [7391] = {25, 1}, [7423] = {30, 1}, [2447] = {20, 1}, [8850] = {15, 1}, [7424] = {10, 1}, } function onUse(cid, item) local number = math.random(1, 100) local _item = 0 for itemid, chance in pairs(items) do if _item == 0 then _item = itemid else local new_chance = (chance[1] - number) > 0 and chance[1] - number or number - chance[1] local old_chance = (items[_item][1] - number) > 0 and items[_item][1] - number or number - items[_item][1] if new_chance < old_chance then _item = itemid end end end if _item ~= 0 then local count = items[_item][2] if not isItemStackable(_item) then if count > 1 then for i = 1, count do doPlayerAddItem(cid, _item, 1) end else doPlayerAddItem(cid, _item, 1) end else doPlayerAddItem(cid, _item, count) end doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You received: "..count.."x "..getItemNameById(_item)..(count > 1 and "s" or "")..".") doRemoveItem(item.uid, 1) end return true end