[Request] Exchanger NPC with successful percentage function

hadiesyafiq

New member
Messages
160
Points
0
Age
35
Location
Malaysia
Github
hadiesyafiq
Emulator
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 

 
Hi.

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






~Kenpachi

 
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?

 
Hi.

Quick'n'dirty:
 

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

 
Last edited by a moderator:
Hi.

Quick'n'dirty:
 

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

 
Back
Top