Jump to content
  • 0

Random Menu Selection


WhiteEagle

Question


  • Group:  Members
  • Topic Count:  76
  • Topics Per Day:  0.02
  • Content Count:  455
  • Reputation:   57
  • Joined:  08/28/12
  • Last Seen:  

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.

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

  • Group:  Content Moderator
  • Topic Count:  55
  • Topics Per Day:  0.02
  • Content Count:  1676
  • Reputation:   702
  • Joined:  12/21/14
  • Last Seen:  

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

 

  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  76
  • Topics Per Day:  0.02
  • Content Count:  455
  • Reputation:   57
  • Joined:  08/28/12
  • Last Seen:  

Thank you. Works perfect !! Very nice from you.

Link to comment
Share on other sites

  • 0

  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2345
  • Joined:  10/28/11
  • Last Seen:  

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

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  13
  • Topics Per Day:  0.00
  • Content Count:  29
  • Reputation:   6
  • Joined:  10/15/15
  • Last Seen:  

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;

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