Ir para conteúdo
  • Cadastre-se

(Resolvido)Script de mineração


Ir para solução Resolvido por MaTTch,

Posts Recomendados

 

Opa, eu tentei fazer esse script de mineração, ele até funciona, mas não parece que funfa 100% certin, ele faz o que era pra fazer, mas eu botei o percent bem alto usando o pickaxe e mesmo assim existe dificuldade de pegar o item, eu nunca usei o for, então não sei se usei ele corretamente, alguém que netende bem poderia dar uma olhada e dizer no que estou errado? a parte do ground podem ignorar, só a parte do stones mesmo

local configs = {
sign = {{level = {0,9}, quant = {1,2}, percent = 5},
{level = {10,19}, quant = {2,4}, percent = 8},
{level = {20,29}, quant = {3,6}, percent = 11},
{level = {30,39}, quant = {4,8}, percent = 14},
{level = {40,49}, quant = {5,10}, percent = 17},
{level = {50,59}, quant = {6,12}, percent = 20},
{level = {60,69}, quant = {7,14}, percent = 23},
{level = {70,79}, quant = {8,16}, percent = 26},
{level = {80,89}, quant = {9,18}, percent = 29},
{level = {90,99}, quant = {10,20}, percent = 32},
{level = {100,200}, quant = {11,22}, percent = 35}},
stones = {1285, 1356},
stones_prize = {
{itemprize = 2160, percent = {1,10}},
{itemprize = 2152, percent = {11,30}},
{itemprize = 2148, percent = {31,100}},
},
grounds = {406},
grounds_prize = {
{itemprize = 2160, percent = {0,1}},
{itemprize = 2157, percent = {2,3}}
},
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local skills = getPlayerSkill(cid, SKILL_SWORD)
if isInArray(configs.stones, itemEx.itemid) then
doPlayerAddSkillTry(cid, SKILL_SWORD, 1)
transform_stone = math.random(1, 100)
	if transform_stone < 16 then
		doTransformItem(itemEx.uid, 2160)
		doPlayerSendTextMessage(cid, 22, "More luck in your next time.")
	else
		for L = 1, #configs.sign do
			if skills >= configs.sign[L].level[1] and skills <= configs.sign[L].level[2] then
				quant = math.random(configs.sign[L].quant[1],configs.sign[L].quant[2])
				if item.itemid == 4874 then
					percent = configs.sign[L].percent + 75
					stry = 2
				else
					percent = configs.sign[L].percent
					stry = 1
				end
				print('Skill: '.. skills ..'.')
				print('Porce: '.. percent ..'%.')
				print('Stry: '.. stry ..'.')
				percent_chance = math.random(1, 100)
				print('PC '.. percent_chance ..'.')
				if percent_chance <= percent then
					for M = 1, #configs.stones_prize do
						for_stone_prize = math.random(1, 100)
						print('SP '.. for_stone_prize..'.')
						if for_stone_prize >= configs.stones_prize[M].percent[1] and for_stone_prize <= configs.stones_prize[M].percent[2] then
							doPlayerAddSkillTry(cid, SKILL_SWORD, stry)
							doPlayerAddItem(cid, configs.stones_prize[M].itemprize, quant)
							doPlayerSendTextMessage(cid, 22, "You won ".. quant .." ".. getItemNameById(configs.stones_prize[M].itemprize) ..".")
							break_chance = math.random(1,100)
							if break_chance < 6 then
								doTransformItem(itemEx.uid, 2160)
							end
							break
						else
							doPlayerSendTextMessage(cid, 22, "You have not won anything, try again..")
							break
						end						
					end
				else
					doPlayerSendTextMessage(cid, 22, "You did not succeed in mining , try again.")
				end
			break
			end		
		end
	end	
elseif isInArray(configs.grounds, itemEx.itemid) then
		doPlayerAddSkillTry(cid, SKILL_SWORD, 1)
		transform_ground = math.random(1, 100)
		if transform_ground < 16 then
			doTransformItem(itemEx.uid, 2160)
			doPlayerSendTextMessage(cid, 22, "Sorry, but this ground was empty.")
		else
			for L = 1, #configs.sign do
				if skills >= configs.sign[L].level[1] and skills <= configs.sign[L].level[2] then
					quant = math.random(configs.sign[L].quant[1],configs.sign[L].quant[2])
					percent_chance = math.random(1, 100)
					if percent_chance <= percent then
						for M = 1, #configs.grounds_prize do
							for_ground_prize = math.random(1, 100)
							if for_ground_prize >= configs.grounds_prize[M].percent[1] and for_grounds_prize <= configs.grounds_prize[M].percent[2] then
								doPlayerAddItem(cid, configs.grounds_prize[M].itemprize, quant)
								doPlayerSendTextMessage(cid, 22, "You won ".. quant .." ".. getItemNameById(configs.grounds_prize[M].itemprize) ..".")
								doTransformItem(itemEx.uid, 2160)
							else
								doPlayerSendTextMessage(cid, 22, "You have not won anything, try again..")
							end
						break	
						end
					else
						doPlayerSendTextMessage(cid, 22, "You did not succeed in mining , try again.")
					end
				break
				end
			end
		end
	end
end
Eu que não fumo, queria um cigarro
Eu que não amo você
Envelheci dez anos ou mais
Nesse último mês
Eu que não bebo, pedi um conhaque
Pra enfrentar o inverno
Que entra pela porta
Que você deixou aberta ao sair
avatar_1218.gif
Link para o post
Compartilhar em outros sites

man eu ainda tou aprendendo script e não parece ter nada errado, unica coisa q tou vendo é que a chance ta baixa

{level = {10,19}, quant = {2,4}, percent = 8},

do lvl 10 ao 19 pode vir de 2 a 4 com 8% de chance ou seja
a cada 100x que for usado vai cair uma media de 8x ou seja a porcentagem ta bem baxinha almenta o 8 pra 90 e testa. acredito que vá cair com mais facilidade

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

Tente trocar essa parte:
 

Spoiler

if percent_chance <= percent then
	for M = 1, #configs.stones_prize do
		for_stone_prize = math.random(1, 100)
		print('SP '.. for_stone_prize..'.')
		if for_stone_prize >= configs.stones_prize[M].percent[1] and for_stone_prize <= configs.stones_prize[M].percent[2] then
			doPlayerAddSkillTry(cid, SKILL_SWORD, stry)
			doPlayerAddItem(cid, configs.stones_prize[M].itemprize, quant)
			doPlayerSendTextMessage(cid, 22, "You won ".. quant .." ".. getItemNameById(configs.stones_prize[M].itemprize) ..".")
			break_chance = math.random(1,100)
			if break_chance < 6 then
				doTransformItem(itemEx.uid, 2160)
			end
			break
		else
			doPlayerSendTextMessage(cid, 22, "You have not won anything, try again..")
			break
		end
	end
else
	doPlayerSendTextMessage(cid, 22, "You did not succeed in mining , try again.")
end

 

 

Por essa:
 

Spoiler

if percent_chance <= percent then
	for_stone_prize = math.random(1, 100)
	print('SP '.. for_stone_prize..'.')
	for M = 1, #configs.stones_prize do
		if for_stone_prize >= configs.stones_prize[M].percent[1] and for_stone_prize <= configs.stones_prize[M].percent[2] then
			doPlayerAddSkillTry(cid, SKILL_SWORD, stry)
			doPlayerAddItem(cid, configs.stones_prize[M].itemprize, quant)
			doPlayerSendTextMessage(cid, 22, "You won ".. quant .." ".. getItemNameById(configs.stones_prize[M].itemprize) ..".")
			break_chance = math.random(1,100)
			if break_chance < 6 then
				doTransformItem(itemEx.uid, 2160)
			end
			break
		elseif(M == #configs.stones_prize) then
			doPlayerSendTextMessage(cid, 22, "You have not won anything, try again..")
		end
	end
else
	doPlayerSendTextMessage(cid, 22, "You did not succeed in mining , try again.")
end

 



Dica: deixe as variáveis locais e não globais.

Link para o post
Compartilhar em outros sites

 

@wevertonvrb

13 horas atrás, blackz disse:

if item.itemid == 4874 then

percent = configs.sign[L].percent + 75

mas se tu olhar aqui, com pickaxe fica bem vantajoso e mesmo assim fica dificil de pegar

 

@MaTTch

4 horas atrás, MaTTch disse:

elseif(M == #configs.stones_prize) then

        doPlayerSendTextMessage(cid, 22, "You have not won anything, try again..")

aqui não vai break? ou esquece-se? e mais uma coisinha, podes me explicar o por que de assim funcionar?

Editado por blackz (veja o histórico de edições)
Eu que não fumo, queria um cigarro
Eu que não amo você
Envelheci dez anos ou mais
Nesse último mês
Eu que não bebo, pedi um conhaque
Pra enfrentar o inverno
Que entra pela porta
Que você deixou aberta ao sair
avatar_1218.gif
Link para o post
Compartilhar em outros sites

@MaTTch

Dica: deixe as variáveis locais e não globais.

 

não sei oque isso significa (:

Editado por blackz (veja o histórico de edições)
Eu que não fumo, queria um cigarro
Eu que não amo você
Envelheci dez anos ou mais
Nesse último mês
Eu que não bebo, pedi um conhaque
Pra enfrentar o inverno
Que entra pela porta
Que você deixou aberta ao sair
avatar_1218.gif
Link para o post
Compartilhar em outros sites

 

@MaTTch

cara, e fiz uma alteração no script, e adicionei mais itemprizes e agora qdo ganha alguma item, ele da a msg de que ganho o item e em seguida essa ação é executada

Em 11/08/2016 ás 21:02, MaTTch disse:

elseif(M == #configs.stones_prize) then

doPlayerSendTextMessage(cid, 22, "You have not won anything, try again..")

end

local configs = {
sign = {{level = {0,9}, percent = 5},
{level = {10,19}, percent = 8},
{level = {20,29}, percent = 11},
{level = {30,39}, percent = 14},
{level = {40,49}, percent = 17},
{level = {50,59}, percent = 20},
{level = {60,69}, percent = 23},
{level = {70,79}, percent = 26},
{level = {80,89}, percent = 29},
{level = {90,99}, percent = 32},
{level = {100,200}, percent = 35}},
stones = {1285, 1356},
stones_prize = {
{itemprize = 1294, quant = {1,5}, percent = {1,50}}, --small stones
{itemprize = 2145, quant = {1,5}, percent = {51,55}}, -- small diamond
{itemprize = 2146, quant = {1,5}, percent = {56,60}}, -- small sapphire
{itemprize = 2147, quant = {1,5}, percent = {61,65}}, -- small ruby
{itemprize = 2149, quant = {1,5}, percent = {66,70}}, -- small emerald
{itemprize = 2150, quant = {1,5}, percent = {71,75}}, -- small amethyst
},
grounds = {406},
grounds_prize = {
{itemprize = 1294, quant = {1,5}, percent = {1,50}}, --small stones
{itemprize = 2145, quant = {1,5}, percent = {51,55}}, -- small diamond
{itemprize = 2146, quant = {1,5}, percent = {56,60}}, -- small sapphire
{itemprize = 2147, quant = {1,5}, percent = {61,65}}, -- small ruby
{itemprize = 2149, quant = {1,5}, percent = {66,70}}, -- small emerald
{itemprize = 2150, quant = {1,5}, percent = {71,75}}, -- small amethyst
{itemprize = 2219, quant = {1,1}, percent = {76,84}}, -- banana skin
{itemprize = 2220, quant = {1,1}, percent = {85,93}}, -- dirty fur
{itemprize = 5888, quant = {1,4}, percent = {94,98}}, -- iron
{itemprize = 5887, quant = {1,3}, percent = {99,100}}, -- steel
},
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local skills = getPlayerSkill(cid, SKILL_SWORD)
if isInArray(configs.stones, itemEx.itemid) then
doPlayerAddSkillTry(cid, SKILL_SWORD, 1)
transform_stone = math.random(1, 100)
	if transform_stone < 16 then
		doTransformItem(itemEx.uid, 2160)
		doPlayerSendTextMessage(cid, 22, "More luck in your next time.")
	else
		for L = 1, #configs.sign do
			if skills >= configs.sign[L].level[1] and skills <= configs.sign[L].level[2] then				
				if item.itemid == 4874 then
					percent = configs.sign[L].percent + 75
					stry = 2
				else
					percent = configs.sign[L].percent
					stry = 1
				end
				print('Skill: '.. skills ..'.')
				print('Porce: '.. percent ..'%.')
				print('Stry: '.. stry ..'.')
				percent_chance = math.random(1, 100)
				print('PC '.. percent_chance ..'.')
				if percent_chance <= percent then
					for_stone_prize = math.random(1, 100)
					for M = 1, #configs.stones_prize do						
						print('SP '.. for_stone_prize..'.')
						if for_stone_prize >= configs.stones_prize[M].percent[1] and for_stone_prize <= configs.stones_prize[M].percent[2] then
							quant = math.random(configs.stones_prize[M].quant[1],configs.stones_prize[M].quant[2])
							doPlayerAddSkillTry(cid, SKILL_SWORD, stry)
							doPlayerAddItem(cid, configs.stones_prize[M].itemprize, quant)
							doPlayerSendTextMessage(cid, 22, "You won ".. quant .." ".. getItemNameById(configs.stones_prize[M].itemprize) ..".")
							break_chance = math.random(1,100)
							if break_chance < 6 then
								doTransformItem(itemEx.uid, 2160)
							end							
						elseif (M == #configs.stones_prize) then
							doPlayerSendTextMessage(cid, 22, "You have not won anything, try again..")												
						end
					end
				else
					doPlayerSendTextMessage(cid, 22, "You did not succeed in mining , try again.")
				end
			break
			end		
		end
	end	
elseif isInArray(configs.grounds, itemEx.itemid) then
		doPlayerAddSkillTry(cid, SKILL_SWORD, 1)
		transform_ground = math.random(1, 100)
			if transform_ground < 16 then
				doTransformItem(itemEx.uid, 2160)
				doPlayerSendTextMessage(cid, 22, "More luck in your next time.")
			else
				for L = 1, #configs.sign do
					if skills >= configs.sign[L].level[1] and skills <= configs.sign[L].level[2] then				
						if item.itemid == 4874 then
							percent = configs.sign[L].percent + 75
							stry = 2
						else
							percent = configs.sign[L].percent
							stry = 1
						end
						print('Skill: '.. skills ..'.')
						print('Porce: '.. percent ..'%.')
						print('Stry: '.. stry ..'.')
						percent_chance = math.random(1, 100)
						print('PC '.. percent_chance ..'.')
						if percent_chance <= percent then
							for_ground_prize = math.random(1, 100)
							for M = 1, #configs.grounds_prize do						
								print('SP '.. for_ground_prize..'.')
								if for_ground_prize >= configs.grounds_prize[M].percent[1] and for_ground_prize <= configs.grounds_prize[M].percent[2] then
									quant = math.random(configs.grounds_prize[M].quant[1],configs.grounds_prize[M].quant[2])
									doPlayerAddSkillTry(cid, SKILL_SWORD, stry)
									doPlayerAddItem(cid, configs.grounds_prize[M].itemprize, quant)
									doPlayerSendTextMessage(cid, 22, "You won ".. quant .." ".. getItemNameById(configs.grounds_prize[M].itemprize) ..".")
									break_chance = math.random(1,100)
									if break_chance < 6 then
										doTransformItem(itemEx.uid, 2160)
									end
								elseif (M == #configs.grounds_prize) then
									doPlayerSendTextMessage(cid, 22, "You have not won anything, try again..")
								end
							end
						else
							doPlayerSendTextMessage(cid, 22, "You did not succeed in mining , try again.")
						end
					break
					end		
				end
			end	
	end
end

 

Editado por blackz (veja o histórico de edições)
Eu que não fumo, queria um cigarro
Eu que não amo você
Envelheci dez anos ou mais
Nesse último mês
Eu que não bebo, pedi um conhaque
Pra enfrentar o inverno
Que entra pela porta
Que você deixou aberta ao sair
avatar_1218.gif
Link para o post
Compartilhar em outros sites

@blackz

Spoiler

local config = {
	sign = {
		{level = {0,9}, percent = 5},
		{level = {10,19}, percent = 8},
		{level = {20,29}, percent = 11},
		{level = {30,39}, percent = 14},
		{level = {40,49}, percent = 17},
		{level = {50,59}, percent = 20},
		{level = {60,69}, percent = 23},
		{level = {70,79}, percent = 26},
		{level = {80,89}, percent = 29},
		{level = {90,99}, percent = 32},
		{level = {100,200}, percent = 35}
	},
	stones = {1285, 1356},
	stones_prize = {
		{itemprize = 1294, quant = {1,5}, percent = {1,50}}, --small stones
		{itemprize = 2145, quant = {1,5}, percent = {51,55}}, -- small diamond
		{itemprize = 2146, quant = {1,5}, percent = {56,60}}, -- small sapphire
		{itemprize = 2147, quant = {1,5}, percent = {61,65}}, -- small ruby
		{itemprize = 2149, quant = {1,5}, percent = {66,70}}, -- small emerald
		{itemprize = 2150, quant = {1,5}, percent = {71,75}} -- small amethyst
	},
	grounds = {406},
	grounds_prize = {
		{itemprize = 1294, quant = {1,5}, percent = {1,50}}, --small stones
		{itemprize = 2145, quant = {1,5}, percent = {51,55}}, -- small diamond
		{itemprize = 2146, quant = {1,5}, percent = {56,60}}, -- small sapphire
		{itemprize = 2147, quant = {1,5}, percent = {61,65}}, -- small ruby
		{itemprize = 2149, quant = {1,5}, percent = {66,70}}, -- small emerald
		{itemprize = 2150, quant = {1,5}, percent = {71,75}}, -- small amethyst
		{itemprize = 2219, quant = {1,1}, percent = {76,84}}, -- banana skin
		{itemprize = 2220, quant = {1,1}, percent = {85,93}}, -- dirty fur
		{itemprize = 5888, quant = {1,4}, percent = {94,98}}, -- iron
		{itemprize = 5887, quant = {1,3}, percent = {99,100}} -- steel
	}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	local tab
	
	local skill = getPlayerSkill(cid, SKILL_SWORD)
	if(isInArray(config.stones, itemEx.itemid)) then
		tab = config.stones_prize
	elseif(isInArray(config.grounds, itemEx.itemid)) then
		tab = config.grounds_prize
	end
	
	if(tab) then
		doPlayerAddSkillTry(cid, SKILL_SWORD, 1)
		
		if(math.random(1, 100) < 16) then -- break chance
			doTransformItem(itemEx.uid, 2160, 1)
			doPlayerSendTextMessage(cid, 22, "More luck in your next time.")
		else
			for _, sign in ipairs(config.sign) do
				local percent, skillTry, PC
				if(skill >= sign.level[1] and skill <= sign.level[2]) then
					if(item.itemid == 4874) then
						percent = sign.percent + 75
						skillTry = 2
					else
						percent = sign.percent
						skillTry = 1
					end
					
					PC = math.random(1, 100)
					
					print('Skill: '.. skill ..'.')
					print('Porce: '.. percent ..'%.')
					print('Stry: '.. skillTry ..'.')
					print('PC '.. PC ..'.')
					
					if(PC <= percent) then
						PC = math.random(1, 100)
						print('SP '.. PC..'.')
						
						for n, prize in ipairs(tab) do
							if(PC >= prize.percent[1] and PC <= prize.percent[2]) then
								local quant = math.random(prize.quant[1], prize.quant[2])
								doPlayerAddSkillTry(cid, SKILL_SWORD, skillTry)
								doPlayerAddItem(cid, prize.itemprize, quant)
								doPlayerSendTextMessage(cid, 22, "You won ".. quant .." ".. getItemNameById(prize.itemprize) ..".")
								
								if(math.random(1, 100) < 6) then -- break chance
									doTransformItem(itemEx.uid, 2160, 1)
								end
								break
								
							elseif(n == #tab) then
								doPlayerSendTextMessage(cid, 22, "You have not won anything, try again.")
							end
						end
					else
						doPlayerSendTextMessage(cid, 22, "You did not succeed in mining, try again.")
					end
					break
				end
			end
		end
	end
	return true
end

 

 

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