Selerie Posted December 10, 2022 Group: Members Topic Count: 9 Topics Per Day: 0.01 Content Count: 13 Reputation: 0 Joined: 12/27/21 Last Seen: December 29, 2022 Share Posted December 10, 2022 mes "Monster ID: "+getmonsterinfo(.@mob_id,MOB_NAME)+"'"; if (getmobdrops(.@mob_id)) { // 'getmobdrops' returns 1 on success // immediately copy global temporary variables into scope variables, // since we don't know when 'getmobdrops' will get called again for // another mob, overwriting your global temporary variables .@count = $@MobDrop_count; copyarray .@item[0],$@MobDrop_item[0],.@count; copyarray .@rate[0],$@MobDrop_rate[0],.@count; mes getmonsterinfo(.@mob_id,MOB_NAME) + " - " + .@count + " drops found:"; for( .@i = 0; .@i < .@count; .@i++ ) { .@menu$ = .@menu$ + .@item[.@i] + " (" + getitemname(.@item[.@i]) + ") " + .@rate[.@i]/100 + ((.@rate[.@i]%100 < 10) ? ".0":".") + .@rate[.@i]%100 + "%"; } .@menu$ = .@menu$ + ":"; } else { mes "Unknown monster ID."; } .@part = .@count[select(.@menu$)]; Can someone help me separate the menu instead of 1 line? Quote Link to comment Share on other sites More sharing options...
0 Tokei Posted December 11, 2022 Group: Members Topic Count: 16 Topics Per Day: 0.00 Content Count: 696 Reputation: 721 Joined: 11/12/12 Last Seen: 5 hours ago Share Posted December 11, 2022 The separator used for menus is the colon, ":". So just change "%" to "%:". Though, this line: .@part = .@count[select(.@menu$)]; doesn't make a whole lot of sense. Keep in mind that select returns the first value as 1 instead of 0, so you have to remove 1. What you probably wanted to write was the following. .@selected = select(.@menu$) - 1; .@itemid = .@item[.@selected]; Also, not... an issue, but you'd probably want to change your variable names a bit by adding an 's' to your arrays otherwise it becomes very messy (and addding [0] is redundant). copyarray .@items, $@MobDrop_item, .@count; Also, might as well use sprintf for your drop rates, it makes your life easier. So something like this: mes "Monster ID: "+getmonsterinfo(.@mob_id,MOB_NAME)+"'"; if (getmobdrops(.@mob_id)) { // 'getmobdrops' returns 1 on success // immediately copy global temporary variables into scope variables, // since we don't know when 'getmobdrops' will get called again for // another mob, overwriting your global temporary variables .@count = $@MobDrop_count; copyarray .@items, $@MobDrop_item, .@count; copyarray .@rates, $@MobDrop_rate, .@count; mes getmonsterinfo(.@mob_id,MOB_NAME) + " - " + .@count + " drops found:"; for (.@i = 0; .@i < .@count; .@i++) { .@menu$ = .@menu$ + sprintf("%d (%s) %d.%02d%%", .@items[.@i], getitemname(.@items[.@i]), .@rates[.@i] / 100, .@rates[.@i] % 100) + ":"; } .@menu$ = .@menu$ + ":"; } else { mes "Unknown monster ID."; } .@selected = select(.@menu$) - 1; .@item = .@items[.@selected]; .@rate = .@rates[.@selected]; Quote Link to comment Share on other sites More sharing options...
Question
Selerie
mes "Monster ID: "+getmonsterinfo(.@mob_id,MOB_NAME)+"'"; if (getmobdrops(.@mob_id)) { // 'getmobdrops' returns 1 on success // immediately copy global temporary variables into scope variables, // since we don't know when 'getmobdrops' will get called again for // another mob, overwriting your global temporary variables .@count = $@MobDrop_count; copyarray .@item[0],$@MobDrop_item[0],.@count; copyarray .@rate[0],$@MobDrop_rate[0],.@count; mes getmonsterinfo(.@mob_id,MOB_NAME) + " - " + .@count + " drops found:"; for( .@i = 0; .@i < .@count; .@i++ ) { .@menu$ = .@menu$ + .@item[.@i] + " (" + getitemname(.@item[.@i]) + ") " + .@rate[.@i]/100 + ((.@rate[.@i]%100 < 10) ? ".0":".") + .@rate[.@i]%100 + "%"; } .@menu$ = .@menu$ + ":"; } else { mes "Unknown monster ID."; } .@part = .@count[select(.@menu$)];
Can someone help me separate the menu instead of 1 line?
Link to comment
Share on other sites
1 answer to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.