Jump to content
  • 0
Helena

This script with this function? Arrays with next page.

Question

Hi Hercules!

 

I have this script (see below) and I was wondering if someone perhaps knows how to add the function in it that this person is asking for - I know it's a rAthena thread, but my request is literally the same, I just can't figure it out because both scripts I'm using are already complicated (for me).

 

Would it work with Arrays? Currently, my script has over 128 items in its arrays and so it drops of the last few IDs (doesnt regocnize), and I hoped that perhaps throwing in a "next page" option would fix this issue. Would it?

 

Any help would be greatly appreciated!

 

 

 

Indoor2,52,50,4	script	Custom Headgear Trader	797,{    mes "[Custom Headgear Trader]";    mes "Hello " +strcharinfo(0)+ ", I can exchange your Custom Headgear. That means if you're ever bored of your current Custom Headgear sprite, I can easily give you another!";    next;    mes "[Custom Headgear Trader]";    mes "This service however is not free, if you want to change your Custom Headgear, I require:";	mes "1x Custom Headgear";	mes "3x Cash Points";    next;      if (select("Continue, please.:I'm not interested.") - 1) close;	if(#CASHPOINTS < 3) {        mes "[Custom Headgear Trader]";        mes "I'm sorry You do not meet the requirements. For you to use my service, I need 3 Cash Points and a Custom Headgear.";        close;    }      mes "[Custom Headgear Trader]";    mes "Very well, let's proceed with the process. Select the Customized Headgear that you want to exchange:";    getinventorylist;    for (.@i = 0; .@i < @inventorylist_count; .@i++) {                if (compare(.itemidcompare$, ":"+ @inventorylist_id[.@i] +":" ) ) {                        .@menu$ = .@menu$ + getitemname( @inventorylist_id[.@i] ) +":";                        .@select[ .@c ] = @inventorylist_id[.@i];                        .@c++;                }        }      if (.@c == 0) {	sleep2 2000;        mes "...Oh, it appears that you have no Custom Headgear, sorry but I can't help you.";        close;    }        .@pickid = .@select[select(.@menu$) - 1];    mes "You've selected your ^FF0000" +getitemname(.@pickid)+ "^000000, is that correct?";    if (select("Yes, it is.:No.") - 1) close;	next;    mes "[Custom Headgear Trader]";    mes "Very well then, now select the item you want to exchange your " +getitemname(.@pickid)+ " for:";	mes "^FF0000To see a list of available sprites, please talk to the Headgear NPC!^000000";    .@menu$ = getitemname(.itemid);    for (.@i = 1; .@i < .itemidsize; .@i++)         .@menu$ = .@menu$ + ":" + getitemname(.itemid[.@i]);        .@tradeid = .itemid[select( .@menu$ ) -1];	next;        mes "[Custom Headgear Trader]";        mes "Please confirm that you want to use 3 Cash Points for trading your ^FF0000" +getitemname(.@pickid) + "^000000 for a ^FF0000" + getitemname(.@tradeid)+ "^000000:";        next;        if (select("Confirm:Cancel") - 1) close;        if (countitem(.@pickid) == 0 || #CASHPOINTS < 3) {            mes "[Custom Headgear Trader]";            mes "It appears that you don't meet the requirements. In order to use my service, you need to have a Custom Headgear and 3 Cash Points.";            close;        }    getinventorylist;        for(set .@i,0; .@i < @inventorylist_count; set .@i,.@i+1){            if( @inventorylist_id[.@i] == .@pickid ) {                set .@refine_rate, @inventorylist_refine[.@i];            }        }        delitem .@pickid, 1;	if ( !.@refine_rate )         getitem .@tradeid, 1;    else         getitem2 .@tradeid,1,1,.@refine_rate,0,@card1,@card2,@card3,@card4;        //getitem .@tradeid, 1;        set #CASHPOINTS,#CASHPOINTS - 3;        mes "[Custom Headgear Trader]";        mes "===================================";        mes "Official Receipt";        mes "===================================";        mes "From : " +getitemname(.@pickid);        mes "To : " +getitemname(.@tradeid);        mes "===================================";	dispbottom "3 Cash Points have been deducted. Current Balance = "+#CASHPOINTS+" Cash Points.";        next;        mes "[Custom Headgear Trader]";        mes "Thank you for using my Custom Headgear trading system, " +strcharinfo(0)+ ". Have a nice day!";        close;      OnInit:            setarray .itemid,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,8066,8067,8068,8069,8070,8071,8072,8073,8074,8075,8076,8077,8078,8079,8080,8081,8082,8083,8084,8085,8086,8087,8094,8095,8098,8100,8102,8103,8104,8105,8106,8107,8108,8109,8110,8111,8112,8113,8114,8115,8116,8112,8117,8118,8119,8120,8121,8122,8123,8124,8125,8126,8127,8128,8130,8131,8132,8133,20051,20052,20053,20054,20055,20056,20057,20058,20059,20060,20061,20062,20063,20064,20065,20066,20067,20068,20069,20070,20071,20072,20073,20074,20075,20076,20077; // Put all Headgear's here             set .itemidsize, getarraysize( .itemid );            set .itemidcompare$, ":"+ .itemid[0];            for ( .@i = 1; .@i < .itemidsize; .@i++ )                    .itemidcompare$ = .itemidcompare$ +":"+ .itemid[.@i] +":";            end;}		} 

Share this post


Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0

If you insist on going about the "Next Page" route, you could just use multiple arrays; for example, "page 1" would use the array .page_1[0] and "page 2" would use the array .page_2[0]. Personally, I'd organize the custom items into separate categories or tiers, and have them exchanged that way. You could also try using multiple for loops.

 

Here's a little sample of using the "next page" idea with multiple arrays; it's heavily commented, but feel free to ask any questions.

 

prontera,150,150,5    script    Pages Sample::pages_sample    999,{    do    // Loop while no confirmation trigger received    {        // Reset page number        @page_num = 0;                do    // Loop while next page trigger is received        {            // Clear "next page" trigger            @next_page = 0;                        // Clear last page's options            .@options$ = "";                        // Increment page number            @page_num++;                        // End session if max page reached            if (@page_num > .max_option)            {                mes .npc_name$;                mes "Come back soon!";                close;            }                        // Intro Dialogue            mes .npc_name$;            mes "Please select an item you would like.";            next;                        // Build menu options            for (.@i = 0; .@i < getarraysize(getd(".page_"+ @page_num)); .@i++)            {                // Add next option in index to previous option                .@options$ = .@options$ + getitemname(getd(".page_"+ @page_num +"["+ .@i +"]")) + ":";            }                        // Choose option            if (@page_num < .num_pages)                menu .@options$ + "^008800Next page^000000",-;            else                menu .@options$ + "^FF0000End session^000000",-;                        // Set next page trigger if it was chosen            if (@menu > .max_option)                @next_page++;                    } while (@next_page);                // Set index        @i = @menu - 1;                // Confirmation Dialogue        mes .npc_name$;        mes "You've selected "+ getitemname(getd(".page_"+ @page_num +"["+ @i +"]")) +", correct?";        next;                // Set confirmation trigger        if (select("That is correct:No, let me choose again") < 2)            @confirm_option++;                } while (!@confirm_option);        // Receive selected item    getitem getd(".page_"+ @page_num +"["+ @i +"]"), .amount;        // Receipt Dialogue    mes .npc_name$;    mes "Here you go! Enjoy!";    close;        OnWhisperGlobal:        // Whisper anything to 'npc:pages_sample' to initialize settings (older emulators)        message strcharinfo(0), strnpcinfo(1) +" : 'OnInit' label has been intialized.";            OnInit:        // NPC's name        .npc_name$ = "[Pages Sample]";                // Max options per page        .max_option = 5;                // Number of pages        .num_pages = 2;            // Item IDs with corresponding pages        setarray .page_1[0], 909, 910, 911, 912, 913;        setarray .page_2[0], 914, 915, 916, 917, 918;                // Global amount to receive        .amount = 1;                end;        }

Share this post


Link to post
Share on other sites

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...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.