Ir para conteúdo

Featured Replies

Postado
local config = {
	[1] = {item = 2160, count = 10, msg = "blablabla."}, -- 60%
	[2] = {item = 2160, count = 10, msg = "blablabla."}, -- 15%
	[3] = {item = 2160, count = 10, msg = "blablabla."}, -- 14%
	[4] = {item = 2160, count = 10, msg = "blablabla."}, -- 5%
	[5] = {item = 2160, count = 10, msg = "blablabla."}, -- 3%
	[6] = {item = 2160, count = 10, msg = "blablabla."}, -- 2%
	[7] = {item = 2160, count = 10, msg = "blablabla."}, -- 1%
}


function onUse(cid, item, fromPosition, itemEx, toPosition)
	
	local x, vetor = math.random(1, 100), 0
	
	if x <= 60 then
		vetor = 1
	elseif x > 60 and x <= 75 then
		vetor = 2
	elseif x > 75 and x <= 89 then
		vetor = 3
	elseif x > 89 and x <= 94 then
		vetor = 4
	elseif x > 94 and x <= 97 then
		vetor = 5
	elseif x > 97 and x <= 99 then
		vetor = 6
	elseif x == 100 then
		vetor = 7
	end
	
	local reward = config[vetor]
	if reward then
		doCreatureSay(cid, reward.msg, TALKTYPE_ORANGE_1)
		doPlayerAddItem(cid, reward.item, reward.count)
		doRemoveItem(cid, item.uid, 1)
	end
	
	return true
end
  • Respostas 8
  • Visualizações 489
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • function onUse(cid, item, fromPosition, itemEx, toPosition) local rand = math.random(1, 120) if rand <= 10 then doCreatureSay(cid, "Abriu e ganhou 15x HANDGUN AMMO!", TALKTYPE_ORANGE_

  • luanluciano93
    luanluciano93

    local config = { [1] = {item = 2160, count = 10, msg = "blablabla."}, -- 60% [2] = {item = 2160, count = 10, msg = "blablabla."}, -- 15% [3] = {item = 2160, count = 10, msg = "blablabla."}, -- 14%

  • biel.stocco
    biel.stocco

    tudo bem manin, agradeço a intenção e obg mesmo, fico muito grato quando pelo menos tentam ajudar de bom coração!     Nesse sistema eu teria que, por exemplo: o baú terá chance de 15 i

Postado
  • Autor

biel.stocco, Desculpe eu estava sem tempo, eu ia fazer o script mais snowsz já fez At+

tudo bem manin, agradeço a intenção e obg mesmo, fico muito grato quando pelo menos tentam ajudar de bom coração!

 

 

 

local config = {

    [1] = {item = 2160, count = 10, msg = "blablabla."}, -- 60%

    [2] = {item = 2160, count = 10, msg = "blablabla."}, -- 15%

    [3] = {item = 2160, count = 10, msg = "blablabla."}, -- 14%

    [4] = {item = 2160, count = 10, msg = "blablabla."}, -- 5%

    [5] = {item = 2160, count = 10, msg = "blablabla."}, -- 3%

    [6] = {item = 2160, count = 10, msg = "blablabla."}, -- 2%

    [7] = {item = 2160, count = 10, msg = "blablabla."}, -- 1%

}

function onUse(cid, item, fromPosition, itemEx, toPosition)

    

    local x, vetor = math.random(1, 100), 0

    

    if x <= 60 then

        vetor = 1

    elseif x > 60 and x <= 75 then

        vetor = 2

    elseif x > 75 and x <= 89 then

        vetor = 3

    elseif x > 89 and x <= 94 then

        vetor = 4

    elseif x > 94 and x <= 97 then

        vetor = 5

    elseif x > 97 and x <= 99 then

        vetor = 6

    elseif x == 100 then

        vetor = 7

    end

    

    local reward = config[vetor]

    if reward then

        doCreatureSay(cid, reward.msg, TALKTYPE_ORANGE_1)

        doPlayerAddItem(cid, reward.item, reward.count)

        doRemoveItem(cid, item.uid, 1)

    end

    

    return true

end

 

Nesse sistema eu teria que, por exemplo:

o baú terá chance de 15 itens diferentes, então terei de configurar a porcentagem dos 15 itens completando 100% ao todo, é isso?

 

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.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.7k

Informação Importante

Confirmação de Termo