viewing paste topic/4516- multiple exchanger | Athena

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
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;
}
Viewed 1323 times, submitted by AnnieRuru.