Jump to content
  • 0
snowflake1963

script goes into infinite loop

Question

Hello All,

 

i have a script for mining and it gets stuck in an infinite loop and freezes up causing players to re-log.

 

Does anyone have any advice on how stop the freezing up?

 

Thank you in advance

 

mfg

Snowflake

 

/////////////////////////////////////////////////////////////////////////// NORMAL MINE////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////-	script	MinerSpot	-1,{	freeloop(0);	if (!getarraysize($@CommonMinerals)) goto OnInit;	if (countitem(7318) < 1) {		mes "[^0000FF" + strcharinfo(0) + "^000000]";		mes "Yeah, this is a beautiful mineral vein, but i can't work on it.";		mes " ";		mes ">> Required item: ^FF0000" + getitemname(7318) + " ^000000<<";		close;	}	// * Remove 1 Old Pick	delitem 7318,1;		// Game Startup (don't change)	set @HRock,rand(10,25);	// How strong is the rock	set @Hpick,rand(10,21);	// How strong is the Old Pick	set @HWeak,rand(9);	// Weak spot in the rock	set @HWP,0;		// Flag for Weak Point Found		// ** Resistence	set @RESIST,0;	// Headgear	if (isequipped(5031) || isequipped(5009))		set @RESIST, @RESIST + 50 + getequiprefinerycnt(1);	else {		if (getequipisequiped(1)) set @RESIST, @RESIST + 15 + getequiprefinerycnt(1);		if (getequipisequiped(9)) set @RESIST, @RESIST + 10;		if (getequipisequiped(10)) set @RESIST, @RESIST + 5;	}		// * Shoes	if (isequipped(2401) || isequipped(2402) || isequipped(2403) || isequipped(2404) || isequipped(2407) || isequipped(2416))		set @RESIST, @RESIST + 10 + getequiprefinerycnt(6);	else if (getequipisequiped(6))		set @RESIST, @RESIST + 20 + getequiprefinerycnt(6);			// * Hand protectors	if (getequipid(7) == 2604 || getequipid(7) == 2615  || getequipid(7) == 2624 || getequipid(7) == 2667 || getequipid(7) == 2692 || getequipid(7) == 2701)		set @RESIST, @RESIST + 10;	if (getequipid(8) == 2604 || getequipid(8) == 2615  || getequipid(8) == 2624 || getequipid(8) == 2667 || getequipid(8) == 2692 || getequipid(8) == 2701)		set @RESIST, @RESIST + 10;	if (@RESIST > 100) set @RESIST, 100;		// * Armor	if (getequipisequiped(2)) set @RESIST, @RESIST + 10 + getequiprefinerycnt(2);		// * Chance to get minerals - (10 = 10%) - (20 = 5%) - (100 = 1%)	set @HLuck,rand(2);	mes "[^0000FF" + strcharinfo(0) + "^000000]";	mes "I need discover a weak point in this mineral vein as soon as posible.";	mes " ";	mes ">> Equip Resistance: ^FF0000" + @RESIST + "%^000000";	next;L_BrkRock:	if (@HRock > 20)		set @RockSt$,"^0EAE1B";	else if (@HRock > 15)		set @RockSt$,"^7CAE0E";	else if (@HRock > 10)		set @RockSt$,"^E3C521";	else if (@HRock > 5)		set @RockSt$,"^D86112";	else		set @RockSt$,"^D82412";		if (@Hpick > 20)		set @PickSt$,"^0EAE1B";	else if (@Hpick > 15)		set @PickSt$,"^7CAE0E";	else if (@Hpick > 10)		set @PickSt$,"^E3C521";	else if (@Hpick > 5)		set @PickSt$,"^D86112";	else		set @PickSt$,"^D82412";	for (set @x, 0; @x < 25; set @x, @x + 1) {		if (@HRock > @x)			set @RockSt$, @RockSt$ + "¤";		else			set @RockSt$, @RockSt$ + "^E0E0E0¤";		if (@Hpick > @x)			set @PickSt$, @PickSt$ + "¤";		else			set @PickSt$, @PickSt$ + "^E0E0E0¤";	}	mes "[^0000FF" + strcharinfo(0) + "^000000]";	if (@HWP){		mes "Weak Point: ^0000FF" + $@PickLocation$[@HWeak] + "^000000";	} else {		mes "Searching Weak Point...";	}	mes "> Rock: ";	mes " [" + @RockSt$ + "^000000]";	mes "> " + getitemname(7318) + ": ";	mes " [" + @PickSt$ + "^000000]";	next;	deletearray @KPos,127;	deletearray @KNm$,127;	setarray @KPos[0],50,50,50,50,50,50,50,50,50;	set @i, 0;	while(@i < 9) {		set @Wrd, rand(9);		set @Repeated,0;		if (@i > 0) {			for (set @x, 0; @x < @i; set @x, @x + 1) {				if (@Wrd == @KPos[@x]) set @Repeated,1;			}		}		if (!@Repeated) {			// Set the position in the array			set @KPos[@i],@Wrd;			set @i, @i + 1;		}	}	set @tmpMenu$,"";	for (set @x, 0; @x < 9; set @x, @x + 1) {		set @tmpMenu$, @tmpMenu$ + $@PickLocation$[@KPos[@x]] + ":";	}	set @tmpMenu$, @tmpMenu$ + "Exit";	// Select the location to break the rock	set @opc, select(@tmpMenu$) - 1;	if (@opc == 9) goto L_Exit;	// Weak side found!	if (@KPos[@opc] == @HWeak) {		soundeffect "chepet_attack.wav",0;		set @HWP,1;		set @Hpower1, rand(3,4);		set @Hpower2, rand(2);	} else {		soundeffect "apocalips_h_move.wav",0;		set @Hpower1, rand(2);		set @Hpower2, rand(1,3);	}	set @HRock, @HRock - @Hpower1;	set @Hpick, @Hpick - @Hpower2;	if (!rand(10)) {		// Accident!!!		mes "[^0000FF" + strcharinfo(0) + "^000000]";		if (@RESIST < 100 || !rand(10)) {			if (Sex)				soundeffect "die_male.wav",0;			else				soundeffect "die_merchant_female.wav",0;			percentheal -rand(1,rand(100-@RESIST)),0;			mes "^FF0000" + $@MNAccidents$[rand(getarraysize($@MNAccidents$))] + "^000000";		} else {			mes "^FF0000" + $@MNAccidents2$[rand(getarraysize($@MNAccidents2$))] + "^000000";		}		if (Hp < 1) close;		next;	} else if (!rand(500)) {		// Earth Quake!!!		soundeffect "earth_quake.wav",0;		percentheal -100,-100;		announce "The mine is colapsing, you are dead!",3;		end;	}	if (@Hpick < 1) {		// Old Pick is broken!		specialeffect2 155;		mes "[^0000FF" + strcharinfo(0) + "^000000]";		mes "Holy shit, i broke this " + getitemname(7318) + "!";		mes " ";		mes ">> ^FF0000" + countitem(7318) + "^000000 " + getitemname(7318) + " left";		close;	}	// Give another chance while @HRock is > 0	if (@HRock > 0) goto L_BrkRock;	soundeffect "tming_success.wav",0;	specialeffect 266;	mes "[^0000FF" + strcharinfo(0) + "^000000]";	mes "Yeahh!!!, the stone wall is history!";	next;	soundeffect "ice_titan_die.wav",0;L_GetMinerals:	if (@Hpick > 20){		set @PickSt$,"^0EAE1B";	} else if (@Hpick > 15){		set @PickSt$,"^7CAE0E";	} else if (@Hpick > 10){		set @PickSt$,"^E3C521";	} else if (@Hpick > 5){		set @PickSt$,"^D86112";	} else {		set @PickSt$,"^D82412";	}	for (set @x, 0; @x < 25; set @x, @x + 1) {		if (@Hpick > @x){			set @PickSt$, @PickSt$ + "¤";		} else {			set @PickSt$, @PickSt$ + "^E0E0E0¤";		}	}	mes "[^0000FF" + strcharinfo(0) + "^000000]";	mes "> " + getitemname(7318) + ": ";	mes " [" + @PickSt$ + "^000000]";	next;	select("Beat");	// Clang!!!	soundeffect "green_iguana_damage.wav",0;		set @Points, rand(@HLuck);	if (!@Points) { // 10%		set @IType, rand(1000);		if (!@IType) { // 0.1%			set @Mineral, $@BonusItems[rand(getarraysize($@BonusItems))];			set @Message$, "OMG!!! i found 1 " + getitemname(@Mineral) + "!";		} else if (@IType < 50) { // 5%			set @Mineral, $@SpecialMinerals[rand(getarraysize($@SpecialMinerals))];			set @Message$, "Yeah!, this is usefull!";		} else { // 94.9%			set @Mineral, $@NormalMinerals[rand(getarraysize($@NormalMinerals))];			set @Message$, "There's nothing usefull here?";		}	} else { // 90%		set @Mineral, $@CommonMinerals[rand(getarraysize($@CommonMinerals))];		set @Message$, "Pfff...";	}	if (@Mineral > 500) {		// Check weight		if (checkweight(@Mineral,1) == 0) {			mes "[^0000FF" + strcharinfo(0) + "^000000]";			mes "Damn!!!... i need more space to get this...";			mes "(You Lose: ^FF00001 " + getitemname(@Mineral) + "^000000)";			close;		}		getitem @Mineral,1;		dispbottom "Mine: You get 1 " + getitemname(@Mineral);		mes "[^0000FF" + strcharinfo(0) + "^000000]";		mes @Message$;		next;	} else {		mes "[^0000FF" + strcharinfo(0) + "^000000]";		mes ">> Grr!!... damn mine!!! <<";		next;	}	// Calculate the Old Pick	set @Hpick, @Hpick - rand(3);	if (@Hpick < 1) {		// Old Pick is broken!		specialeffect2 155;		mes "[^0000FF" + strcharinfo(0) + "^000000]";		mes "Damn, i broke this " + getitemname(7318) + ".";		mes " ";		mes ">> ^FF0000" + countitem(7318) + "^000000 " + getitemname(7318) + " left";		close;	}	goto L_GetMinerals;	end;L_Exit:	mes "[^0000FF" + strcharinfo(0) + "^000000]";	mes "I'm tired... fiuuufff...";	close;	end;OnInit:	setarray $@CommonMinerals[0],	909,1,1,1,1,1,1,1,1,1,1,1,1;	setarray $@NormalMinerals[0],	715,716,717,7067,7300,733,910,911,912,984,985,998,999,1002,1010,1011,7053,7054,7096,7220,7321;	setarray $@SpecialMinerals[0],	718,719,720,721,722,723,724,725,726,727,728,729,730,731,732,990,991,992,993,994,995,996,997,1000,1003,7224,7231,7232,7233,7289,7290,7291,7292,7293,7294,7295,7296,969;	setarray $@BonusItems[0],	616,2622,2605,2616,2621,2624,2626,2665,2666,2667,2670,2673,	2682,2683,2684,2685; // OCA & RINGS	setarray $@PickLocation$[0],	"[O] Center","[/] Up","[/] Down","[<] Left","[>] Right","[<] Top Left","[/>] Top Right","[</] Bottom Left","[>] Bottom Right";	setarray $@MNAccidents$[0],	"Ouchhh!!! my eye... snifff","Arghh!!!!... my finger!","Ouch!... a stone fell on my head...";	setarray $@MNAccidents2$[0],	"Oh my lord, that was lucky!","He he he... i'm protected!";}

 

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0
	freeloop(1);	while(@i < 9) {		set @Wrd, rand(9);		set @Repeated,0;		if (@i > 0) {			for (set @x, 0; @x < @i; set @x, @x + 1) {				if (@Wrd == @KPos[@x]) set @Repeated,1;			}		}		if (!@Repeated) {			// Set the position in the array			set @KPos[@i],@Wrd;			set @i, @i + 1;		}	}	freeloop(0);

Just add freeloop(1) and freeloop(0) before and after that part, as shown above.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.