Jump to content
  • 0

Easier way to script this?


Question

Posted (edited)

How I make it so Whenever someone clicks on selection it goes to somewhere?

Ex.

mes .@n$;
mes "Which Item would you like?";
next; if(select("Cygnus Helmet!:Diamond Dust!:Bye!"))
if(select("Cygnus Helmet!:Diamond Dust!:Bye!")==3) goto M_Leave;
if(select("Cygnus Helmet!:Diamond Dust!:Bye!")==2) goto M_Once;
if(select("Cygnus Helmet!:Diamond Dust!:Bye!")==1) goto M_Twos;

If clicked on "Bye!" go to M_Leave = Exit NPC

If clicked on "Diamond Dust!" go to M_Once = Buying Custom Item

If clicked on "Cygnus Helmet!" go to M_Twos = Buying Another Custom Item

If I use that I have to click many times, unless ()==1), but can't use all for that?

Possible?

mes .@n$;
mes "Which Item would you like?";
next; if(select("Cygnus Helmet!:Diamond Dust!:Bye!"))
if(select("Cygnus Helmet!:Diamond Dust!:Bye!")==1) goto M_Leave;
if(select("Cygnus Helmet!:Diamond Dust!:Bye!")==1) goto M_Once;
if(select("Cygnus Helmet!:Diamond Dust!:Bye!")==1) goto M_Twos;

Edited by Kurby

14 answers to this question

Recommended Posts

Posted

u mean like this?

menu "Cygnus Helm",chelm,"Diamond Dust",ddust,"Bye!",bye;

chelm:

blabla

ddust:

script here

bye:

mes "Bye";

close;

Posted

u mean like this?

menu "Cygnus Helm",chelm,"Diamond Dust",ddust,"Bye!",bye;

chelm:

blabla

ddust:

script here

bye:

mes "Bye";

close;

Would that make the selections 1 click enable? :D

Posted

i dont get what ur trying to say about the 1 click enable ._.

this will show a menu with 3 options. then choose one. and it will redirect u to that option. same as case in if select. but this one is more of a looping menu or skipping-kind of menu.

Posted

i dont get what ur trying to say about the 1 click enable ._.

this will show a menu with 3 options. then choose one. and it will redirect u to that option. same as case in if select. but this one is more of a looping menu or skipping-kind of menu.

I mean if you use "if(select("Cygnus Helmet!:Diamond Dust!:Bye!")==3) goto M_Leave;" You'll have to click "Bye!" option 3 times before it closes the NPC.

How would your format look like? This?

mes .@n$;mes "Which Item would you like?";next; menu "Cygnus Helm",chelm,"Diamond Dust",ddust,"Bye!",bye;

chelm:

goto M_Twos;

ddust:

goto M_Once;

bye:

goto M_Leave;

close;

Posted (edited)

menu "Cygnus Helm",M_Twos,"Diamond Dust",M_Once,"Bye",M_Leave;

just this will work

Edited by Mavis
Posted

Please use the Switch Select method... it's much cleaner and easier to read.

mes .@n$;
mes "Which Item would you like?";
next;
switch(select("Cygnus Helmet!:Diamond Dust!:Bye!")) {
 case 1:
// Your script for buying Cygnus Helmet.
break;
 case 2:
// Your script for buying Diamond Dust.
break;
 case 3:
close;
}

Also... next time please don't post the same topic, regarding the same issue, twice (double post). Lilith gave you the correct answer regarding your question yet you still posted the same issue again ^^; Please avoid double posting.

Posted (edited)

menu "Cygnus Helm",M_Twos,"Diamond Dust",M_Once,"Bye",M_Leave;

just this will work

Thank you, I will test whenever my server gets back up /hmm

Edited by Kurby
Posted

mes .@n$;
mes "Which Item would you like?";
next;
switch(select("Cygnus Helmet!:Diamond Dust!:Bye!")) {
case 1:
// Your script for buying Cygnus Helmet.
goto M_Twos;
break;

case 2:
// Your script for buying Diamond Dust.
goto M_Once;
break;

case 3:
goto M_Leave;
break;
}

Posted

mes .@n$;
mes "Which Item would you like?";
next;
switch(select("Cygnus Helmet!:Diamond Dust!:Bye!")) {
case 1:
// Your script for buying Cygnus Helmet.
goto M_Twos;
break;

case 2:
// Your script for buying Diamond Dust.
goto M_Once;
break;

case 3:
goto M_Leave;
break;
}

You don't need the labels... if he's just processing what item they want all he needs to do is place the code he'd put under those labels after the correct 'Case'.

Labels cause unnecessary clutter in scripts, and make finding code harder. Using Switch statements is highly recommended as you don't need to then hunt down where the Label is to find the code for that selected item in a menu.

Posted

mes .@n$;
mes "Which Item would you like?";
next;
switch(select("Cygnus Helmet!:Diamond Dust!:Bye!")) {
case 1:
// Your script for buying Cygnus Helmet.
goto M_Twos;
break;
case 2:
// Your script for buying Diamond Dust.
goto M_Once;
break;
case 3:
goto M_Leave;
break;
}

You don't need the labels... if he's just processing what item they want all he needs to do is place the code he'd put under those labels after the correct 'Case'.

i know. i think he might want to use a looping kind of style thats why he decided to use goto; ._.

Posted

i know. i think he might want to use a looping kind of style thats why he decided to use goto; ._.

You can do looping without using labels / goto. Use the While loop.

while(1) {
 mes .@n$;
 mes "Which Item would you like?";
 next;
 switch(select("Cygnus Helmet!:Diamond Dust!:Bye!")) {
case 1:
  // Your script for buying Cygnus Helmet.
  break;
case 2:
  // Your script for buying Diamond Dust.
  break;
case 3:
  close;
 }
}

Posted

ok relax it works the same ._. and not really much of a difference, i guess?

Relax? o.O I'm not arguing... This is a Scripting Support forum. I've giving support...

The point of a support forum is to allow people to give the best possible solutions to the person asking for help. If outdated methods are being given then an experienced scripter coming in and giving feedback shouldn't be met with hostility... Development is about sharing methods of how we create things.

Again, was giving feedback / support. Wasn't trying to argue or say your method is bad... it's just not a very clean way of scripting... there's a reason we spent a good time at eAthena converting all the goto / label menus with switch select menus. It's cleaner and easier to read; allows for better debugging.

  • Upvote 1

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.   Paste as plain text instead

  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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...