Jump to content
  • 0

help waiting room shuffle player lms


Question

Posted (edited)

hi anyone can help me how to add waiting room in LMS but to shuffle the players before entering? 

Spoiler

OnStart:
    if ( getwaitingroomstate( 0, "red bravery" ) < .minplayer2start || getwaitingroomstate( 0, "blue bavery" ) < .minplayer2start ) end;
    set .red, waitingroom2bg( "bat_c01", 53,128, strnpcinfo(0)+"::OnredQuit", strnpcinfo(0)+"::OnredDead", "red bravery" );
    copyarray .team1aid[.@i], $@arenamembers[.@i], $@arenamembersnum;
    set .blue, waitingroom2bg( "bat_c01", 146,55, strnpcinfo(0)+"::OnblueQuit", strnpcinfo(0)+"::OnblueDead", "blue bavery" );
    copyarray .team2aid[.@i], $@arenamembers[.@i], $@arenamembersnum;
    delwaitingroom "red bravery";
    delwaitingroom "blue bavery";
    bg_warp .red, "bat_c01", 58,123;
    bg_warp .blue, "bat_c01", 141,60;
    set .score[1], .startingscore;
    set .score[2], .startingscore;
    bg_updatescore "bat_c01", .score[1], .score[2];
    sleep .eventlasting * 1000;

 

bat_room,150,156,5    script    red bravery    733,{
    end;
OnInit:
    waitingroom "bravery red side", getvariableofnpc( .minplayer2start, "custom_bg#control" ) +1, "custom_bg#control::OnStart", getvariableofnpc( .minplayer2start, "custom_bg#control" );
    end;
}
bat_room,150,144,5    script    blue bavery    734,{
    end;
OnInit:
    waitingroom "bravery blue side", getvariableofnpc( .minplayer2start, "custom_bg#control" ) +1, "custom_bg#control::OnStart", getvariableofnpc( .minplayer2start, "custom_bg#control" );
    end;

 

Edited by cadz

1 answer to this question

Recommended Posts

  • 0
Posted

Try this
 


//////////////////////////////////////////////////////////////////////////////////
// by AnnieRuru authored and MishimaHaruna
// *** Function "F_ShuffleNumbers":
// Generate a set of numbers in random order that the numbers are not repeated
// --- callfunc "F_ShuffleNumbers",<start num>,<last num>,<output array>{,<count>};
// Examples: 
//    callfunc("F_ShuffleNumbers", 0, 5, .@output)      // possible output 4,1,3,2,0,5
//    callfunc("F_ShuffleNumbers", -5, 1, .@output)     // possible output -3,-5,-4,-2,-1,1,0
//    callfunc("F_ShuffleNumbers", 0, 100, .@output, 5) // possible output 9,55,27,84,33
// Reminder: Use *freeloop command when appropriate !
//////////////////////////////////////////////////////////////////////////////////

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



https://annieruru.blogspot.com/2019/01/shuffle-algorithm.html

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