WhiteEagle Posted June 28, 2019 Group: Members Topic Count: 79 Topics Per Day: 0.02 Content Count: 480 Reputation: 67 Joined: 08/28/12 Last Seen: 11 hours ago Share Posted June 28, 2019 Hey ~ Can anyone help me please with this here? I only want to display 2 randomly from the Array .@gqname$. Spoiler setarray .@gqname$[0],"Kill Mantis","Kill Bees","Kill Soils","Kill Porings"; .@menu = select( random 2 selections from above ); switch(.@menu) { case 1: mes("mantis"); close; case 2: mes("bees"); close; case 3: mes("soils"); close; case 4: mes("porings."); close; } Thanks in Advance. Quote Link to comment Share on other sites More sharing options...
0 sader1992 Posted June 28, 2019 Group: Content Moderator Topic Count: 55 Topics Per Day: 0.01 Content Count: 1691 Reputation: 716 Joined: 12/21/14 Last Seen: Tuesday at 07:50 PM Share Posted June 28, 2019 setarray .@gqname$[0],"Kill Mantis","Kill Bees","Kill Soils","Kill Porings"; .@null$ = "NULL"; while(countinarray(.@gqname$[0], .@null$) != 2) .@gqname$[rand(getarraysize(.@gqname$))] = .@null$; switch(select(replacestr(implode(.@gqname$, ":"), .@null$, ""))) { case 1: mes("mantis"); close; case 2: mes("bees"); close; case 3: mes("soils"); close; case 4: mes("porings."); close; } 1 Quote Link to comment Share on other sites More sharing options...
0 WhiteEagle Posted June 29, 2019 Group: Members Topic Count: 79 Topics Per Day: 0.02 Content Count: 480 Reputation: 67 Joined: 08/28/12 Last Seen: 11 hours ago Author Share Posted June 29, 2019 Thank you. Works perfect !! Very nice from you. Quote Link to comment Share on other sites More sharing options...
0 Emistry Posted August 18, 2019 Group: Forum Moderator Topic Count: 93 Topics Per Day: 0.02 Content Count: 10018 Reputation: 2369 Joined: 10/28/11 Last Seen: Sunday at 05:32 PM Share Posted August 18, 2019 you can also try something like this... prontera,155,181,5 script Sample 4_F_KAFRA1,{ callfunc("F_ShuffleNumbers", 0, getarraysize(.array$) - 1, .@output, .menu_count); for (.@i = 0; .@i < .menu_count; .@i++) .@menu$ = .@menu$ + .array$[.@output[.@i]] + ":"; .@i = select(.@menu$) - 1; mes "Selected "+.array$[.@output[.@i]]; close; OnInit: .menu_count = 2; setarray .array$, "Kill Mantis", "Kill Bees", "Kill Soils", "Kill Porings"; end; } but you will need this function function script F_ShuffleNumbers { deletearray getarg(2); .@static = getarg(0); .@range = getarg(1) +1 - .@static; .@count = getarg(3, .@range); if (.@range <= 0 || .@count <= 0) return 0; if (.@count > .@range) .@count = .@range; for (.@i = 0; .@i < .@range; ++.@i) .@temparray[.@i] = .@i; for (.@i = 0; .@i < .@count; ++.@i) { .@rand = rand(.@range); set getelementofarray( getarg(2), .@i ), .@temparray[.@rand] + .@static; .@temparray[.@rand] = .@temparray[--.@range]; } return .@count; } Quote Link to comment Share on other sites More sharing options...
0 lphz Posted January 14, 2021 Group: Members Topic Count: 13 Topics Per Day: 0.00 Content Count: 29 Reputation: 6 Joined: 10/15/15 Last Seen: March 14 Share Posted January 14, 2021 prontera,155,181,5 script Sample 4_F_KAFRA1,{ callfunc("F_ShuffleNumbers", 0, getarraysize(.array$) - 1, .@output, .menu_count); for (.@i = 0; .@i < .menu_count; .@i++) .@menu$ = .@menu$ + .array$[.@output[.@i]] + ":"; .@i = select(.@menu$) - 1; mes "Selected "+.array$[.@output[.@i]]; close; OnInit: .menu_count = 2; setarray .array$, "Kill Mantis", goto L_KillMantis "Kill Bees", "Kill Soils", "Kill Porings"; end; } after select menu how next ... like goto L_KillMantis L_KillMantis: mes "................."; close; Quote Link to comment Share on other sites More sharing options...
Question
WhiteEagle
Hey ~
Can anyone help me please with this here?
I only want to display 2 randomly from the Array .@gqname$.
setarray .@gqname$[0],"Kill Mantis","Kill Bees","Kill Soils","Kill Porings";
.@menu = select( random 2 selections from above );
switch(.@menu) {
case 1:
mes("mantis");
close;
case 2:
mes("bees");
close;
case 3:
mes("soils");
close;
case 4:
mes("porings.");
close;
}
Thanks in Advance.
Link to comment
Share on other sites
4 answers 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.