Jump to content
  • 0
Sign in to follow this  
Aaeru

Problem with next and previous page.

Question

Hi Hercules!

 

I'm using a nice script that trades costumes for costumes. But I'm having a problem with the next and previous page options.

 

This is what's buggy:

 

- If I click previous page in the menu, it does next page instead.

- If I click previous page on the LAST page (when there are no further items to show), it closes the window.

 

Can you please help me fix it? And if its not too much to ask, tell me which lines should be changed please? I don't want to replace the whole script because it's part of something bigger (for which I need my local (unchanged) text file for it to be functional). I would like to make line adjustments 1 by 1, please? I learn more that way. :)

 

Thanks so much! Forever grateful! ^^

 

 

prontera,156,188,3    script    Costume Trader    4_M_4THPRIN2,{
function AddItem;
 
    // Preview section
    set @topview, getlook(4);
    
    addtimer 3000, strnpcinfo(3)+"::OnLeave";
 
    mes "[Custom Costume Trader]";
    mes "Hello " +strcharinfo(0)+ ", I offer Costume trading services. Sounds nice right?";
    menu "- Trade my Custom Costume for another Costume",-;
    next;
    mes "[Custom Costume Trader]";
    mes "Alright! If you want to change your Custom Costume, I require:";
    mes "1x Custom Costume";
    mes "3x Credit";
    
    if (select("Continue, please.:Not interested.") - 1) close;
 
    next;
    mes "[Custom Costume Trader]";
    mes "Very well, let's proceed with the process. Select the Costume that you want to trade:";
    getinventorylist;
    for (.@i = 0; .@i < @inventorylist_count; .@i++) {
        if ( getiteminfo( @inventorylist_id[.@i],5 ) & ( 1|256|512 ) == 0 ) continue;// not an Costume
        for ( .@j = 0; .@j <= .num_total/128; .@j++ ) {
            if ( compare( getd( ".itemidcompare"+ .@j +"$" ), ":"+ @inventorylist_id[.@i] +":" ) ) {
                setd ".@arraymenu_"+ ( .@count/25 ) +"$["+ ( .@count%25 ) +"]", getitemname( @inventorylist_id[.@i] );
                setd ".@itemid_"+ ( .@count/25 ) +"["+ ( .@count%25 ) +"]", @inventorylist_id[.@i];
                setd ".@refine_"+ ( .@count/25 ) +"["+ ( .@count%25 ) +"]", @inventorylist_refine[.@i];
                setd ".@attribute_"+ ( .@count/25 ) +"["+ ( .@count%25 ) +"]", @inventorylist_attribute[.@i];
                setd ".@identify_"+ ( .@count/25 ) +"["+ ( .@count%25 ) +"]", @inventorylist_identify[.@i];
                setd ".@card1_"+ ( .@count/25 ) +"["+ ( .@count%25 ) +"]", @inventorylist_card1[.@i];
                setd ".@card2_"+ ( .@count/25 ) +"["+ ( .@count%25 ) +"]", @inventorylist_card2[.@i];
                setd ".@card3_"+ ( .@count/25 ) +"["+ ( .@count%25 ) +"]", @inventorylist_card3[.@i];
                setd ".@card4_"+ ( .@count/25 ) +"["+ ( .@count%25 ) +"]", @inventorylist_card4[.@i];
                .@count++;
            }
        }
    }
    if ( .@count == 0 ) {
        sleep2 2000;
        mes "It appears that you have no Costume, sorry but I can't help you.";
        close;
    }
    
    if(countitem(501) < 3) {
        mes "[Custom Costume Trader]";
        mes "IYou do not meet the requirements. For you to use my service, I need 3 Credit and a Costume.";
        close;
    }
    
    while(1) {
        .@menu$ = ( .@page ? "^777777Previous Page^000000:" : ":" ) + implode( getd( ".@arraymenu_"+ .@page +"$" ), ":" ) + ( .@page == .@count/25 ? "":":^777777Next Page^000000" );
        .@s = select( .@menu$ ) -2;
        if ( .@s == -1 && .@page )
            .@page--;
        else if ( .@s == 25 )
            .@page++;
        else
            break;
    }
        
    .@item_name$ = getd( ".@arraymenu_"+ .@page +"$["+ .@s +"]" );
    .@myitem_id = getd( ".@itemid_"+ .@page +"["+ .@s +"]" );
    mes "You've selected your ^FF0000" + getd( ".@arraymenu_"+ .@page +"$["+ .@s +"]" ) + "^000000, is that correct?";
    next;
    if (select("Yes, it is.:No.") - 1) close;
    
    if( getequipname(EQI_HEAD_TOP) != ""){
        sleep2 100;
        next;
        mes "[Custom Costume Trader]";
        mes "Make sure you don't have anything equipped in your top headgear slot first! I can't properly let you preview otherwise!";
        close;
    }
    
    mes "[Custom Costume Trader]";
    mes "Very well then, now select the Costume you want to exchange your " + .@item_name$ + " for:";
    mes "^FF0000Your character will be wearing a preview of the selected Custom Costume!^000000";
    
L_Menu:
next;
    for ( .@j = 0; .@j < .num_total; .@j += 25 ) {
        .@menu$ = ( .@j/25 ? "^777777Previous Page^000000:" : ":" );
        for ( .@i = .@j; .@i < .@j +25; .@i++ ) {
            .@item_id = getd( ".itemid"+ ( .@i/128 ) +"["+ ( .@i%128 ) +"]" );
            if ( .@item_id )
                .@item_name2$ = getitemname( .@item_id );
            else
                .@item_name2$ = ":";
            .@menu$ = .@menu$ + .@item_name2$ +":";
        }
        .@menu$ = .@menu$ + ( .@j/25 != .num_total/25 ? "^777777Next Page^000000" : "" );
        .@s2 = select( .@menu$ ) -2;
        if ( .@s2 == -1 && .@j/25 )
            .@j -= 20;
        else if ( .@s2 != 25 )
            break;
    }
    .@tradeid = getd( ".itemid"+ ( ( .@j + .@s2 ) /128 ) +"["+ ( .@j + .@s2 )%128 +"]" );
        
    if(.@tradeid == 0)
    close;
    
    set @equip, getiteminfo(.@tradeid, 5);
    set @view, getiteminfo(.@tradeid, 11);
    atcommand "@changelook 1 " + @view;
 
    .@item_name$ = getd( ".@arraymenu_"+ .@page +"$["+ .@s +"]" );
    .@myitem_id = getd( ".@itemid_"+ .@page +"["+ .@s +"]" );
    
    mes "[Custom Costume Trader]";
    mes "Please confirm that you want to use 500 Credit for trading your ^FF0000" + .@item_name$ + "^000000 for a";
    mes "<ITEMLINK>"+ getitemname(.@tradeid)+"<INFO>"+ .@tradeid +"</INFO></ITEMLINK>:";
 
    if (select("Confirm:I would like trying another Costume!") - 1) goto L_Menu;
    if (countitem( .@myitem_id ) == 0 || countitem(32744) < 500) {
        mes "[Custom Costume Trader]";
        mes "It appears that you don't meet the requirements. In order to use my service, you need to have a Custom Costume and 500 Credit.";
        close;
    }
    .@identify = getd( ".@identify_"+ .@page +"["+ .@s +"]" );
    .@refine = getd( ".@refine_"+ .@page +"["+ .@s +"]" );
    .@attribute = getd( ".@attribute_"+ .@page +"["+ .@s +"]" );
    .@card1 = getd( ".@card1_"+ .@page +"["+ .@s +"]" );
    .@card2 = getd( ".@card2_"+ .@page +"["+ .@s +"]" );
    .@card3 = getd( ".@card3_"+ .@page +"["+ .@s +"]" );
    .@card4 = getd( ".@card4_"+ .@page +"["+ .@s +"]" );
    delitem2 .@myitem_id,1, .@identify, .@refine, .@attribute, .@card1, .@card2, .@card3, .@card4;
    getitem2 .@tradeid,1, .@identify, .@refine, .@attribute, .@card1, .@card2, .@card3, .@card4;
 
    delitem 501,3;
    
    next;
    
    mes "[Custom Costume Trader]";
    mes "It has been done! Your Custom Costume has been changed for a different sprite! ";
    mes " ";
    mes "From : " + .@item_name$;
    mes "To : " +getitemname(.@tradeid);
    dispbottom "3 Credit have been deducted. Current Balance = "+countitem(501)+" Credit.";
    next;
    mes "[Custom Costume Trader]";
    mes "Thank you for using the XTraLifeRO Custom Costume trading system, " +strcharinfo(0)+ "!";
    close;
 
OnInit:
    AddItem( 8003,8005,8006,8015,8016,8017,8018,8019,8020,8021,8022,8023,8024,8025,8026,8027,8028,8029,8030,8031,8032,8033,8034,8035,8036,8037,8038,8039,8040,8041,8042,8043,8044,8045,8046,8047,8052,8053,8054,8055,8056,8057,8058,8059,8060,8062,8063,8064,8065 );
    AddItem( 8066,8067,8068,8069,8070,8071,8072,8073,8074,8075,8076,8077,8078,8079,8080,8081,8082,8083,8084,8085,8086,8087,8090,8094,8095,8099,8100,8102,8103,8104,8105,8106,8107,8108,8109,8110,8111,8112,8113,8114,8115,8116,8117,8118,8119,8120,8121 );
    AddItem( 8122,8123,8124,8125,8126,8127,8128,8129,8130,8131,8132,8133,8154,8157,8158,8159,8160,8161,8162,8163,8164,8165,8166,8167,8168,8169,8171,8175,8176,8177,8178,8181,8183,8185,8186,8188,8192,8193,8194,8195,8196,8197,8201,8205,8206,8207,8208,8209,8210,8212,8213,17777 );
    AddItem( 19000,19001,19002,19003,19005,19006,19007,19008,19009,19010,19011,19012,19013,19015,19016,19017,19018,19019,19020,19021,19022,19023,19024,19025,19026,19027,19028,19030,19031,19046,19049,19050,19051,19052,19053,19055,19056,19057,19058,19059,19060,19061,19062,19063,19064,19065,19066,19067 );
    AddItem( 19068,19069,19075,19076,19085,19090,19091,19095,19098,19100,19105,19109,19113,19120,19129,19134,19137,19139,19140,19141,19142,19143,19146,19149,19150,19156,19160,19162,19163,19164,19165,19166,19168,19175,19179,19180,19181,19185,19187,19191,19192,19195,19197,19202,19203,19204,19205,21064,21082,21117,21179,21183,25018,25037 );
    AddItem( 31027,31028,31029,31030,31031,31032,31033,31034,31035,31249,31250,31252,31253,31254,31255,31256,31257,31258,31283,31284,31285,31286,31287,31288,31289,31290,31291,31292 );
 
function AddItem {
    .@amount = .num_total + getargcount();
    .@i = .@tmp = .num_total;
    while( .@i < .@amount ) {
        .@arg = getarg( .@i - .@tmp );
        if ( getitemname( .@arg ) != "NULL" ) {
            setd ".itemid"+ ( .num_total/128 ) +"["+ ( .num_total%128 ) +"]", .@arg;
            setd ".itemidcompare"+ ( .num_total/128 ) +"$", getd( ".itemidcompare"+ ( .num_total/128 ) +"$" ) +":"+ .@arg;
            .num_total += 1;
            if ( .num_total%128 == 0 )
                setd ".itemidcompare"+ ( .num_total/128 -1 ) +"$", getd( ".itemidcompare"+ ( .num_total/128 -1 ) +"$" ) +":";
            else if ( .num_total == .@amount )
                setd ".itemidcompare"+ ( .num_total/128 ) +"$", getd( ".itemidcompare"+ ( .num_total/128 ) +"$" ) +":";
        }
        .@i++;
    }
}
 
OnLeave:
    atcommand "@changelook 1 " + @topview;
    end;
}

Share this post


Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

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.