Jump to content
  • 0

Best Way For Randomly Split


Question

Posted (edited)

Hello guys!

 

Im trying to find the best way to split 3 Vectors...

 

example:

public static Vector<L2PcInstance> players = new Vector<>();

Contains 50 players.

 

I want to split them to 25 - 25 but not taking 1 by 1 .. i want randomly selection in the next 2 vectors

public static Vector<L2PcInstance> vec1 = new Vector<>();
public static Vector<L2PcInstance> vec2 = new Vector<>();

Im always missing something and the result isnt correct. Someone can help me? 

Thank you!!!

Edited by melron

Recommended Posts

  • 0
Posted

Alright then im doing it wrong... And im asking again now, Even if i will use a list to store them ....

Then i have to do the same thing to suffle them right?.......... :D

 

Forget about vectors.. lets say i have list ... i want just the way for a random split for 2 other lists...

You can use the 

Collections.shuffle(list)

to suffle the list.

After you add the elements onto the list use it to suffle it.

  • 0
Posted

Hello guys!

 

Im trying to find the best way to split 3 Vectors...

 

example:

public static Vector<L2PcInstance> players = new Vector<>();

Contains 50 players.

 

I want to split them to 25 - 25 in the next 2 vectors

public static Vector<L2PcInstance> vec1 = new Vector<>();
public static Vector<L2PcInstance> vec2 = new Vector<>();

Im always missing something and the result isnt correct. Someone can help me? 

Thank you!!!

show code

  • 0
Posted (edited)

show code

What code do you need? i havent ready code that working thats why im asking for help...

 

players = 50 players

 

vec1 = 0

vec2 = 0;

 

how i can randomly split the players to vec1 & vec2.

 

Sorry for no posting my code but i think its rly useless since im looking the way for a split

Correct me if im wrong

 

Edit: Actually i havent something to show you.. i just want to create this code 

Edited by melron
  • 0
Posted (edited)

Bla bla bla, you afraid of people leeching your code? If i don't see the code you ain't take your answer.

 

Byeee  :-[

Yea u found it! 

as im saying....

Edit: Actually i havent something to show you.. i just want to create this code

 

i havent ready code to show you im just want find this way to split...

To explain it again:

 

players using the command .example

When the list 'players' collect 50 people the registration will close.

 

after that i want to split the players in these 2 vectors randomly so i can continue work with them...

i think you can understand what i mean.. i wanna start making something...

 

atm the code is here but as i said isnt showing something... You dont need these..

 

Open registrations

 

 

protected void openRegistrations()
   {  
       state = State.REGISTER;
       Broadcast.announceToOnlinePlayers(".::Event::.");
       Broadcast.announceToOnlinePlayers("In one minute registration will be close!");
       ThreadPoolManager.getInstance().scheduleGeneral(new checkRegist(), 60000 );
   } 

 

 

check registrations

Event.java

 

 

protected void Registrations()
    {
	   try
	   {
	       state=State.LOADING;
	       
	       if(players.isEmpty() || players.size() < 50)
	       {
	           Broadcast.announceToOnlinePlayers("Event aborted due to innactivity!");
	           clean();
	           return;
	       }
	       Broadcast.announceToOnlinePlayers("In 30 seconds players will shuffle");
	       ThreadPoolManager.getInstance().scheduleGeneral(new shuffle, 30000 ); 
	   }
	   catch (Exception e)
	   {
		   _log.warning("Error event" + e.getMessage());
	   }
	   
    } 

 

 

 

Say2.java

 

 

checkCommand(_text,activeChar);
		       if(_text.equalsIgnoreCase(".example") || _text.equalsIgnoreCase(".example"))
		           return;

 

 

 

checkCommand in Say2.java

 

 

static void checkCommand(String text,L2PcInstance player)
	   {
	       if(text.equalsIgnoreCase(".example"))
	       {
	           if(Event.players.contains(player))
	           {
	               player.sendMessage("You have already registed to the event.");
	               return;
	           }
	           if(Event.state == Event.State.INACTIVE)
	               return;
	           if(Event.state != Event.State.REGISTER)
	           {
	               player.sendMessage("Event has already started.");
	               return;
	           }
	           Event.players.add(player);
	           player.sendMessage("You registed to the event!!");
	           return;
	       }

 

 

 

And in shuffle i want to make this split... So??

Edited by melron
  • 0
Posted (edited)

I don't know why you want use vector. Probably you want create 3 teams which is bad lel. You need create teamHolders no vectors but even if you want create vectors i won't go against it.

 

Make a for to all elements of players and use a variable i and check if i > 15 to add the player into vector 1 (then do i++) else add player into vector 2

if this is what you want.

for (int i=0; i <= players.size();)
{
   if (i<=15)
      vectorplayers1.add(players.get(i));
   else
      vectorplayers2.add(players.get(i));
   i++;
}

something like this maybe? i don't even know vector i dont use it.

 

Just giving you the idea on how to split into 3 vectors

Edited by AccessDenied
  • 0
Posted (edited)

I don't know why you want use vector. Probably you want create 3 teams which is bad lel. You need create teamHolders no vectors but even if you want create vectors i won't go against it.

 

Make a for to all elements of players and use a variable i and check if i > 15 to add the player into vector 1 (then do i++) else add player into vector 2

if this is what you want.

for (int i=0; i <= players.size();)
{
   if (i<=15)
      vectorplayers1.add(players.get(i));
   else if (i>15 && i<=30)
      vectorplayers2.add(players.get(i));
   else
      vectorplayers3.add(players.get(i));
   i++;
}

something like this maybe? i don't even know vector i dont use it.

 

Just giving you the idea on how to split into 3 vectors

Thank you for your help, I want 2 teams (the players vector will be clean after the split)

im trying to use a kind of shuffle ... with your way its like the first 25 players go to team1 and the others go to team 2.. i want random selection :/

 

p.s if i can do this one with a better way i will not say no :D

 

But if i will use a list or something , I  should do the same method as im searching now... Am i wrong?

Edited by melron
  • 0
Posted

Thank you for your help, I want 2 teams (the players vector will be clean after the split)

im trying to use a kind of suffle ... with your way its like the first 25 players go to team1 and the others go to team 2.. i want random selection :/

 

p.s if i can do this one with a better way i will not say no :D

 

But if i will use a list or something , I  should do the same method as im searching now... Am i wrong?

 

Making teams don't even use vectors or arrays lel 

what if u need 5 teams u will make 5 vectors? you use sets stored into 1 array.

  • 0
Posted (edited)

Making teams don't even use vectors or arrays lel 

what if u need 5 teams u will make 5 vectors? you use sets stored into 1 array.

Alright then im doing it wrong... And im asking again now, Even if i will use a list to store them ....

Then i have to do the same thing to shuffle them right?.......... :D

 

Forget about vectors.. lets say i have list ... i want just the way for a random split for 2 other lists...

Edited by melron
  • 0
Posted

You can use the 

Collections.shuffle(list)

to suffle the list.

After you add the elements onto the list use it to suffle it.

Thank you!

Guest
This topic is now closed to further replies.


  • Posts

    • Please note:i will provide you with forum address for registration once buyer sends money(my commission) to forum guarantor's payment details. You can register on forum in any day and in any time,which are convenient for you,send code word in private message to forum guarantor(you will receive code word from buyer). If buyer does not purchase your product,you will need to wait private message(answer) from forum guarantor to compare code word. I will invite you in "forum deal". I will add your name,which you registered on forum,in "forum deal". Then you write in "forum deal": "buyer did not purchase product" and add code word(you will have this right according to clause in forum questionnaire). Forum guarantor will refund buyer((in full amount). If buyer purchases your product,buyer notifies forum guarantor and forum guarantor will send money to my payment details.   Sports exercise machines,jacuzzi,building materials,cosmetics,perfumes,shoes,clothing,furniture,bags,televisions,music centers,telephones,laptops,tablet computers,refrigerators,washing machines,microwaves,fans.  
    • Here is a L2JMobius Classic Interlude FULL server. The share includes full server source+datapack, patch, interface and the P110 client. The original build is L2JMobius. However it was bought from a user called "ClassicLude (https://classic-lude.org/)" which is also a huge scammer, selling free Mobius files for $500. I could not believe someone actually bought this, yet here we are.    Unfortunately the admin is a scammer and refused to pay his remaining balance of over $150 to me since he is too busy "working for Bill Gates" and opening the next big mega mall in ChatGPT city therefore not having enough money. The server itself garnered a massive 30 players so I can't really tell you if this is usable. Knowing its backstory and that it is Mobius based i can surmise that it is NOT suitable for serious users. This build is the result of typical AI slop and vibecode "admins" thinking they just "one shotted L2J" because they discovered how to prompt an agent.   I have made the following changes, some of which were regrettably butchered by the admin after he discovered how to download Cursor. Not much more was done due to the absolute displeasure and misery of having to work on a Mobius server.   - Updated files to JDK 22 - Added l2 reborn community board - Added preview system for skins including mounts/agathions - Added AIO npc (buffer/store/teleporter) - Added QuickVar system - Added Ranking system (pvp/pk/online/level and moar) - Added raid boss list on community board - Added drop search+shift click with itemtooltip on community board and npc - Added l2 reborn styled flash windows and window borders and L2UI_CT1 - Added custom donate coin icon in the store swf - Fixed some random bugs like Hot Springs monsters not giving the disease     Links Source+Datapack: https://drive.google.com/file/d/1uMaTzSxKtnLxXC-VoZyHYW_OXq7Oof5L/view?usp=sharing Interface+Compiler+Client tools: https://drive.google.com/file/d/14IJWyYSDOjMycHnJ749H9dRXuv2JeYK3/view?usp=sharing Full Client: https://drive.google.com/file/d/1P7Yd9wI0XcWlLMFDPSdfTZgWhW_9JEii/view?usp=sharing
    • I logged in with this system, maybe its the patch shared by greenhope i don't remember i just downloaded it because i love C3 but no l2j or l2off c3 is good everything is buggy and this one too, also it has no geodata and i don't know if it has geoengine because i didn't see the config for it in the config folder. If someone had the latest l2jvn maybe it could be more stable but i don't think so at least without the source, if someone has it to share it that would be good  https://www.mediafire.com/file/mzodnsyi9qn4ap7/patch+560+for+c3.rar/file
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..