WhiteEagle Posted June 28, 2019 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
0 sader1992 Posted June 28, 2019 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
0 WhiteEagle Posted June 29, 2019 Author Posted June 29, 2019 Thank you. Works perfect !! Very nice from you. Quote
0 Emistry Posted August 18, 2019 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
0 lphz Posted January 14, 2021 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
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.
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.