Jump to content
  • 0

Converter NPC


Question

Posted

Sir this is my ygg converter -> berry tickets.

prontera,155,181,5 script Yggdrasil Exchanger 757,{

set .@ItemID,607;

set .@BoxID,6185;

if( countitem(607) < 50 )

mes "Sorry, But you don't have "+getitemname( .@ItemID )+";

else{

if( countitem( .@ItemID ) >= 50 ){

mes "How many Yggdrasil Berry will be traded into "+getitemname( .@BoxID )+"?";

input .@Count,0,countitem( .@ItemID );

set .@Amount,( .@Count / 50 );

next;

delitem .@ItemID,( .@Amount * 50 );

getitem .@BoxID,.@Amount;

mes "Congratulations! You received "+getitemname( .@BoxID )+"!";

}

}

close;

}

What i want to have is there would be two options to choose from.

one is from:

YGG -> Berry Tickets

and the other from:

Berry Tickets --> YGG

Thankyou sir

DOes anyone have this?

9 answers to this question

Recommended Posts

Posted

Yes sir I've used your script. But my problem is I want to make two choices.

Berry -> berry tickets

berry tickets -> TCG

That script only makes Berry -> berry tickets

Because ive tried editing your script but nothing works.

Posted

Ive tried sir

prontera,155,181,5 script Sample 757,{

function Exchange;

switch( select( "Yggdrasilberry",

"Royal Jelly",

"etc..." )){

// Exchange( <Item Gained>,<Amount>,<Item Required>,<Amount> );

Case 1: Exchange( 13517,1,607,100 ); break;

Case 2: Exchange( 13516,5,526,50 ); break;

Case 3: Exchange( 12997,10,757,10 ); break;

default:

mes "Wrong Selection"; break;

}

close;

function Exchange {

mes "Exchange "+getarg(3)+" "+getitemname( getarg(2) )+" into "+getarg(1)+" "+getitemname( getarg(0) )+"?";

if( select("Yes:No") == 1 ){

if( countitem( getarg(2) ) < getarg(3) ){

mes "Sorry you didnt have enough Items to trade.";

break;

}else{

mes "Done";

delitem getarg(2),getarg(3);

getitem getarg(0),getarg(1);

}

}

return;

}

}

But when i tried to reload it. I cant talk to the NPC

Posted (edited)

wow ... at 1st I thought this is simple script ...

but suddenly struck me an idea to use this as dynamic shop ...

... let me test some algorithm ...

prontera,155,179,5	script	kjdhfkjshf	100,{
mes "this is an exchanger shop";
mes "make sure you selected 2 items";
close2;
callshop "testshop", 1;
end;
OnBuyItem:
if ( getarraysize( @bought_nameid ) != 2 ) {
	mes "please select only 2 items";
	close;
}
while ( .@i < 2 ) {
	while ( @bought_nameid[.@i] != .exchange_list[ .@j[.@i] ] && .@j[.@i] < .shop_size ) .@j[.@i] += 2;
	if ( .@j[.@i] >= .shop_size ) end; // error
	.@i++;
}
mes "selected :-";
mes .exchange_list[ .@j[0] +1 ]+"x "+ getitemname( .exchange_list[ .@j[0] ] );
mes .exchange_list[ .@j[1] +1 ]+"x "+ getitemname( .exchange_list[ .@j[1] ] );
next;
.@s = select (
	.exchange_list[ .@j[0] +1 ]+"x "+ getitemname( .exchange_list[ .@j[0] ] ) +" -> "+ .exchange_list[ .@j[1] +1 ]+"x "+ getitemname( .exchange_list[ .@j[1] ] ),
	.exchange_list[ .@j[1] +1 ]+"x "+ getitemname( .exchange_list[ .@j[1] ] ) +" -> "+ .exchange_list[ .@j[0] +1 ]+"x "+ getitemname( .exchange_list[ .@j[0] ] ) ) -1;	
mes "selected :-";
mes .exchange_list[ .@j[.@s] +1 ]+"x "+ getitemname( .exchange_list[ .@j[.@s] ] ) +" -> "+ .exchange_list[ .@j[!.@s] +1 ]+"x "+ getitemname( .exchange_list[ .@j[!.@s] ] );
mes " ";
if ( countitem( .exchange_list[ .@j[.@s] ] ) < .exchange_list[ .@j[.@s] +1 ] ) {
	mes "not enough "+ getitemname( .exchange_list[ .@j[.@s] ] );
	close;
}
mes "input the amount that you can change";
mes "max = "+( .@max = countitem( .exchange_list[ .@j[.@s] ] ) / .exchange_list[ .@j[.@s] +1 ] );
next;
if ( input( .@input, 1, .@max ) ) {
	mes "invalid amount";
	close;
}
delitem .exchange_list[ .@j[.@s] ], .@input * .exchange_list[ .@j[.@s] +1 ];
getitem .exchange_list[ .@j[!.@s] ], .@input * .exchange_list[ .@j[!.@s] +1 ];
close;
OnInit:
setarray .exchange_list,
	501, 1, // rate of exchange, 1x red potion
	502, 1,
	503, 5; // rate of exchange, 5x yellow potions

npcshopdelitem "testshop", 501;
.shop_size = getarraysize( .exchange_list );
for ( .@i = 0; .@i < .shop_size; .@i += 2 )
	npcshopadditem "testshop", .exchange_list[.@i], .exchange_list[.@i +1];
npcshopattach "testshop";
end;
}
-	shop	testshop	-1,501:1000

hehehe ... sry emistry /sry

Edited by AnnieRuru
Posted (edited)

So, I want to get into this too.

prontera,100,100,4	script	Converter	100,{

mes "hi there.";
mes "select which item do you want to exchange.";
for ( set .@size, getarraysize ( .@items ); .@i < .@size ; set .@i, .@i + 4 )
{
	if ( countitem ( .items[.@i] ) )
	{
		set .@color$, ( ( countitem ( .items[.@i] ) < .items[.@i + 1] ) ? "^ff0000" : "^00ff00" );
		set .@menu$, .@color$ + .@menu$ + getitemname ( .items[.@i] ) +":";
		set .@m$[.@j], "1x"+ .@i;
		set .@j, .@j + 1;
	}
	if ( countitem ( .items[.@i + 2] ) )
	{
		set .@color$, ( ( countitem ( .items[.@i + 2] ) < .items[.@i + 3] ) ? "^ff0000" : "^00ff00" );
		set .@menu$, .@color$ + .@menu$ + getitemname ( .items[.@i + 2] ) +":";
		set .@m$[.@j], "2x"+ .@i;
		set .@j, .@j + 1;
	}
}
next ;
set .@s, select ( .@menu$ ) - 1;
explode .@array$, .@m$[.@s], "x";
set .@type, atoi ( .@array$[0] );
set .@item, atoi ( .@array$[1] );
if ( countitem ( .items[.@item + (.@type/2)*2] ) < .items[.@item + ((.@type + 1)/3)*3 + .@type%2] )
	mes "sorry, you don't have the required.";
else
{
	mes "how much?";
	input .@n;
	set .@req, .@n * .items[.@item + ((.@type + 1)/3)*3 + .@type%2];
	if ( .@req > countitem ( .items[.@item + (.@type/2)*2 )
		set .@n, countitem ( .items[.@item + (.@type/2)*2] ) / .items[.@item + ((.@type + 1)/3)*3 + .@type%2];
	delitem .items[.@item + (.@type/2)*2], .@req;
	getitem .items[(.@item + 1)/4 * (.@type % 2)*2], .@n;
	mes "all done.";
}
close;



OnInit:

setarray .items[0],	 501, 10,	// you can exchange this into v
			502, 5 ;	// or this into ^

end ;

I didn't test, and as far as I understand this is a:

x item[amount a] -> y item[amount b]

y item[amount b] -> x item[amount a]

Edited by Emistry
Please use [CODEBOX] or Attachments for long contents.
Posted (edited)

lol,

I fixed your script like this

prontera,155,176,4    script    Converter    100,{

   mes "hi there.";
   mes "select which item do you want to exchange.";
   .@size = getarraysize( .items );
   for ( .@i = 0; .@i < .@size ; set .@i, .@i + 4 )
   {
       if ( countitem ( .items[.@i] ) )
       {
           set .@color$, ( ( countitem ( .items[.@i] ) < .items[.@i + 1] ) ? "^ff0000" : "^00ff00" );
           set .@menu$, .@color$ + .@menu$ + getitemname ( .items[.@i] ) +":";
           set .@m$[.@j], "1x"+ .@i;
           set .@j, .@j + 1;
       }
       if ( countitem ( .items[.@i + 2] ) )
       {
           set .@color$, ( ( countitem ( .items[.@i + 2] ) < .items[.@i + 3] ) ? "^ff0000" : "^00ff00" );
           set .@menu$, .@color$ + .@menu$ + getitemname ( .items[.@i + 2] ) +":";
           set .@m$[.@j], "2x"+ .@i;
           set .@j, .@j + 1;
       }
   }
   next ;
   set .@s, select ( .@menu$ ) - 1;
   explode .@array$, .@m$[.@s], "x";
   set .@type, atoi ( .@array$[0] );
   set .@item, atoi ( .@array$[1] );
   if ( countitem ( .items[.@item + (.@type/2)*2] ) < .items[.@item + ((.@type + 1)/3)*3 + .@type%2] )
       mes "sorry, you don't have the required.";
   else
   {
       mes "how much?";
       input .@n;
       set .@req, .@n * .items[.@item + ((.@type + 1)/3)*3 + .@type%2];
       if ( .@req > countitem ( .items[.@item + (.@type/2)*2] ) )
           set .@n, countitem ( .items[.@item + (.@type/2)*2] ) / .items[.@item + ((.@type + 1)/3)*3 + .@type%2];
       delitem .items[.@item + (.@type/2)*2], .@req;
       getitem .items[(.@item + 1)/4 * (.@type % 2)*2], .@n;
       mes "all done.";
   }
   close;




OnInit:
   setarray .items[0],     501, 1,    // I purposely change this
               502, 1 ;

   end ;
}

I input change 1 red potion into 1 orange potion ...

I get free red potion ... ????

but changing 1 orange potion into 1 red potion is correct though

EDIT:

WOW !!! fun this is an algorithm script !

@KeyWorld wanna join in the fun ? xD

Edited by AnnieRuru
Posted (edited)

Thanks guys! I Already Solved this one..

But i got another request:

here is my script

prontera,144,168,6	script	TCG Exchanger	117,{
		mes "[TCG Exchanger]";
		mes "Hello there.";
		mes "I can change your Berry Tickets and ZileRO Points to TCG or TCG to Premium Tickets and ZileRO Points";
		mes "Which do you need?";
		menu "Berry to Ticket",t_trade, "Ticket to Berry",b_trade, "I dont need anything",-;
		next;
		mes "[TCG Exchanger]";
		mes "Very well, have a nice day.";
		close;
t_trade:
next;
if(countitem(607) < 300) goto t_fail;
//if (checkweight(607,300) == 0 ) goto t_OverWeight;
delitem 607,300;
mes "[berry Changer]";
mes "Ok, here's Your ^0000FFPremium Ticket^000000.";
getitem 25613,1;
close;

t_fail:
next;
mes "[berry Changer]";
mes "I'm terribly sorry, but you do not have enough berry for this ticket.";
next;
mes "[berry Changer]";
mes "Please come back when you have the correct ammount.";
close;

b_trade:
next;
if(countitem(25613) < 1) goto b_fail;
if (checkweight(607,300) == 0 ) goto t_OverWeight;
delitem 25613,1;
mes "[berry Changer]";
mes "Ok, here's Your ^0000FF300 Yggdrasil Berry^000000.";
getitem 607,300;
close;

b_fail:
next;
mes "[berry Changer]";
mes "It seems you don't have that ticket.";
close;

t_Overweight:
next;
mes "[berry Changer]";
mes "It seems you are overweight.";
close;
}

I want two items to be traded 100 Coins and 15 Berry Tickets --> 1 TCG:

and the other:

1 TCG --> 100 Coins and 15 Berry Tickets

Is this possible? I tried experimenting but cant make it work.

Edited by AnnieRuru
use [codebox] if the script > 10 lines
Posted

for dialog, you change yourself

// 674,Mithril_Coin
// 13517,Yggdrasilberry_Box
// 7227,TCG_Card
// 100 coins + 15 berry ticket <-> 1 TCG

prontera,144,168,6    script    TCG Exchanger    117,{
   mes "[TCG Exchanger]";
   mes "Hello there.";
   mes "I can change your Berry Tickets and ZileRO Points to TCG or TCG to Premium Tickets and ZileRO Points";
   mes "Which do you need?";
   menu "Berry to Ticket",t_trade, "Ticket to Berry",b_trade, "I dont need anything",-;
   next;
   mes "[TCG Exchanger]";
   mes "Very well, have a nice day.";
   close;
t_trade:
   next;
   if ( countitem(674) < 100 ) goto t_fail;
   if ( countitem(13517) < 15 ) goto t_fail;
   delitem 674, 100;
   delitem 13517, 15;
   mes "[berry Changer]";
   mes "Ok, here's Your ^0000FFPremium Ticket^000000.";
   getitem 7227, 1;
   close;

t_fail:
   next;
   mes "[berry Changer]";
   mes "I'm terribly sorry, but you do not have enough berry for this ticket.";
   next;
   mes "[berry Changer]";
   mes "Please come back when you have the correct ammount.";
   close;

b_trade:
   next;
   if ( countitem(7227) < 1 ) goto b_fail;
   if ( !checkweight(674,100,13517,15) ) goto t_OverWeight;
   delitem 7227,1;
   mes "[berry Changer]";
   mes "Ok, here's Your ^0000FF300 Yggdrasil Berry^000000.";
   getitem 674,100;
   getitem 13517,15;
   close;

b_fail:
   next;
   mes "[berry Changer]";
   mes "It seems you don't have that ticket.";
   close;

t_Overweight:
   next;
   mes "[berry Changer]";
   mes "It seems you are overweight.";
   close;
}

and algorithm for fun

prontera,155,179,5    script    kjdhfkjshf    100,{
   mes "this is an exchanger NPC";
   .@s = select (
       .exchange_list$[0] +" -> "+ .exchange_list$[1],
       .exchange_list$[1] +" -> "+ .exchange_list$[0] ) -1;
   mes "selected :-";
   mes .exchange_list$[ .@s ];
   mes " -> ";
   mes .exchange_list$[ !.@s ];
   while ( countitem( getd(".exchange_list"+ .@s +"["+ .@i +"]") ) >= getd(".exchange_list"+ .@s +"["+( .@i +1 )+"]" ) && .@i < .size[ .@s ] ) .@i += 2;
   if ( .@i < .size[.@s] ) {
       mes "not enough "+ getitemname( getd(".exchange_list"+ .@s +"["+ .@i +"]") );
       close;
   }
   mes "input the amount that you can change";
   for ( .@i = 0; .@i < .size[ .@s ]; .@i += 2 ) {
       .@tmp[.@c] = countitem( getd(".exchange_list"+ .@s +"["+ .@i +"]") ) / getd(".exchange_list"+ .@s +"["+( .@i +1 )+"]");
       if ( !.@max || .@max > .@tmp[.@c] )
           .@max = .@tmp[.@c];
       .@c++;
   }
   mes "max = "+ .@max;
   next;
   if ( input( .@input, 1, .@max ) ) {
       mes "invalid amount";
       close;
   }
   for ( .@i = 0; .@i < .size[ .@s ]; .@i += 2 )
       delitem getd(".exchange_list"+ .@s +"["+ .@i +"]"), getd(".exchange_list"+ .@s +"["+( .@i +1 )+"]");
   for ( .@i = 0; .@i < .size[ !.@s ]; .@i += 2 )
       getitem getd(".exchange_list"+ !.@s +"["+ .@i +"]"), getd(".exchange_list"+ !.@s +"["+( .@i +1 )+"]");
   close;
OnInit:
   setarray .exchange_list0, 501,1 , 502,2 , 503,3 ;
   setarray .exchange_list1, 504,1 ;

   while ( .@j <= 1 ) {
       .@i = 0;
       .size[.@j] = getarraysize( getd(".exchange_list"+ .@j ) );
       while ( .@i < .size[.@j] ) {
           .exchange_list$[.@j] = .exchange_list$[.@j] + getd(".exchange_list"+ .@j +"["+( .@i +1 )+"]" ) +"x "+ getitemname( getd(".exchange_list"+ .@j +"["+ .@i +"]" ) ) +( ( .@i == .size[.@j] -2 )? "":" + " );
           .@i += 2;
       }
       .@j++;
   }
   end;
}

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.   Paste as plain text instead

  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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...