TA

Bau de recompensa

Por Taiger, 06 de abr. de 2020 em Scripts

8
2.6k
TaigerT
06 de abril de 2020 às 16:29

Estou com um problema nesse sistema de bau de recompensas, ele esta dando só os dois primeiros itens da tabela, não importa quantos itens eu adiciono nela, só ganha os 2 primeiros, alguém poderia me ajudar?

 

-- Time Chest by Limos
local config = {
    exhausttime = 86400, -- time in seconds
    exhauststorage = 2301,
    level = 25 -- minimum level to open the chest
}
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
 
local rewarditems = {
    --[[[25] = {
        tilllevel = 50,
        {id = 2152, chance = 5, count = math.random(1, 50)}, -- start with the lowest chances
        {id = 17214, chance = 10, count = 1},
        {id = 17215, chance = 15, count = 1},
        {id = 2160, chance = 70, count = math.random(1, 50)}
    },
    [50] = {
        tilllevel = 100,
        {id = 7730, chance = 5, count = 1},
        {id = 2466, chance = 10, count = 1},
        {id = 2497, chance = 15, count = 1},
        {id = 2152, chance = 70, count = math.random(1, 20)}
    },
    [100] = {
        tilllevel = 200,
        {id = 2492, chance = 5, count = 1},
        {id = 2498, chance = 10, count = 1},
        {id = 2195, chance = 15, count = 1},
        {id = 2152, chance = 70, count = math.random(20, 50)}
    },]]--
    [80] = {
        tilllevel = 10000,
        {id = 17214, chance = 50, count = 1},
		{id = 2392, chance = 100, count = 1},
        {id = 16116, chance = 55, count = 1},
		
    }
}
 
if(getPlayerLevel(cid) < config.level) then        
	doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)        
	doPlayerSendCancel(cid, "You need to be level "..config.level.." to open the chest.")        
	return true    
end  
  
if getPlayerStorageValue(cid, config.exhauststorage) and getPlayerStorageValue(cid, config.exhauststorage) - os.time(t) > 0 then        
	local time = getPlayerStorageValue(cid, config.exhauststorage) - os.time(t)        
	local hours, minutes, seconds = math.floor (time / 3600), math.floor ((time - ((math.floor (time / 3600)) * 3600))/ 60), time - ((math.floor (time/60)) * 60)       
	if time >= 3600 then            
		text = hours.." "..(hours == 1 and "hour" or "hours")..", "..minutes.." "..(minutes == 1 and "minute" or "minutes").." and "..seconds.." "..(seconds == 1 and "second" or "seconds")        
		elseif time >= 120 then            text = minutes.." "..(minutes == 1 and "minute" or "minutes").." and "..seconds.." "..(seconds == 1 and "second" or "seconds")        
	else            
		text = seconds.." "..(seconds == 1 and "second" or "seconds")        
	end        
		doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)        
		doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "It is empty. You need to wait "..text.." before you can get a reward again.")        
	return true    
 end   
 
 local chance = math.random(1,100)    
 for v, x in pairs(rewarditems) do        
	if(getPlayerLevel(cid) >= v and getPlayerLevel(cid) < x.tilllevel) then            
		level = v			
		till = x.tilllevel        
	end    
 end    
	for a, b in pairs(rewarditems[level]) do	
	if b == till then return true end        
		if(chance < b.chance) then            
		local info = getItemInfo(b.id)            
			if(b.count > 1) then   				
				text = b.count .. " " .. info.plural            
			else				
				text = info.article .. " " .. info.name            
			end             
	local item = doCreateItemEx(b.id, b.count)            
	if(doPlayerAddItemEx(cid, item, false) ~= RETURNVALUE_NOERROR) then                
		doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)                
		text = "You have found a reward. It is to heavy or you have not enough space."            
		else                text = "You have found " .. text .. "."                
		exhaustion.set(cid, config.exhauststorage, config.exhausttime)            
	end            
	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, text)            
	return true        
 else            
 chance = chance - b.chance        
		end    
	end
 end

 

Yan OliveiraY
07 de abril de 2020 às 13:03

Só para entender, você quer um baú que dê recompensa uma vez por dia e a recompensa varia de acordo com o level do jogador? A quantidade também deve variar ou é fixa?

TaigerT
07 de abril de 2020 às 13:24
22 minutos atrás, Yan18 disse:

Só para entender, você quer um baú que dê recompensa uma vez por dia e a recompensa varia de acordo com o level do jogador? A quantidade também deve variar ou é fixa?

Isso, essa parte que voce mencionou ja funciona, mas nao importa a variedade de itens que eu coloque, o sistema so da os dois primeiros itens da tabela.

Eu estava tentando adptar o script que voce me ajudou la da box para esse do bau, mas nao estou conseguindo pq esse do bau tb da itens em quantidade, ex: pokeballs etc. Seria tipo o sistema da box mas com tempo para uso, level e tb dava itens em quantidade.

Editado Abril 7 por Taiger

Yan OliveiraY
07 de abril de 2020 às 16:05
2 horas atrás, Taiger disse:

Isso, essa parte que voce mencionou ja funciona, mas nao importa a variedade de itens que eu coloque, o sistema so da os dois primeiros itens da tabela.

Eu estava tentando adptar o script que voce me ajudou la da box para esse do bau, mas nao estou conseguindo pq esse do bau tb da itens em quantidade, ex: pokeballs etc. Seria tipo o sistema da box mas com tempo para uso, level e tb dava itens em quantidade.

Entendi, você quer que a recompensa também seja um item aleatório de acordo com a tabela, igual no outro script que fiz para você?

TaigerT
07 de abril de 2020 às 16:15
9 minutos atrás, Yan18 disse:

Entendi, você quer que a recompensa também seja um item aleatório de acordo com a tabela, igual no outro script que fiz para você?

sim, mas com chance configurável para cada item ou tabela entende?

Yan OliveiraY
07 de abril de 2020 às 23:09
6 horas atrás, Taiger disse:

sim, mas com chance configurável para cada item ou tabela entende?

Sim entendi.

 

Bom, eu fiz outro script:

local itens_grupo1 = {
[1] = {id = 2152},
[2] = {id = 2160},
[3] = {id = 17214, quantidade = 1},
[4] = {id = 17215, quantidade = 1},
}

local itens_grupo2 = {
[1] = {id = 2152},
[2] = {id = 2466, quantidade = 1},
[3] = {id = 2497, quantidade = 1},
[4] = {id = 7730, quantidade = 1},
}

local itens_grupo3 = {
[1] = {id = 2152},
[2] = {id = 2195, quantidade = 1},
[3] = {id = 2492, quantidade = 1},
[4] = {id = 2498, quantidade = 1},
}

local itens_grupo4 = {
[1] = {id = 2392, quantidade = 1},
[2] = {id = 16116, quantidade = 1},
[3] = {id = 17214, quantidade = 1},
}

local storage_time = 55000

---------- CÓDIGO ----------
function onUse(cid, item, fromPosition, itemEx, toPosition)
local index_item = 0 -- VARIÁVEL PARA PEGAR UM INDICE ALEATÓRIO DA TABELA NA VERIFICAÇÃO
local random = 1 -- VARIÁVEL PARA GERAR O RANDOM DOS ITEMS QUE A QUANTIDADE É RANDOM

if getPlayerStorageValue(cid, storage_time) <= os.time() then
------ SE FOR LEVEL MENOR QUE 25 NÃO PODERÁ RECEBER A RECOMPENSA ------
  if getPlayerLevel(cid) < 25 then
     doPlayerSendTextMessage(cid, 27, "You need to be at least level 25 or more to open this chest.")
  return true

------ RECOMPENSA SE FOR LEVEL ENTRE 25 E 49 ------
  elseif getPlayerLevel(cid) >= 25 and getPlayerLevel(cid) < 50 then
     index_item = math.random(1, #itens_grupo1)
     random = math.random(1, 20)
     
     if itens_grupo1[index_item].id == 2152 or itens_grupo1[index_item].id == 2160 then
       doPlayerAddItem(cid, itens_grupo1[index_item].id, random)
       doSendMagicEffect(getThingPos(cid), 27)
       if random > 1 then  
          doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations! You received " ..random.. " " ..getItemNameById(itens_grupo1[index_item].id).. ".")
       else
          doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations! You received " ..getItemNameById(itens_grupo1[index_item].id).. ".") 
       end   
       doRemoveItem(item.uid, 1)   
       setPlayerStorageValue(cid, storage_time, os.time() + 24 * 60 * 60)
     return true
     
     else
       doPlayerAddItem(cid, itens_grupo1[index_item].id, itens_grupo1[index_item].quantidade)
       doSendMagicEffect(getThingPos(cid), 27)
       if itens_grupo1[index_item].quantidade > 1 then
          doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations! You received " ..itens_grupo1[index_item].quantidade.. " " ..getItemNameById(itens_grupo1[index_item].id).. ".")
       else     
       	  doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations! You received " ..getItemNameById(itens_grupo1[index_item].id).. ".")
       end     
       doRemoveItem(item.uid, 1) 
       setPlayerStorageValue(cid, storage_time, os.time() + 24 * 60 * 60)
     return true
     end

----- RECOMPENSA SE FOR LEVEL ENTRE 50 E 99 -----    
  elseif getPlayerLevel(cid) >= 50 and getPlayerLevel(cid) < 100 then  
     index_item = math.random(1, #itens_grupo2)
     random = math.random(1, 50)  

     if itens_grupo2[index_item].id == 2152 then
       doPlayerAddItem(cid, itens_grupo2[index_item].id, random)
       doSendMagicEffect(getThingPos(cid), 27)
       if random > 1 then     
          doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations! You received " ..random.. " " ..getItemNameById(itens_grupo2[index_item].id).. ".")
       else
          doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations! You received " ..getItemNameById(itens_grupo2[index_item].id).. ".")    
       end       
       doRemoveItem(item.uid, 1) 
       setPlayerStorageValue(cid, storage_time, os.time() + 24 * 60 * 60)
     return true
   
     else
       doPlayerAddItem(cid, itens_grupo2[index_item].id, itens_grupo2[index_item].quantidade)
       doSendMagicEffect(getThingPos(cid), 27)
       if itens_grupo2[index_item].quantidade > 1 then
          doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations! You received " ..itens_grupo2[index_item].quantidade.. " " ..getItemNameById(itens_grupo2[index_item].id).. ".")  
       else         
          doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations! You received " ..getItemNameById(itens_grupo2[index_item].id).. ".")
       end         
       doRemoveItem(item.uid, 1) 
       setPlayerStorageValue(cid, storage_time, os.time() + 24 * 60 * 60)
     return true
     end
     
----- RECOMPENSA SE FOR LEVEL ENTRE 100 E 200 -----    
  elseif getPlayerLevel(cid) >= 100 and getPlayerLevel(cid) < 200 then  
     index_item = math.random(1, #itens_grupo3) 
     random = math.random(20, 50)
  
     if itens_grupo3[index_item].id == 2152 then
       doPlayerAddItem(cid, itens_grupo3[index_item].id, random)
       doSendMagicEffect(getThingPos(cid), 27)
       if random > 1 then         
          doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations! You received " ..random.. " " ..getItemNameById(itens_grupo3[index_item].id).. ".")
       else
          doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations! You received " ..getItemNameById(itens_grupo3[index_item].id).. ".")
       end   
       doRemoveItem(item.uid, 1) 
       setPlayerStorageValue(cid, storage_time, os.time() + 24 * 60 * 60)
     return true
   
     else
       doPlayerAddItem(cid, itens_grupo3[index_item].id, itens_grupo3[index_item].quantidade)
       doSendMagicEffect(getThingPos(cid), 27)
       if itens_grupo3[index_item].quantidade > 1 then  
          doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations! You received " ..itens_grupo3[index_item].quantidade.. " " ..getItemNameById(itens_grupo3[index_item].id).. ".")
       else
          doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations! You received " ..getItemNameById(itens_grupo3[index_item].id).. ".")
       end   
       doRemoveItem(item.uid, 1) 
       setPlayerStorageValue(cid, storage_time, os.time() + 24 * 60 * 60)
     return true
     end  
 
----- RECOMPENSA SE FOR LEVEL ACIMA DE 200 -----    
  else  
     index_item = math.random(1, #itens_grupo4) 
     doPlayerAddItem(cid, itens_grupo4[index_item].id, itens_grupo4[index_item].quantidade)
     doSendMagicEffect(getThingPos(cid), 27)
     if itens_grupo4[index_item].quantidade > 1 then  
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations! You received " ..itens_grupo4[index_item].quantidade.. " " ..getItemNameById(itens_grupo4[index_item].id).. ".")
     else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations! You received " ..getItemNameById(itens_grupo4[index_item].id).. ".")
     end   
     doRemoveItem(item.uid, 1) 
     setPlayerStorageValue(cid, storage_time, os.time() + 24 * 60 * 60)
  return true
  end 

else
  doPlayerSendTextMessage(cid, 27, "You need to wait " ..getTime(getPlayerStorageValue(cid, storage_time) - os.time()).. " to get the reward again.")
return true
end 
       
end  

No PDA 1.9, na em Data/Lib nos arquivos de funções tem uma função chamada getTimeDiff que retorna o tempo restante (horas, minutos e segundos). Porém na concatenação a palavra horas, segundos e minutos estão grudados com os valores, então eu separei criando outra função para que fique mais fácil para você, então vá em Data/Lib/SomeFunctions ou outro arquivo contendo as funções e adicione essa função:

 

function getTime(diff)
   local dateFormat = {
      {' hour', diff / 60 / 60}, 
      {' minute', diff / 60 % 60},
      {' second', diff % 60},
   }

   local out = {}  
   local prefix = ''   
                             
   for k, t in ipairs(dateFormat) do
      local v = math.floor(t[2])
      if v > 0 then
         prefix = #out == 0 and '' or k < #dateFormat and ' ' or ' and '
         table.insert(out, prefix .. v .. '' .. (v <= 1 and t[1] or t[1].."s"))
      end
   end

   return table.concat(out)
end 

Ou se preferir, procure a getTimeDiff e dê um espaço nas strings: "hour, minute e second" que irá funcionar.

 

Mas lembrando que se alterar na função getTimeDiff tem que ir nesta linha do script:

doPlayerSendTextMessage(cid, 27, "You need to wait " ..getTime(getPlayerStorageValue(cid, storage_time) - os.time()).. " to get the reward again.")

E trocar por:

doPlayerSendTextMessage(cid, 27, "You need to wait " ..getTimeDiff(getPlayerStorageValue(cid, storage_time) - os.time()).. " to get the reward again.")

 

Também reparei que na tabela do script que postou aqui, a última tabela estava com level mínimo 80, mas na tabela anterior o level mínimo era 100 e máximo 200, talvez poderia ser isso que estava bugando, já que provavelmente o char que estava testando devia ser level maior que 100.

 

Mas eu testei aqui e está funcionando normalmente, já deixei também para o jogador poder pegar novamente a recompensa a cada 24 horas.

 

Testa e se der alguma problema me fale.

Editado Abril 7 por Yan18

TaigerT
07 de abril de 2020 às 23:54

Funcionou, mas voce esqueceu da chance, tem como colocar chance individual para cada item, tipo igual no script original que postei?

{id = 17214, chance = 50, count = 1},

 

Yan OliveiraY
09 de abril de 2020 às 18:25
Em 07/04/2020 em 23:54, Taiger disse:

Funcionou, mas voce esqueceu da chance, tem como colocar chance individual para cada item, tipo igual no script original que postei?

{id = 17214, chance = 50, count = 1},

 

Opa o fórum não me notificou que respondeu, só vi agora. Tem sim, substitui o código por esse:

 

local itens_grupo1 = {
[1] = {id = 2152, chance = 5},
[2] = {id = 2160, chance = 10},
[3] = {id = 17214, quantidade = 1, chance = 15},
[4] = {id = 17215, quantidade = 1, chance = 70},
}

local itens_grupo2 = {
[1] = {id = 2152, chance = 5},
[2] = {id = 2466, quantidade = 1, chance = 10},
[3] = {id = 2497, quantidade = 1, chance = 15},
[4] = {id = 7730, quantidade = 1, chance = 70},
}

local itens_grupo3 = {
[1] = {id = 2152, chance = 5},
[2] = {id = 2195, quantidade = 1, chance = 10},
[3] = {id = 2492, quantidade = 1, chance = 15},
[4] = {id = 2498, quantidade = 1, chance = 70},
}

local itens_grupo4 = {
[1] = {id = 2392, quantidade = 1, chance = 25},
[2] = {id = 16116, quantidade = 1, chance = 50},
[3] = {id = 17214, quantidade = 1, chance = 70},
}

local storage_time = 55000

---------- CÓDIGO ----------
function onUse(cid, item, fromPosition, itemEx, toPosition)
local chance_item = math.random(1, 100)
local random_quantidade = math.random(1, 20)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, chance_item.. " " ..random_quantidade)

if getPlayerStorageValue(cid, storage_time) <= os.time() then

------ SE FOR LEVEL MENOR QUE 25 NÃO PODERÁ RECEBER A RECOMPENSA ------
  if getPlayerLevel(cid) < 25 then
     doPlayerSendTextMessage(cid, 27, "You need to be at least level 25 or more to open this chest.")
  return true

------------------------------ RECOMPENSA SE FOR LEVEL ENTRE 25 E 49 -------------------------------
  elseif getPlayerLevel(cid) >= 25 and getPlayerLevel(cid) < 50 then  
     doSendMagicEffect(getThingPos(cid), 27)
  	
   -- CHANCE 5 --
     if chance_item <= 5 then
       doPlayerAddItem(cid, itens_grupo1[1].id, random_quantidade)
        if random_quantidade > 1 then  
          doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations! You received " ..random_quantidade.. " " ..getItemNameById(itens_grupo1[1].id).. ".")
       else
          doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations! You received " ..getItemNameById(itens_grupo1[1].id).. ".") 
       end     
  	
   -- CHANCE 10 --
     elseif chance_item > 5 and chance_item <= 10 then
        doPlayerAddItem(cid, itens_grupo1[2].id, random_quantidade)
        if random_quantidade > 1 then  
          doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations! You received " ..random_quantidade.. " " ..getItemNameById(itens_grupo1[2].id).. ".")
       else
          doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations! You received " ..getItemNameById(itens_grupo1[2].id).. ".") 
       end       
   
   -- CHANCE 15 --       
    elseif chance_item > 10 and chance_item <= 15 then
       doPlayerAddItem(cid, itens_grupo1[3].id, itens_grupo1[3].quantidade)
        if itens_grupo1[3].quantidade > 1 then
          doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations! You received " ..itens_grupo1[3].quantidade.. " " ..getItemNameById(itens_grupo1[3].id).. ".")
       else     
       	  doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations! You received " ..getItemNameById(itens_grupo1[3].id).. ".")
       end              
   
   -- CHANCE MAIOR QUE 15 ATÉ 100 --
     else
        doPlayerAddItem(cid, itens_grupo1[4].id, itens_grupo1[4].quantidade)
        if itens_grupo1[4].quantidade > 1 then
          doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations! You received " ..itens_grupo1[4].quantidade.. " " ..getItemNameById(itens_grupo1[4].id).. ".")
       else     
       	  doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations! You received " ..getItemNameById(itens_grupo1[4].id).. ".")
       end        
     end
  
    doRemoveItem(item.uid, 1)   
    setPlayerStorageValue(cid, storage_time, os.time() + 24 * 60 * 60)     
    return true

-------------------------------- RECOMPENSA SE FOR LEVEL ENTRE 50 E 99 -------------------------------    
  elseif getPlayerLevel(cid) >= 50 and getPlayerLevel(cid) < 100 then  
     doSendMagicEffect(getThingPos(cid), 27)

   -- CHANCE 5 --
     if chance_item <= 5 then
       doPlayerAddItem(cid, itens_grupo2[1].id, random_quantidade)
        if random_quantidade > 1 then  
          doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations! You received " ..random_quantidade.. " " ..getItemNameById(itens_grupo2[1].id).. ".")
       else
          doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations! You received " ..getItemNameById(itens_grupo2[1].id).. ".") 
       end     
  	
   -- CHANCE 10 --
     elseif chance_item > 5 and chance_item <= 10 then
        doPlayerAddItem(cid, itens_grupo2[2].id, random_quantidade)
        if random_quantidade > 1 then  
          doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations! You received " ..random_quantidade.. " " ..getItemNameById(itens_grupo2[2].id).. ".")
       else
          doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations! You received " ..getItemNameById(itens_grupo2[2].id).. ".") 
       end       
   
   -- CHANCE 15 --       
    elseif chance_item > 10 and chance_item <= 15 then
       doPlayerAddItem(cid, itens_grupo2[3].id, itens_grupo2[3].quantidade)
        if itens_grupo2[3].quantidade > 1 then
          doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations! You received " ..itens_grupo2[3].quantidade.. " " ..getItemNameById(itens_grupo2[3].id).. ".")
       else     
       	  doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations! You received " ..getItemNameById(itens_grupo2[3].id).. ".")
       end              
   
   -- CHANCE MAIOR QUE 15 ATÉ 100 --
     else
       doPlayerAddItem(cid, itens_grupo2[4].id, itens_grupo2[4].quantidade)
        if itens_grupo2[4].quantidade > 1 then
          doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations! You received " ..itens_grupo2[4].quantidade.. " " ..getItemNameById(itens_grupo2[4].id).. ".")
       else     
       	  doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations! You received " ..getItemNameById(itens_grupo2[4].id).. ".")
       end       
     end
  
   doRemoveItem(item.uid, 1)   
   setPlayerStorageValue(cid, storage_time, os.time() + 24 * 60 * 60)     
   return true  

-------------------- RECOMPENSA SE FOR LEVEL ENTRE 100 E 200 ----------------------    
  elseif getPlayerLevel(cid) >= 100 and getPlayerLevel(cid) < 200 then    
     doSendMagicEffect(getThingPos(cid), 27)
  	
   -- CHANCE 5 --
     if chance_item <= 5 then
       doPlayerAddItem(cid, itens_grupo3[1].id, itens_grupo3[1].quantidade)
        if itens_grupo3[1].quantidade > 1 then
          doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations! You received " ..itens_grupo3[3].quantidade.. " " ..getItemNameById(itens_grupo3[1].id).. ".")
       else     
       	  doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations! You received " ..getItemNameById(itens_grupo3[1].id).. ".")
       end              
  	
   -- CHANCE 10 --
     elseif chance_item > 5 and chance_item <= 10 then
        doPlayerAddItem(cid, itens_grupo3[2].id, itens_grupo3[2].quantidade)
        if itens_grupo3[2].quantidade > 1 then
          doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations! You received " ..itens_grupo3[2].quantidade.. " " ..getItemNameById(itens_grupo3[2].id).. ".")
       else     
       	  doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations! You received " ..getItemNameById(itens_grupo3[2].id).. ".")
       end              
   
   -- CHANCE 15 --       
    elseif chance_item > 10 and chance_item <= 15 then
       doPlayerAddItem(cid, itens_grupo3[3].id, itens_grupo3[3].quantidade)
        if itens_grupo3[3].quantidade > 1 then
          doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations! You received " ..itens_grupo3[3].quantidade.. " " ..getItemNameById(itens_grupo3[3].id).. ".")
       else     
       	  doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations! You received " ..getItemNameById(itens_grupo3[3].id).. ".")
       end              
   
   -- CHANCE MAIOR QUE 15 ATÉ 100 --
     else
        doPlayerAddItem(cid, itens_grupo3[4].id, itens_grupo3[4].quantidade)
        if itens_grupo3[4].quantidade > 1 then
          doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations! You received " ..itens_grupo3[4].quantidade.. " " ..getItemNameById(itens_grupo3[4].id).. ".")
       else     
       	  doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations! You received " ..getItemNameById(itens_grupo3[4].id).. ".")
       end        
     end
  
    doRemoveItem(item.uid, 1)   
    setPlayerStorageValue(cid, storage_time, os.time() + 24 * 60 * 60)    
    return true

----------------------- RECOMPENSA SE FOR LEVEL ACIMA DE 200 -----------------------    
  else  
     doSendMagicEffect(getThingPos(cid), 27)
  	  	
   -- CHANCE ATÉ 25 --
     if chance_item <= 25 then
        doPlayerAddItem(cid, itens_grupo4[1].id, itens_grupo4[1].quantidade)
        if itens_grupo4[1].quantidade > 1 then
          doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations! You received " ..itens_grupo4[1].quantidade.. " " ..getItemNameById(itens_grupo4[1].id).. ".")
       else     
       	  doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations! You received " ..getItemNameById(itens_grupo4[1].id).. ".")
       end              
   
   -- CHANCE ATÉ 50 --       
    elseif chance_item > 25 and chance_item <= 50 then
       doPlayerAddItem(cid, itens_grupo4[2].id, itens_grupo4[2].quantidade)
        if itens_grupo4[2].quantidade > 1 then
          doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations! You received " ..itens_grupo4[2].quantidade.. " " ..getItemNameById(itens_grupo4[2].id).. ".")
       else     
       	  doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations! You received " ..getItemNameById(itens_grupo4[2].id).. ".")
       end              
   
   -- CHANCE MAIOR QUE 50 ATÉ 100 --
     else
        doPlayerAddItem(cid, itens_grupo4[3].id, itens_grupo4[3].quantidade)
        if itens_grupo4[3].quantidade > 1 then
          doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations! You received " ..itens_grupo4[3].quantidade.. " " ..getItemNameById(itens_grupo4[3].id).. ".")
       else     
       	  doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations! You received " ..getItemNameById(itens_grupo4[3].id).. ".")
       end       
     end
  
    doRemoveItem(item.uid, 1)   
    setPlayerStorageValue(cid, storage_time, os.time() + 24 * 60 * 60) 
    return true 
  end  

else
  doPlayerSendTextMessage(cid, 27, "You need to wait " ..getHorasRestante(getPlayerStorageValue(cid, storage_time) - os.time()).. " to get the reward again.")
return true
end 
       
end  

Testei aqui e funcionou. Só lembrando que a chance da última tabela tive que definir outros valores porque a do seu script estava meio confuso e a soma da chance dos itens estava dando mais de 100. Mas pode editar de acordo com sua preferência, lembrando que tem que estar de acordo com a verificação do script. Mas caso queira inserir um novo item, vai ter que editar o script, pois ele está pegando diretamente cada item da tabela de acordo com a chance, então como ele pega o índice direto, se inserir um novo item, e a chance for desse item, ele vai dar erro ou não vai adicionar nada.

Editado Abril 9 por Yan18