Ir para conteúdo

Featured Replies

Postado

Ontem mesmo postei um tópico pedindo uma ajuda com esse code de chest e um sangue bom me trouxe um código intacto e 100%..

 

Bem, como eu costumo acumular barreiras kkk acabei por tentar usar o mesmo code, mas dessa vez para que cada char(vocation) pegue mais de 1 item...

 

Tentei, tentei, de diversas formas cabíveis à minha inteligência e nenhuma delas funcionou.. In-game, apenas o ID do primeiro item de cada vocation era recebido da chest..

 

esse é o .lua do code que estou tentando replicar, do amigo aqui do fórum que me ajudou @Weslley Kiyo :)

 

local cfg = {
	knight = {2430}, 
	paladin = {2173}, 
	sorcerer = {2189},
	druid = {8857}, 
}

function onUse(cid, item)

	if getPlayerStorageValue(cid, 38493) < 1 then
		if getPlayerVocation(cid) == 4 or getPlayerVocation(cid) == 8 then
			if doPlayerAddItem(cid, cfg.knight[1], 1) then
				doPlayerSendTextMessage(cid, 25, "Congratulations!!")
				doPlayerSetStorageValue(cid, 38493, 1)
			else
				doPlayerSendTextMessage(cid,25,"ERROR! Please contact the administrator.")
			end
		elseif getPlayerVocation(cid) == 1 or getPlayerVocation(cid) == 5 then
			if doPlayerAddItem(cid, cfg.sorcerer[1], 1) then
				doPlayerSendTextMessage(cid, 25, "Congratulations!!")
				doPlayerSetStorageValue(cid, 38493, 1)
			else
				doPlayerSendTextMessage(cid,25,"ERROR! Please contact the administrator.")
			end
		elseif getPlayerVocation(cid) == 2 or getPlayerVocation(cid) == 6 then
			if doPlayerAddItem(cid, cfg.druid[1], 1) then
				doPlayerSendTextMessage(cid, 25, "Congratulations!!")
				doPlayerSetStorageValue(cid, 38493, 1)
			else
				doPlayerSendTextMessage(cid,25,"ERROR! Please contact the administrator.")
			end
		elseif getPlayerVocation(cid) == 3 or getPlayerVocation(cid) == 7 then
			if doPlayerAddItem(cid, cfg.paladin[1], 1) then
				doPlayerSendTextMessage(cid, 25, "Congratulations!!")
				doPlayerSetStorageValue(cid, 38493, 1)
			else
				doPlayerSendTextMessage(cid,25,"ERROR! Please contact the administrator.")
			end
		end
	elseif getPlayerStorageValue(cid, 38493) >= 1 then
		doPlayerSendCancel(cid, "It's empty.")
	end
	return true
end

 

Enfim.. Tentei bastante encaixar mais itens em cada vocation no local cfg...

 

Quem puder ajudar, fortalecer preu saber como realiza essa diversificação/incrementação de mais itens em cada linha de cada vocation, agradeço imensamente rs

Postado

Não testei esse código, mas fiz rapidinho aqui no site mesmo:
 

local cfg = {
    --     vocs     id   qtd   id   qtd
	[1] = {{4,8}, {{2430, 1}, {2380, 1}}},
	[2] = {{3,7}, {{2173, 1}, {2380, 1}}},
	[3] = {{1,5}, {{2189, 1}, {2380, 1}}},
	[4] = {{2,6}, {{8857, 1}, {7380, 5}}}
}

function onUse(cid, item)

local voc = getPlayerVocation(cid)

if getPlayerStorageValue(cid, 38493) < 1 then
	for i,v in ipairs(cfg) do
  		if voc == v[1][1] or voc == v[1][2] then
    		for p=1, #v[2] do
        		doPlayerAddItem(cid, v[2][p][1], v[2][p][2])
    		end
    		doPlayerSendTextMessage(cid, 25, "Congratulations!!")
			doPlayerSetStorageValue(cid, 38493, 1)
  		end
	end
else
	doPlayerSendCancel(cid, "It's empty.")
end
return true
end

Adicionei ao código uma parte que tu pode adicionar a quantidade de cada item. Se não entender como configurar o, só perguntar aqui, mas eu comentei para que ficasse mais fácil de entender a tabela.

                                                                     Ajudei? De nada \o/                                            Att Rusherzin

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.6k

Informação Importante

Confirmação de Termo