Ir para conteúdo
  • Cadastre-se

(Resolvido)Box Poke Random Com Chance Configuravel


Ir para solução Resolvido por antharaz,

Posts Recomendados

Bem queria uma script de Box que desse um Poke Random com a chance de cada Poke configurável, ja tenho uma que faz isso com item mais não consegui adaptar.Se alguém Puder da uma ajudinha agradeço muito :D

 

Script Da Box Que ja Tenho Que Da Item:

Spoiler

local config = {storage = 559761,hours = 1}
local items =

--[numeração] = {id = ID DO ITEM, count = QUANTIDADE DO ITEM, c = CHANCE}
    [1]={id=2160, count=100, c=60}, -- item 1
    [2]={id=14215, count=7, c=20}, -- item 2
    [3]={id=14214, count=100, c=60}, -- item 3
    [4]={id=14188, count=1, c=60}, -- item 4
    [5]={id=14186, count=1, c=50}, -- item 5
    [6]={id=14185, count=1, c=35}, -- item 6
    [7]={id=12618, count=8, c=60}, -- item 7
    [8]={id=12323, count=1, c=60}, -- item 8
    [9]={id=14241, count=1, c=40}, -- item 9
    [10]={id=2392, count=100, c=60}, -- item 10
}

function getRandomItem(t)
    local i = math.random(1, #t)
    i = t
    if math.random(1, 100) <= i.c then
        return i
    end
    
    return getRandomItem(t)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
         if getPlayerLevel(cid) >= 225 then
         if getPlayerStorageValue(cid,config.storage) >= os.time() then
         return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Desculpe, mas voce deve aguardar ate "..os.date("%d %B %Y %X ", getPlayerStorageValue(cid,config.storage)).." para pegar seu presente novamente!")
         end    
         local i = getRandomItem(items)
         setPlayerStorageValue(cid, config.storage, os.time()+config.hours*3600)
         doPlayerAddItem(cid, i.id, i.count)
         doSendAnimatedText(getPlayerPosition(cid), "Box!", TEXTCOLOR_GREEN)
         doPlayerSendTextMessage(cid, 27, "Você abriu uma Box e Ganhou "..i.count.."x "..getItemNameById(i.id)..(i.count > 1 and "s" or "")..".")
         else
           doPlayerSendCancel(cid,'So Level 225+ Pode Pegar')
        end
return true
end

 

 

Exemplo de Box De Poke:

Spoiler

local a = {
[12313] = {pokemons = {"Tyranitar", "Aggron", "Rhyperior", "Steelix", "Shiny Onix", "Shiny Larvitar", "Metagross","Tyranitar", "Aggron", "Rhyperior", "Steelix", "Metagross", "Metagross","Tyranitar", "Aggron", "Rhyperior", "Steelix", "Metagross",
                        "Metagross","Tyranitar", "Aggron", "Rhyperior", "Steelix", "Metagross", "Metagross","Tyranitar", "Aggron", "Rhyperior", "Steelix", "Metagross", "Metagross","Tyranitar", "Aggron", "Rhyperior", "Steelix", "Metagross"}}
}
        
local happy = 1000 
         
function onUse(cid, item, frompos, item2, topos)
         local b = a[item.itemid]                                    
               if not b then return true end
         local pokemon = b.pokemons[math.random(#b.pokemons)]
               if not pokes[pokemon] then return true end  

         doPlayerSendTextMessage(cid, 27, "You opened a pokemon prize box +"..item.itemid - (11637).."!")
     doPlayerSendTextMessage(cid, 27, "The prize pokemon was a "..pokemon..", congratulations!")
     doSendMagicEffect(getThingPos(cid), 29)
               
         addPokeToPlayer(cid, pokemon, 20, nil, btype)     --alterado v1.9                                                   
         doRemoveItem(item.uid, 1)
                   if useOTClient then
                doCreatureExecuteTalkAction(cid, "/salvar")
    end
    
return true
end

 

Link para o post
Compartilhar em outros sites
Spoiler

local config = {
				storage = 559761, --storage usada
				exaust = 1, --exaust em horas
				pokes = {
								{pokemon="Rat", c=90}, --{id = ID DO ITEM, c = CHANCE}
								{pokemon="Rotworm", c=90}, 
								{pokemon="Dog", c=90}
				},
				lvl_min = 200 --level minimo para usar
}


function onUse(cid, item, fromPosition, itemEx, toPosition)
	if getPlayerLevel(cid) < config.lvl_min then
		return doPlayerSendCancel(cid,'Somente Level '..config.lvl_min..'+ Pode Pegar')
	elseif getPlayerStorageValue(cid,config.storage) > os.time() then
		return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Desculpe, mas voce deve aguardar ate "..os.date("%d %B %Y %X ", getPlayerStorageValue(cid,config.storage)).." para pegar seu presente novamente!")
	end
	setPlayerStorageValue(cid, config.storage, os.time()+config.exaust*3600)
	local poke = config.pokes[math.random(1,#config.pokes)]
	print(poke.c)
	if math.random(1,100) > poke.c then
		return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Desculpe, mas voce não obteve sucesso ao pegar seu presente!")
	end
	addPokeToPlayer(cid, poke.pokemon, 20, nil, btype)
	doSendAnimatedText(getPlayerPosition(cid), "Box!", TEXTCOLOR_GREEN)
	doPlayerSendTextMessage(cid, 27, "Você abriu uma Box e Ganhou um "..poke.pokemon..".")
	return true
end

 

 

Link para o post
Compartilhar em outros sites
14 minutos atrás, antharaz disse:
  Ocultar conteúdo


local config = {
				storage = 559761, --storage usada
				exaust = 1, --exaust em horas
				pokes = {
								{pokemon="Rat", c=90}, --{id = ID DO ITEM, c = CHANCE}
								{pokemon="Rotworm", c=90}, 
								{pokemon="Dog", c=90}
				},
				lvl_min = 200 --level minimo para usar
}


function onUse(cid, item, fromPosition, itemEx, toPosition)
	if getPlayerLevel(cid) < config.lvl_min then
		return doPlayerSendCancel(cid,'Somente Level '..config.lvl_min..'+ Pode Pegar')
	elseif getPlayerStorageValue(cid,config.storage) > os.time() then
		return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Desculpe, mas voce deve aguardar ate "..os.date("%d %B %Y %X ", getPlayerStorageValue(cid,config.storage)).." para pegar seu presente novamente!")
	end
	setPlayerStorageValue(cid, config.storage, os.time()+config.exaust*3600)
	local poke = config.pokes[math.random(1,#config.pokes)]
	print(poke.c)
	if math.random(1,100) > poke.c then
		return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Desculpe, mas voce não obteve sucesso ao pegar seu presente!")
	end
	addPokeToPlayer(cid, poke.pokemon, 20, nil, btype)
	doSendAnimatedText(getPlayerPosition(cid), "Box!", TEXTCOLOR_GREEN)
	doPlayerSendTextMessage(cid, 27, "Você abriu uma Box e Ganhou um "..poke.pokemon..".")
	return true
end

 

 

Vllw man funcionou, mas teria como fazer pro player sempre conseguir algum pokemon ?

Link para o post
Compartilhar em outros sites
  • Solução

@port16 

 

Na próxima vez, coloca tudo que você quer no primeiro post para não ter que ficar alterando toda hora. ta ae:

 

Spoiler

local config = {
				storage = 559761, --storage usada
				exaust = 1, --exaust em horas
				pokes = {
								{pokemon="Rat", c=90}, --{id = ID DO ITEM, c = CHANCE}
								{pokemon="Rotworm", c=90}, 
								{pokemon="Dog", c=90}
				},
				lvl_min = 200 --level minimo para usar
}

function ppoke()
	local v,poke = 0,{}
	while 1 do
		poke = config.pokes[math.random(1,#config.pokes)]
		if math.random(1,100) <= poke.c then
			return poke
		end
	end
end


function onUse(cid, item, fromPosition, itemEx, toPosition)
	if getPlayerLevel(cid) < config.lvl_min then
		return doPlayerSendCancel(cid,'Somente Level '..config.lvl_min..'+ Pode Pegar')
	elseif getPlayerStorageValue(cid,config.storage) > os.time() then
		return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Desculpe, mas voce deve aguardar ate "..os.date("%d %B %Y %X ", getPlayerStorageValue(cid,config.storage)).." para pegar seu presente novamente!")
	end
	setPlayerStorageValue(cid, config.storage, os.time()+config.exaust*3600)
	local poke = ppoke()
	addPokeToPlayer(cid, poke.pokemon, 20, nil, btype)
	doSendAnimatedText(getPlayerPosition(cid), "Box!", TEXTCOLOR_GREEN)
	doPlayerSendTextMessage(cid, 27, "Você abriu uma Box e Ganhou um "..poke.pokemon..".")
	return true
end

 

 

Link para o post
Compartilhar em outros sites
4 minutos atrás, antharaz disse:

@port16 

 

Na próxima vez, coloca tudo que você quer no primeiro post para não ter que ficar alterando toda hora. ta ae:

 

  Ocultar conteúdo


local config = {
				storage = 559761, --storage usada
				exaust = 1, --exaust em horas
				pokes = {
								{pokemon="Rat", c=90}, --{id = ID DO ITEM, c = CHANCE}
								{pokemon="Rotworm", c=90}, 
								{pokemon="Dog", c=90}
				},
				lvl_min = 200 --level minimo para usar
}

function ppoke()
	local v,poke = 0,{}
	while 1 do
		poke = config.pokes[math.random(1,#config.pokes)]
		if math.random(1,100) <= poke.c then
			return poke
		end
	end
end


function onUse(cid, item, fromPosition, itemEx, toPosition)
	if getPlayerLevel(cid) < config.lvl_min then
		return doPlayerSendCancel(cid,'Somente Level '..config.lvl_min..'+ Pode Pegar')
	elseif getPlayerStorageValue(cid,config.storage) > os.time() then
		return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Desculpe, mas voce deve aguardar ate "..os.date("%d %B %Y %X ", getPlayerStorageValue(cid,config.storage)).." para pegar seu presente novamente!")
	end
	setPlayerStorageValue(cid, config.storage, os.time()+config.exaust*3600)
	local poke = ppoke()
	addPokeToPlayer(cid, poke.pokemon, 20, nil, btype)
	doSendAnimatedText(getPlayerPosition(cid), "Box!", TEXTCOLOR_GREEN)
	doPlayerSendTextMessage(cid, 27, "Você abriu uma Box e Ganhou um "..poke.pokemon..".")
	return true
end

 

 

Muito Obrigado cara.

Link para o post
Compartilhar em outros sites

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

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo