Jump to content
  • 0
WhiteEagle

Random Menu Selection

Question

Hey ~
Can anyone help me please with this here?
I only want to display 2 randomly from the Array [email protected]$.
 

Spoiler

setarray [email protected]$[0],"Kill Mantis","Kill Bees","Kill Soils","Kill Porings";
    [email protected] = select( random 2 selections from above );
    switch([email protected]) {
    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
	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;
	}

 

Link to comment
Share on other sites

  • 0

you can also try something like this...

prontera,155,181,5	script	Sample	4_F_KAFRA1,{
	callfunc("F_ShuffleNumbers", 0, getarraysize(.array$) - 1, [email protected], .menu_count);
	for ([email protected] = 0; [email protected] < .menu_count; [email protected]++)
		[email protected]$ = [email protected]$ + .array$[[email protected][[email protected]]] + ":";
	[email protected] = select([email protected]$) - 1;
	mes "Selected "+.array$[[email protected][[email protected]]];
	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);
	[email protected] = getarg(0);
	[email protected] = getarg(1) +1 - [email protected];
	[email protected] = getarg(3, [email protected]);
	if ([email protected] <= 0 || [email protected] <= 0)
		return 0;
	if ([email protected] > [email protected])
		[email protected] = [email protected];
	for ([email protected] = 0; [email protected] < [email protected]; [email protected])
		[email protected][[email protected]] = [email protected];
	for ([email protected] = 0; [email protected] < [email protected]; [email protected]) {
		[email protected] = rand([email protected]);
		set getelementofarray( getarg(2), [email protected] ), [email protected][[email protected]] + [email protected];
		[email protected][[email protected]] = [email protected][[email protected]];
	}
	return [email protected];
}

 

Link to comment
Share on other sites

  • 0
prontera,155,181,5	script	Sample	4_F_KAFRA1,{
	callfunc("F_ShuffleNumbers", 0, getarraysize(.array$) - 1, [email protected], .menu_count);
	for ([email protected] = 0; [email protected] < .menu_count; [email protected]++)
		[email protected]$ = [email protected]$ + .array$[[email protected][[email protected]]] + ":";
	[email protected] = select([email protected]$) - 1;
	mes "Selected "+.array$[[email protected][[email protected]]];
	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...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.