Postado Maio 30, 2017 8 anos Como faço pra por um texto animado laranja em cima do jogador, quando abrir a caixa: Você recebeu 100 crystal coins com 50% de chance. Script da caixa: Spoiler local items = { --[itemid] = {chance, count}, [2160] = {50, 100}, [2158] = {70, 50}, } 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, 27, "You received: "..count.."x "..getItemNameById(_item)..(count > 1 and "s" or "")..".") doRemoveItem(item.uid, 1) end return true end
Postado Junho 9, 2017 8 anos Que tal assim? local items = { --[itemid] = {chance, count}, [2160] = {50, 100}, [2158] = {70, 50}, } 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, 27, "You received: "..count.."x "..getItemNameById(_item)..(count > 1 and "s" or "")..".") doCreatureSay(cid, "Você recebeu 100 crystal coins com 50% de chance", TALKTYPE_ORANGE_1) doRemoveItem(item.uid, 1) end return true end Editado Junho 9, 2017 8 anos por Frenesy (veja o histórico de edições)
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.