Jump to content
  • 0
ToiletMaster

Shortening this script

Question

Hi Guys,

 

Here's one part of the script that i made, i was thinking of methods of shortening this, would there be anyway? as the 2nd part of the case is all duplicated except for the item IDs.

 

I'm not really good with arrays, so if someone could provide me an example, I'd be really grateful!

 

 

 

       	 if(baselevel >= 5 && novice_ground == 1) {            mes ""+.npc_name$+"";            mes "Good job Leveling up! Go on! Take one item from my stash! It's on me!";            next;            switch(select("Cutter:Falchion:Mace:Main Gauche")){                                case 1:                mes ""+.npc_name$+"";                mes "You've selected ^FF0000Cutter^000000.";                mes "Are you sure?";                next;                switch(select("Yes:No")){                                                case 1:                        mes ""+.npc_name$+"";                        mes "Here you go!";                        getitem 13040,1;                        set novice_ground, 2;                        close;                                                case 2:                        mes ""+.npc_name$+"";                        mes "Come back once you've decided!";                        close;                                                        }                                    case 2:                mes ""+.npc_name$+"";                mes "You've selected ^FF0000Falchion^000000.";                mes "Are you sure?";                next;                switch(select("Yes:No")){                                                                case 1:                        mes ""+.npc_name$+"";                        mes "Here you go!";                        getitem 13415,1;                        set novice_ground, 2;                        close;                                                case 2:                        mes ""+.npc_name$+"";                        mes "Come back once you've decided!";                        close;                                                }                                case 3:                mes ""+.npc_name$+"";                mes "You've selected ^FF0000Mace^000000.";                mes "Are you sure?";                next;                switch(select("Yes:No")){                                                                case 1:                        mes ""+.npc_name$+"";                        mes "Here you go!";                        getitem 1545,1;                        set novice_ground, 2;                        close;                                                case 2:                        mes ""+.npc_name$+"";                        mes "Come back once you've decided!";                        close;                                                }                                case 4:                mes ""+.npc_name$+"";                mes "You've selected ^FF0000Main Gauche^000000.";                mes "Are you sure?";                next;                switch(select("Yes:No")){                                                                case 1:                        mes ""+.npc_name$+"";                        mes "Here you go!";                        getitem 13041,1;                        set novice_ground, 2;                        close;                                                case 2:                        mes ""+.npc_name$+"";                        mes "Come back once you've decided!";                        close;                                            }                                }            }

 

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0
            if(baselevel >= 5 && novice_ground == 1) {				mes ""+.npc_name$+"";				mes "Good job Leveling up! Go on! Take one item from my stash! It's on me!";				next;				.@menu$ = "";				for (.@i=0; .@i<getarraysize(.items); .@i++){					.@menu$ = (.@menu$)+""+getitemname(.items[.@i])+":";				}				.@menu$ = (.@menu$)+"Cancel";				.@item_selected = select(.@menu$);				if (.@item_selected > getarraysize(.items)){close;}				next;				mes ""+.npc_name$+"";				mes "You've selected ^FF0000"+getitemname(.items[(.@item_selected)-1])+"^000000.";				mes "Are you sure?";				next;				switch(select("Yes:No")){					case 1:					mes ""+.npc_name$+"";					mes "Here you go!";					getitem .items[(.@item_selected)-1],1;					set novice_ground, 2;					close;										case 2:					mes ""+.npc_name$+"";					mes "Come back once you've decided!";					close;									}			}

And at OnInit:

OnInit:	setarray .items[0],13040,13415,1545,13041;	end;
Edited by Dastgir Pojee

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.