Ir para conteúdo

Featured Replies

Postado

.Qual servidor ou website você utiliza como base? 

8.60

 

Buenas,

 

Estava tentando fazer uma implementação em um script aqui, mas a parte da aleatoriedade me confundiu todo, gostaria de saber se alguém aí poderia me ajudar a fazer o seguinte:

 

Esse script aqui funciona perfeitamente, eu abro o item, e ele sorteia 1 dos 7 itens possíveis pra vir.

Só que, eu gostaria de adicionar para que se o player já pegou o item X, assim que ele abrir uma nova vez, ele não pegará um item repetido

 

Aqui está o code

 

 

local items = {

{itemId = 11331, count = 1, chance = 10}, -- ITEM, QUANTIDADE, CHANCE
{itemId = 11330, count = 1, chance = 10},
{itemId = 11332, count = 1, chance = 10},

{itemId = 11337, count = 1, chance = 10},
{itemId = 11338, count = 1, chance = 10},
{itemId = 11319, count = 1, chance = 10},
{itemId = 11321, count = 1, chance = 10},


}

function onUse(cid, item, frompos, item2, topos)

local config = {
	pos = getCreaturePosition(cid), -- posição do player
	exhaustionSeconds = 60, -- exausted em segundos
	storageUse = 43531, -- storage usado.

}

if(exhaustion.check(cid, config.storageUse)) then
if (exhaustion.get(cid, config.storageUse) >= 60) then
doPlayerSendCancel(cid, "Você somente poderá abrir uma nova Rare Box em " .. math.floor(exhaustion.get(cid, config.storageUse) / 60 + 1) .." minutos.") 
end
if (exhaustion.get(cid, config.storageUse) <= 60) then
doPlayerSendCancel(cid, "Você precisa esperar " .. exhaustion.get(cid, config.storageUse).." segundos.")
end
return true
end

    local totalChance, randomTable, randomNumber = 0, {}, 0
	
	addEvent(doPlayerSendTextMessage, 1*1000, cid, 27, "Sorteando...")
    addEvent(doPlayerSendTextMessage, 2*1000, cid, 27, "Sorteando...")
	addEvent(doPlayerSendTextMessage, 3*1000, cid, 27, "Sorteando...")
	addEvent(doPlayerSendTextMessage, 4*1000, cid, 27, "Sorteando...")
	addEvent(doPlayerSendTextMessage, 5*1000, cid, 27, "Sorteando...")
	addEvent(doSendAnimatedText, 1*1000, config.pos, "[5]", 180)
    addEvent(doSendAnimatedText, 2*1000, config.pos, "[4]", 180)
	addEvent(doSendAnimatedText, 3*1000, config.pos, "[3]", 180)
	addEvent(doSendAnimatedText, 4*1000, config.pos, "[2]", 180)
	addEvent(doSendAnimatedText, 5*1000, config.pos, "[1]", 180)
	addEvent(doSendAnimatedText, 6*1000, config.pos, "Pronto!", 180)
	
    for _, itemInfo in pairs (items) do
            randomTable[itemInfo.itemId] = {min = totalChance + 1, max = itemInfo.chance, count = itemInfo.count or 1}
            totalChance = totalChance + itemInfo.chance
    end
    
    randomNumber = math.random(1, totalChance)
    
    for itemId, itemInfo in pairs (randomTable) do
            local min, max = itemInfo.min, itemInfo.min + itemInfo.max
            if randomNumber >= min and randomNumber <= max then
                    local newItem = addEvent(doPlayerAddItem, 6*1000, cid, itemId, itemInfo.count, false)
                    if not newItem then return doPlayerSendCancel(cid, "Você não possui espaço suficiente para receber o item.") end
                    doRemoveItem(item.uid, 1)
					exhaustion.set(cid, config.storageUse, config.exhaustionSeconds)
                    local iInfo = getItemInfo(itemId)	
                    addEvent(doPlayerSendTextMessage, 6*1000, cid, 27, "Item encontrado : (" ..iInfo.name.. ")!")
                    break
            end
    end

return true
end

 

Postado
local items = {

{itemId = 11331, count = 1, chance = 10}, -- ITEM, QUANTIDADE, CHANCE
{itemId = 11330, count = 1, chance = 10},
{itemId = 11332, count = 1, chance = 10},

{itemId = 11337, count = 1, chance = 10},
{itemId = 11338, count = 1, chance = 10},
{itemId = 11319, count = 1, chance = 10},
{itemId = 11321, count = 1, chance = 10},


}

function onUse(cid, item, frompos, item2, topos)

local config = {
	pos = getCreaturePosition(cid), -- posição do player
	exhaustionSeconds = 60, -- exausted em segundos
	storageUse = 43531, -- storage usado.

}
  
if getPlayerStorageValue(cid, 144125) < 1 then
if(exhaustion.check(cid, config.storageUse)) then
if (exhaustion.get(cid, config.storageUse) >= 60) then
doPlayerSendCancel(cid, "Você somente poderá abrir uma nova Rare Box em " .. math.floor(exhaustion.get(cid, config.storageUse) / 60 + 1) .." minutos.") 
end
if (exhaustion.get(cid, config.storageUse) <= 60) then
doPlayerSendCancel(cid, "Você precisa esperar " .. exhaustion.get(cid, config.storageUse).." segundos.")
end
end
return true
end

    local totalChance, randomTable, randomNumber = 0, {}, 0
	
	addEvent(doPlayerSendTextMessage, 1*1000, cid, 27, "Sorteando...")
    addEvent(doPlayerSendTextMessage, 2*1000, cid, 27, "Sorteando...")
	addEvent(doPlayerSendTextMessage, 3*1000, cid, 27, "Sorteando...")
	addEvent(doPlayerSendTextMessage, 4*1000, cid, 27, "Sorteando...")
	addEvent(doPlayerSendTextMessage, 5*1000, cid, 27, "Sorteando...")
	addEvent(doSendAnimatedText, 1*1000, config.pos, "[5]", 180)
    addEvent(doSendAnimatedText, 2*1000, config.pos, "[4]", 180)
	addEvent(doSendAnimatedText, 3*1000, config.pos, "[3]", 180)
	addEvent(doSendAnimatedText, 4*1000, config.pos, "[2]", 180)
	addEvent(doSendAnimatedText, 5*1000, config.pos, "[1]", 180)
	addEvent(doSendAnimatedText, 6*1000, config.pos, "Pronto!", 180)
	
    for _, itemInfo in pairs (items) do
            randomTable[itemInfo.itemId] = {min = totalChance + 1, max = itemInfo.chance, count = itemInfo.count or 1}
            totalChance = totalChance + itemInfo.chance
    end
    
    randomNumber = math.random(1, totalChance)
    
    for itemId, itemInfo in pairs (randomTable) do
            local min, max = itemInfo.min, itemInfo.min + itemInfo.max
            if randomNumber >= min and randomNumber <= max then
                    local newItem = addEvent(doPlayerAddItem, 6*1000, cid, itemId, itemInfo.count, false)
                    if not newItem then return doPlayerSendCancel(cid, "Você não possui espaço suficiente para receber o item.") end
                    doRemoveItem(item.uid, 1)
					exhaustion.set(cid, config.storageUse, config.exhaustionSeconds)
                    local iInfo = getItemInfo(itemId)	
                    addEvent(doPlayerSendTextMessage, 6*1000, cid, 27, "Item encontrado : (" ..iInfo.name.. ")!")
      				setPlayerStorageValue(cid, 144125, 1)
                    break
            end
    end

return true
end

 

VlVKQKC.png&key=d5c17620ae9567a1f898dd7a

 

 

 

  • 532144234_Logo_NTO_BLOOD_Finish_HIM_By_Antonio_Luckas(3).png.fd58d1af125a7e82ccdd751637e9ca93.png

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.

Conteúdo Similar

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo