Jump to content
  • 0

Script de mineração


Boguemon

Question

 

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) thendoPlayerAddSkillTry(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	endend

 

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

O problema, alem da formatação e o algoritmo usado, esta na quantidade de verificaçao de percentuais.

Citar
if for_stone_prize >= configs.stones_prize[M].percent[1] and for_stone_prize <= configs.stones_prize[M].percent[2] then

Logo acima dessa linha, existe uma outra veroficacao de percentual.

Tentq simplificar o codigo, removendo o maximo possivel de coisas deesnecessarias.

Link to comment
Share on other sites

×
×
  • Create New...