Jump to content
  • 0

Easier way to script this?


Kurby

Question


  • Group:  Members
  • Topic Count:  37
  • Topics Per Day:  0.01
  • Content Count:  113
  • Reputation:   1
  • Joined:  07/15/12
  • Last Seen:  

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
Link to comment
Share on other sites

14 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  46
  • Topics Per Day:  0.01
  • Content Count:  147
  • Reputation:   26
  • Joined:  11/19/11
  • Last Seen:  

u mean like this?

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

chelm:

blabla

ddust:

script here

bye:

mes "Bye";

close;

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  37
  • Topics Per Day:  0.01
  • Content Count:  113
  • Reputation:   1
  • Joined:  07/15/12
  • Last Seen:  

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

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  46
  • Topics Per Day:  0.01
  • Content Count:  147
  • Reputation:   26
  • Joined:  11/19/11
  • Last Seen:  

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.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  37
  • Topics Per Day:  0.01
  • Content Count:  113
  • Reputation:   1
  • Joined:  07/15/12
  • Last Seen:  

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;

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  46
  • Topics Per Day:  0.01
  • Content Count:  147
  • Reputation:   26
  • Joined:  11/19/11
  • Last Seen:  

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

just this will work

Edited by Mavis
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  56
  • Reputation:   30
  • Joined:  02/22/12
  • Last Seen:  

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.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  37
  • Topics Per Day:  0.01
  • Content Count:  113
  • Reputation:   1
  • Joined:  07/15/12
  • Last Seen:  

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
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  46
  • Topics Per Day:  0.01
  • Content Count:  147
  • Reputation:   26
  • Joined:  11/19/11
  • Last Seen:  

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;
}

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  56
  • Reputation:   30
  • Joined:  02/22/12
  • Last Seen:  

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.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  46
  • Topics Per Day:  0.01
  • Content Count:  147
  • Reputation:   26
  • Joined:  11/19/11
  • Last Seen:  

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

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  56
  • Reputation:   30
  • Joined:  02/22/12
  • Last Seen:  

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;
 }
}

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  46
  • Topics Per Day:  0.01
  • Content Count:  147
  • Reputation:   26
  • Joined:  11/19/11
  • Last Seen:  

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

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  56
  • Reputation:   30
  • Joined:  02/22/12
  • Last Seen:  

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
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  46
  • Topics Per Day:  0.01
  • Content Count:  147
  • Reputation:   26
  • Joined:  11/19/11
  • Last Seen:  

im sorry. i think yours is easier :)

Link to comment
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.   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.

×
×
  • Create New...