Ir para conteúdo
  • Cadastre-se

(Resolvido)Quantidade RANDOM


Ir para solução Resolvido por FlavioHulk,

Posts Recomendados

Como Colocar pra mensagem aparecer com a quantidade random que ganhou?

 

 

            str = str .. amount .. ' ' .. getItemNameById(item_id) .. ' '..(i ~= table.maxn(items) and ', ' or '.')

 

  Mostrar conteúdo oculto
Editado por tetheuscunha (veja o histórico de edições)

Senhoras e senhores, se alguma resposta lhe ajudou, marque-a como a melhor resposta e de ponto positivo, assim você incentiva quem lhe ajudou a continuar ajudando!!.

Link para o post
Compartilhar em outros sites

Poderia explicar isso melhor? Você quer que apareça a chance que o player conseguiu para obter a recompensa?

E por que a tabela tá com a mesma variável pra todos os actionIds?

items[1] é a chance que o player poderá obter ou não?

Link para o post
Compartilhar em outros sites
  Em 17/10/2018 em 05:08, FlavioHulk disse:

Poderia explicar isso melhor? Você quer que apareça a chance que o player conseguiu para obter a recompensa?

E por que a tabela tá com a mesma variável pra todos os actionIds?

items[1] é a chance que o player poderá obter ou não?

 

Mostrar mais  

Não, eu quero que aparece a quantidade que o player ganhou. O player pode ganhar de 1 ate 10 crystal coins, eu quero que aparece : Você ganhou x cristal coins.

 

 

Senhoras e senhores, se alguma resposta lhe ajudou, marque-a como a melhor resposta e de ponto positivo, assim você incentiva quem lhe ajudou a continuar ajudando!!.

Link para o post
Compartilhar em outros sites
local chest = {
	[8049] = {
		name = '[Event] BOX',
		container = 1738, 
		items = {
			[1] = {
				chance = 100,
				itemId = 2160,
				amountMax = 10
			}
		}
	}
}

function onUse(cid, item, frompos, item2, topos)
    local tmpConfig = chest[item.actionid]
    if not tmpConfig then
    	return true
    end

    local container, str = doPlayerAddItem(cid, tmpConfig.container, 1), 'BackPack from '.. tmpConfig.name ..', Your Rewards:\n'
    for i = 1, #tmpConfig.items do
    	local items = tmpConfig.items[i]items
    	if chance >= math.random(1, 100) then
    		local amountRandom = math.random(1, items.amountMax)
    		str = str .. amountRandom .. ' ' .. getItemNameById(items.itemId) .. ' '..(i ~= #tmpConfig.items and ', ' or '.')
    		doAddContainerItem(tmpConfig.container, items.itemId, amountRandom)
    	else
    		return true
    	end
    end

    doSendMagicEffect(getPlayerPosition(cid), math.random(28, 30))
    doRemoveItem(item.uid, 1)
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,'You have found a '.. str)
	return true
end

Quanto a tabela ter sido reduzida, você deve fazer o seguinte:
Ir no RME e colocar somente aquela action em todas as caixas, e deixar os unique ids em 0 ou não inserir...
Colocar somente as actionsIds nos boxes, não uniqueId ! 

Link para o post
Compartilhar em outros sites
  Em 18/10/2018 em 15:06, FlavioHulk disse:
local chest = {
	[8049] = {
		name = '[Event] BOX',
		container = 1738, 
		items = {
			[1] = {
				chance = 100,
				itemId = 2160,
				amountMax = 10
			}
		}
	}
}

function onUse(cid, item, frompos, item2, topos)
    local tmpConfig = chest[item.actionid]
    if not tmpConfig then
    	return true
    end

    local container, str = doPlayerAddItem(cid, tmpConfig.container, 1), 'BackPack from '.. tmpConfig.name ..', Your Rewards:\n'
    for i = 1, #tmpConfig.items do
    	local items = tmpConfig.items[i]items
    	if chance >= math.random(1, 100) then
    		local amountRandom = math.random(1, items.amountMax)
    		str = str .. amountRandom .. ' ' .. getItemNameById(items.itemId) .. ' '..(i ~= #tmpConfig.items and ', ' or '.')
    		doAddContainerItem(tmpConfig.container, items.itemId, amountRandom)
    	else
    		return true
    	end
    end

    doSendMagicEffect(getPlayerPosition(cid), math.random(28, 30))
    doRemoveItem(item.uid, 1)
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,'You have found a '.. str)
	return true
end

Quanto a tabela ter sido reduzida, você deve fazer o seguinte:
Ir no RME e colocar somente aquela action em todas as caixas, e deixar os unique ids em 0 ou não inserir...
Colocar somente as actionsIds nos boxes, não uniqueId ! 

 

Mostrar mais  

Assim que chegar em casa irei testar. Obrigado

 

## EDIT:

Deu esse erro @FlavioHulk

 

[22:37:50.257] [Error - LuaInterface::loadFile] data/actions/scripts/test2.lua:24: '=' expected near 'if'
[22:37:50.258] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/test2.lua)
[22:37:50.258] data/actions/scripts/test2.lua:24: '=' expected near 'if'

Editado por tetheuscunha (veja o histórico de edições)

Senhoras e senhores, se alguma resposta lhe ajudou, marque-a como a melhor resposta e de ponto positivo, assim você incentiva quem lhe ajudou a continuar ajudando!!.

Link para o post
Compartilhar em outros sites
local chest = {
	[8049] = {
		name = '[Event] BOX',
		container = 1738, 
		items = {
			[1] = {
				chance = 100,
				itemId = 2160,
				amountMax = 10
			}
		}
	}
}

function onUse(cid, item, frompos, item2, topos)
    local tmpConfig = chest[item.actionid]
    if not tmpConfig then
    	return true
    end

    local container, str = doPlayerAddItem(cid, tmpConfig.container, 1), 'BackPack from '.. tmpConfig.name ..', Your Rewards:\n'
    for i = 1, #tmpConfig.items do
    	local items = tmpConfig.items[i]
    	if chance >= math.random(1, 100) then
    		local amountRandom = math.random(1, items.amountMax)
    		str = str .. amountRandom .. ' ' .. getItemNameById(items.itemId) .. ' '..(i ~= #tmpConfig.items and ', ' or '.')
    		doAddContainerItem(tmpConfig.container, items.itemId, amountRandom)
    	else
    		return true
    	end
    end

    doSendMagicEffect(getPlayerPosition(cid), math.random(28, 30))
    doRemoveItem(item.uid, 1)
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,'You have found a '.. str)
	return true
end

 

Link para o post
Compartilhar em outros sites
  Em 19/10/2018 em 19:56, FlavioHulk disse:
local chest = {
	[8049] = {
		name = '[Event] BOX',
		container = 1738, 
		items = {
			[1] = {
				chance = 100,
				itemId = 2160,
				amountMax = 10
			}
		}
	}
}

function onUse(cid, item, frompos, item2, topos)
    local tmpConfig = chest[item.actionid]
    if not tmpConfig then
    	return true
    end

    local container, str = doPlayerAddItem(cid, tmpConfig.container, 1), 'BackPack from '.. tmpConfig.name ..', Your Rewards:\n'
    for i = 1, #tmpConfig.items do
    	local items = tmpConfig.items[i]
    	if chance >= math.random(1, 100) then
    		local amountRandom = math.random(1, items.amountMax)
    		str = str .. amountRandom .. ' ' .. getItemNameById(items.itemId) .. ' '..(i ~= #tmpConfig.items and ', ' or '.')
    		doAddContainerItem(tmpConfig.container, items.itemId, amountRandom)
    	else
    		return true
    	end
    end

    doSendMagicEffect(getPlayerPosition(cid), math.random(28, 30))
    doRemoveItem(item.uid, 1)
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,'You have found a '.. str)
	return true
end

 

 

Mostrar mais  

[18:11:34.774] [Error - Action Interface]
[18:11:34.776] data/actions/scripts/test2.lua:onUse
[18:11:34.779] Description:
[18:11:34.781] data/actions/scripts/test2.lua:24: attempt to compare number with nil
[18:11:34.782] stack traceback:
[18:11:34.783]  data/actions/scripts/test2.lua:24: in function <data/actions/scripts/test2.lua:15>

Senhoras e senhores, se alguma resposta lhe ajudou, marque-a como a melhor resposta e de ponto positivo, assim você incentiva quem lhe ajudou a continuar ajudando!!.

Link para o post
Compartilhar em outros sites
local chest = {
    [8049] = {
        name = '[Event] BOX',
        container = 1738, 
        items = {
            [1] = {
                chance = 100,
                itemId = 2160,
                amountMax = 10
            }
        }
    }
}

function onUse(cid, item, frompos, item2, topos)
    local tmpConfig = chest[item.actionid]
    if not tmpConfig then
        return true
    end

    local container, str = doPlayerAddItem(cid, tmpConfig.container, 1), 'BackPack from '.. tmpConfig.name ..', Your Rewards:\n'
    for i = 1, #tmpConfig.items do
        local items = tmpConfig.items[i]
        if tmpConfig.chance >= math.random(1, 100) then
            local amountRandom = math.random(1, items.amountMax)
            str = str .. amountRandom .. ' ' .. getItemNameById(items.itemId) .. ' '..(i ~= #tmpConfig.items and ', ' or '.')
            doAddContainerItem(tmpConfig.container, items.itemId, amountRandom)
        else
            return true
        end
    end

    doSendMagicEffect(getPlayerPosition(cid), math.random(28, 30))
    doRemoveItem(item.uid, 1)
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,'You have found a '.. str)
    return true
end

 

Link para o post
Compartilhar em outros sites
  Em 19/10/2018 em 22:26, FlavioHulk disse:
local chest = {
    [8049] = {
        name = '[Event] BOX',
        container = 1738, 
        items = {
            [1] = {
                chance = 100,
                itemId = 2160,
                amountMax = 10
            }
        }
    }
}

function onUse(cid, item, frompos, item2, topos)
    local tmpConfig = chest[item.actionid]
    if not tmpConfig then
        return true
    end

    local container, str = doPlayerAddItem(cid, tmpConfig.container, 1), 'BackPack from '.. tmpConfig.name ..', Your Rewards:\n'
    for i = 1, #tmpConfig.items do
        local items = tmpConfig.items[i]
        if tmpConfig.chance >= math.random(1, 100) then
            local amountRandom = math.random(1, items.amountMax)
            str = str .. amountRandom .. ' ' .. getItemNameById(items.itemId) .. ' '..(i ~= #tmpConfig.items and ', ' or '.')
            doAddContainerItem(tmpConfig.container, items.itemId, amountRandom)
        else
            return true
        end
    end

    doSendMagicEffect(getPlayerPosition(cid), math.random(28, 30))
    doRemoveItem(item.uid, 1)
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,'You have found a '.. str)
    return true
end

 

 

Expand   Mostrar mais  

[19:35:34.292] [Error - Action Interface]
[19:35:34.294] data/actions/scripts/test2.lua:onUse
[19:35:34.295] Description:
[19:35:34.298] data/actions/scripts/test2.lua:24: attempt to compare number with nil
[19:35:34.299] stack traceback:
[19:35:34.300]  data/actions/scripts/test2.lua:24: in function <data/actions/scripts/test2.lua:15>

Senhoras e senhores, se alguma resposta lhe ajudou, marque-a como a melhor resposta e de ponto positivo, assim você incentiva quem lhe ajudou a continuar ajudando!!.

Link para o post
Compartilhar em outros sites
  • Solução
local chest = {
    [8049] = {
        name = '[Event] BOX',
        container = 1738, 
        items = {
            [1] = {
                chance = 100,
                itemId = 2160,
                amountMax = 10
            }
        }
    }
}

function onUse(cid, item, frompos, item2, topos)
    local tmpConfig = chest[item.actionid]
    if not tmpConfig then
        return true
    end

    local container, str = doPlayerAddItem(cid, tmpConfig.container, 1), 'BackPack from '.. tmpConfig.name ..', Your Rewards:\n'
    for i = 1, #tmpConfig.items do
        local items = tmpConfig.items[i]
        if items.chance >= math.random(1, 100) then
            local amountRandom = math.random(1, items.amountMax)
            str = str .. amountRandom .. ' ' .. getItemNameById(items.itemId) .. ' '..(i ~= #tmpConfig.items and ', ' or '.')
            doAddContainerItem(container, items.itemId, amountRandom)
        else
            return true
        end
    end

    doSendMagicEffect(getPlayerPosition(cid), math.random(28, 30))
    doRemoveItem(item.uid, 1)
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,'You have found a '.. str)
    return true
end

Puts, erro meu! Não havia reparado, mas tudo bem, vida que segue... @KotZletY @Vodkart marcação aleatória, só saudades <3

Link para o post
Compartilhar em outros sites

@FlavioHulk estou meio: "é, tudo bem então!!", com o fórum, e como você disse aê, "vida que segue". HAudhasd

 

Saudades de quê ? Estou on no discord o tempo todo, e tenho no celu também, só chamar! :rock:

 

 

 

 

                                                              ezgif-1-98aab239f3.gif.1a897c9c3225228909e7b356a5cfb8e4.gif

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.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

  • Estatísticas dos Fóruns

    96833
    Tópicos
    519574
    Posts
×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo