Jump to content
  • 0
Sign in to follow this  
hadiesyafiq

[Request] Exchanger NPC with successful percentage function

Question

Hi all can someone share or teach me how to do this script?

the script i want is like this:

Exchange item to item need to pay zeny but have percentage to failure 

example change silver coins to gold coins requirement 1 silver coins and 500zeny but 80% successful and 20% fail...

 

thanks in advance 

Share this post


Link to post
Share on other sites

4 answers to this question

Recommended Posts

  • 0
1 hour ago, Kenpachi said:

Hi.

 

if (rand(10000) < 2000) // 20% chance to fail. // FAIL else // SUCCESS


if (rand(10000) < 2000) // 20% chance to fail.
	// FAIL
else
	// SUCCESS

 

 

~Kenpachi

Hi my idol...can you show me how to put it specific on the script?

 

and can you help me like this :

1 silver coins + 500zeny = 20% chance to get  gold coins

1 silver coins + 10cash = 50% chance to get gold coins

1 silver coins + poring coin = 90% chance to get gold coins...

 

sir @Kenpachi can you help me build this?

Share this post


Link to post
Share on other sites
  • 0

Hi.

 

Quick'n'dirty:
 

Spoiler

prontera,150,170,0	script	Coin Exchange	4_F_KAFRA5,{
	mes(.npc_name$);
	mes("What do you want to exchange for 1 Gold Coin?");

	.@selection1 = select(.menu_option1$, .menu_option2$, .menu_option3$);

	mesclear();
	mes(.npc_name$);

	if (countitem(Silver_Coin) < 1) {
		mes("You need at least 1 Silver Coin.");
		close();
	}

	switch (.@selection1) {
	case 1:
		if (Zeny < 500) {
			mes("You need at least 500z.");
			close();
		}
		break;
	case 2:
		if (#CASHPOINTS < 10) {
			mes("You need at least 10 Cash Points.");
			close();
		}
		break;
	case 3:
		if (countitem(Poring_Coin) < 1) {
			mes("You need at least 1 Poring Coin.");
			close();
		}
		break;
	}

	mes("Are you sure?");

	.@selection2 = select("Yes", "No");

	mesclear();
	mes(.npc_name$);

	if (.@selection2 == 2) {
		mes("Okay, see you.");
		close();
	}

	delitem(Silver_Coin, 1);

	switch (.@selection1) {
	case 1: // 20% success chance.
		.@failed = (rand(10000) < 8000) ? 1 : 0;
		Zeny -= 500;
		break;
	case 2: // 50% success chance.
		.@failed = (rand(10000) < 5000) ? 1 : 0;
		#CASHPOINTS -= 10;
		break;
	case 3: // 90% success chance.
		.@failed = (rand(10000) < 1000) ? 1 : 0;
		delitem(Poring_Coin, 1);
		break;
	}

	if (.@failed == 1) {
		mes("Sorry, you had no luck.");
	} else {
		mes("You're a lucky person and obtain 1 Gold Coin.");
		getitem(Gold_Coin, 1);
	}

	close();



OnInit:
	.npc_name$ = "[" + strnpcinfo(NPC_NAME_VISIBLE) + "]";
	.menu_option1$ = "1 Silver Coin + 500z (20% chance)";
	.menu_option2$ = "1 Silver Coin + 10 Cash Points (50% chance)";
	.menu_option3$ = "1 Silver Coin + 1 Poring Coin (90% chance)";
	end;
}

 

 

 

~Kenpachi

Share this post


Link to post
Share on other sites
  • 0
7 hours ago, Kenpachi said:

Hi.

 

Quick'n'dirty:
 

  Hide contents

prontera,150,170,0 script Coin Exchange 4_F_KAFRA5,{ mes(.npc_name$); mes("What do you want to exchange for 1 Gold Coin?"); .@selection1 = select(.menu_option1$, .menu_option2$, .menu_option3$); mesclear(); mes(.npc_name$); if (countitem(Silver_Coin) < 1) { mes("You need at least 1 Silver Coin."); close(); } switch (.@selection1) { case 1: if (Zeny < 500) { mes("You need at least 500z."); close(); } break; case 2: if (#CASHPOINTS < 10) { mes("You need at least 10 Cash Points."); close(); } break; case 3: if (countitem(Poring_Coin) < 1) { mes("You need at least 1 Poring Coin."); close(); } break; } mes("Are you sure?"); .@selection2 = select("Yes", "No"); mesclear(); mes(.npc_name$); if (.@selection2 == 2) { mes("Okay, see you."); close(); } delitem(Silver_Coin, 1); switch (.@selection1) { case 1: // 20% success chance. .@failed = (rand(10000) < 8000) ? 1 : 0; Zeny -= 500; break; case 2: // 50% success chance. .@failed = (rand(10000) < 5000) ? 1 : 0; #CASHPOINTS -= 10; break; case 3: // 90% success chance. .@failed = (rand(10000) < 1000) ? 1 : 0; delitem(Poring_Coin, 1); break; } if (.@failed == 1) { mes("Sorry, you had no luck."); } else { mes("You're a lucky person and obtain 1 Gold Coin."); getitem(Gold_Coin, 1); } close(); OnInit: .npc_name$ = "[" + strnpcinfo(NPC_NAME_VISIBLE) + "]"; .menu_option1$ = "1 Silver Coin + 500z (20% chance)"; .menu_option2$ = "1 Silver Coin + 10 Cash Points (50% chance)"; .menu_option3$ = "1 Silver Coin + 1 Poring Coin (90% chance)"; end; }



prontera,150,170,0	script	Coin Exchange	4_F_KAFRA5,{
	mes(.npc_name$);
	mes("What do you want to exchange for 1 Gold Coin?");

	.@selection1 = select(.menu_option1$, .menu_option2$, .menu_option3$);

	mesclear();
	mes(.npc_name$);

	if (countitem(Silver_Coin) < 1) {
		mes("You need at least 1 Silver Coin.");
		close();
	}

	switch (.@selection1) {
	case 1:
		if (Zeny < 500) {
			mes("You need at least 500z.");
			close();
		}
		break;
	case 2:
		if (#CASHPOINTS < 10) {
			mes("You need at least 10 Cash Points.");
			close();
		}
		break;
	case 3:
		if (countitem(Poring_Coin) < 1) {
			mes("You need at least 1 Poring Coin.");
			close();
		}
		break;
	}

	mes("Are you sure?");

	.@selection2 = select("Yes", "No");

	mesclear();
	mes(.npc_name$);

	if (.@selection2 == 2) {
		mes("Okay, see you.");
		close();
	}

	delitem(Silver_Coin, 1);

	switch (.@selection1) {
	case 1: // 20% success chance.
		.@failed = (rand(10000) < 8000) ? 1 : 0;
		Zeny -= 500;
		break;
	case 2: // 50% success chance.
		.@failed = (rand(10000) < 5000) ? 1 : 0;
		#CASHPOINTS -= 10;
		break;
	case 3: // 90% success chance.
		.@failed = (rand(10000) < 1000) ? 1 : 0;
		delitem(Poring_Coin, 1);
		break;
	}

	if (.@failed == 1) {
		mes("Sorry, you had no luck.");
	} else {
		mes("You're a lucky person and obtain 1 Gold Coin.");
		getitem(Gold_Coin, 1);
	}

	close();



OnInit:
	.npc_name$ = "[" + strnpcinfo(NPC_NAME_VISIBLE) + "]";
	.menu_option1$ = "1 Silver Coin + 500z (20% chance)";
	.menu_option2$ = "1 Silver Coin + 10 Cash Points (50% chance)";
	.menu_option3$ = "1 Silver Coin + 1 Poring Coin (90% chance)";
	end;
}

 

 

 

~Kenpachi

Thanks my idol @Kenpachi

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...
Sign in to follow this  

×
×
  • Create New...

Important Information

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