Request: NPC Exchanger item to Item

Post error if any :

Code:
prontera,150,150,0	script	Sample	100,{	setarray .choices[0],7229,7228,7757;	.size = getarraysize(.choices);	for ( .@i = 0; .@i < .size; .@i++ ) {		.@menu$ += getitemname(.choices[.@i]);		.@menu$ += ":";	}	.@selected = select(.@menu$) - 1;	.npc$ = "["+strnpcinfo(1)+"]";	mes .npc$;	mes "Exchange Rates : ";	mes "1x " +getitemname(.choices[.@selected]);	if ( !.@selected ) {		setarray .req[0],15,7232;		mes .req[0]+ "x " +getitemname(.req[1]);	} else if ( .@selected == 1 ) {		setarray .req[0],10,7231;		mes .req[0]+ "x " +getitemname(.req[1]);	} else {		setarray .req[0],5,7233;		mes .req[0]+ "x " +getitemname(.req[1]);	}	next;	if (select("I have the following requirements:No, thanks") - 1) close;	if ( countitem(.req[1]) < .req[0] ) {		mes .npc$;		mes "You lack requirements";		close;	}	delitem .req[1],.req[0];	getitem .choices[.@selected],1;	mes .npc$;	mes "Thanks for exchanging!";	close;}
 
<header>,{  for( set .@i, 1; .@i < getarraysize(.exchange); set .@i, .@i + 1 ) {    set .@menu$, .@menu$ + " - " + "^0000ff" + getitemname(.exchange[.@i]) + "^000000";    set .@menu$, .@menu$ + ":"; // build menu.  }    set .@choice, select(.@menu$);    mes "[ "+strnpcinfo(1)+" ]",      "Exchange Rates : ",      "1x " + getitemname(.exchange[.@choice]),      .cost[.@choice]+"x " + getitemname(.requirement[.@choice]);    if ( select( "Exchange", "Later" ) == 2 ) close;    if ( countitem(.requirement[.@choice]) < .cost[.@choice] ) { // count if you have sufficient items to exchange.      mes " ","I need ^ff0000"+ ( .cost[.@choice] - countitem(.requirement[.@choice]) ) + " "+ getitemname(.requirement[.@choice])+ "^000000.";      close;    }    delitem .requirement[.@choice],.cost[.@choice]; // delete item requirements    getitem .exchange[.@choice], 1; // get item    mes " ","Thanks for exchanging!";    close;OnInit: // Config   setarray .exchange[1],7229, 7228, 7757, 501;    // exchange item.  setarray .requirement[1],7232, 7231, 7233,502;  // item requirement.  setarray .cost[1], 5, 10, 15, 20;        // exchange cost.  end;}

or

Code:
<header>,{    for( set .@i, 1; .@i < getarraysize(.exchange); set .@i, .@i + 1 ) {        set .@menu$, .@menu$ + " - " + "^0000ff" + getitemname(.exchange[.@i]) + "^000000";        set .@menu$, .@menu$ + ":"; // build menu.    }        set .@choice, select(.@menu$);        mes "[ "+strnpcinfo(1)+" ]",            "Exchange Rates : ",            .cost[.@choice]+"x ^ff0000" + getitemname(.requirement[.@choice])+ "^000000 is to", "1x ^ff0000" + getitemname(.exchange[.@choice])+"^000000";                    if ( select( "Exchange", "Later" ) == 2 ) close;        mes "How many do you want to exchange?";        input .@input; // input how many items you want to exchange.        if ( countitem(.requirement[.@choice]) < (.cost[.@choice] * .@input ) || .@input == 0) { // count if you have sufficient items to exchange.            mes " ",.@input == 0?"Value is not accepted!":"I need ^ff0000"+ ( (.cost[.@choice] * .@input ) - countitem(.requirement[.@choice]) ) + " "+ getitemname(.requirement[.@choice])+ "^000000.";            close;        }        delitem .requirement[.@choice], (.cost[.@choice] * .@input ); // delete item requirements        getitem .exchange[.@choice], .@input; // get item        mes " ","Thanks for exchanging!";        close;OnInit: // Config    setarray .exchange[1],7229, 7228, 7757;        // exchange item.    setarray .requirement[1],7232, 7231, 7233;    // item requirement.    setarray .cost[1], 5, 10, 15;                 // exchange cost.    end;}
 
Last edited by a moderator:
Back
Top