Ir para conteúdo

Featured Replies

Postado
 

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

Resolvido por MaTTch

Ir para solução
  • Respostas 8
  • Visualizações 1.8k
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • Tente trocar essa parte:     Por essa:   Dica: deixe as variáveis locais e não globais.

Postado

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

Postado
  • 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.

Postado
  • Autor

 

@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)

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