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)

Why the fuck you use vector ?

i updated my previous post you can take a look

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

    • it's great that you know who these files come from... you shouldn't forget vanganth too! now it is very easy, you take my last revision of svn and compare it against those files.... when you finish analyzing and comparing you should do the following... which will be very easy to check...   once everything is checked, analyze what did L2Devs do hahaha   I who give away the files, make me problem. L2Devs is SCAMMING people, selling something free and you don't say anything... It is something very strange what happens .... Besides you ripped me off 100usd, but I hope you got server to eat at least. PD: the day you take it back and return my 100usd I will forgive you and pretend that nothing ever happened 😉
    • 🔥 Apresentação I present to you a new fully customized DressMe system, developed for DreamV2, inspired by the best servers and enhanced with unique features that guarantee performance, customization and stunning visuals. ✨ Funcionalidades ✅ Aplicação de visual de armas e armaduras sem alterar o item real equipado. ✅ Compatível com qualquer tipo de arma/armadura (ex: skins de bow visíveis apenas com bows equipados). ✅ Remoção automática do visual quando parte do set real é desequipada. ✅ Efeitos visuais (skills) aplicados com suporte a: Aplicação única ou recorrente Intervalo configurável via XML Remoção automática ao desativar o visual ✅ Interface limpa e lógica modular, fácil de expandir com novos visuais ou efeitos.     <?xml version="1.0" encoding="UTF-8"?> <dressMeList> <dress skillId="9100" name="Draconic Armor" type="ARMOR" isVip="false" > <visualSet chest="6379" legs="0" gloves="6380" feet="6381" helmet="6841" /> <visualEffect skillId="445" level="1" recurring="true" interval="35" /> </dress> <dress skillId="9102" name="Cloak Style Armor" type="CLOAK" isVip="false"> <visualSet chest="7000" legs="0" gloves="0" feet="0" helmet="0" /> <visualEffect skillId="10005" level="1" recurring="false" /> </dress> <dress skillId="9103" name="Valakas Style Weapon" type="WEAPON" isVip="false"> <visualWep type="bow" rhand="7575" lhand="0" lrhand="0" /> <visualEffect skillId="10005" level="1" recurring="false" /> </dress> </dressMeList> 📸 Imagens & Vídeo 🛠️ Detalhes Técnicos Desenvolvido com base no L2J DreamV2 Integração direta com L2PcInstance, Inventory, ThreadPoolManager e SkillTable Sistema de gerenciamento central via DressMeEffectManager Agendamento e cancelamento seguro de efeitos recorrentes Totalmente thread-safe e compatível com jogadores offline 📂 Instalação A instalação é feita via patch e inclui: Classes: DressMeHolder, DressMeEffectManager, modificações em L2PcInstance XML de exemplo Suporte completo à expansão por armas, cloaks e visuais parciais 📎 Download https://pastebin.com/raw/7i843yKh 💬 Feedback & Sugestões Sinta-se à vontade para comentar abaixo com sugestões, dúvidas ou feedbacks. Toda contribuição é bem-vinda para futuras versões!
    • @Tinker123aa Guytis, I have nothing against you, but it's very clear to me who is behind this files. I'm talking about the one that came with the captcha anti-bot system. I personally bought it from the real owner, who was one of the administrators of L2Gold.cc. This can be confirmed by him if he wishes. 😊 Maybe you worked on the files, but they didn’t start from you.   To the people trying to buy the files I’m just advising you not to waste your money. This is 100% verified information.   I honestly don't know how people believe you. 🙂 I'll share the link to the guy's topic below.   ps  
    • Hello,  Anyone knows how I can communicate to purchase this emulator.  Nobody answered in the forum of eternity neither Kate neither lord winter.    Thanks in advance.
  • Topics

×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock