Jump to content

Question

Posted

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.

4 answers to this question

Recommended Posts

  • 0
Posted
	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
  • 0
Posted

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

 

  • 0
Posted
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;

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...