Register for your free account! | Forgot your password?

You last visited: Today at 23:05

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



the better method

Discussion on the better method within the CO2 Private Server forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Sep 2011
Posts: 105
Received Thanks: 17
the better method

Now guys I am doing a TeamsWar and I don't know how to do the automatic team choice for every player that sign up !
so I made two methods may you please tell me if they will work properly.
and tell me what method to choose from, BTW I am not a good coder I am still a beginner so just don't come here to make fun of me. if you have a better way to do it may you please explain how

Here is the code !
XDestroyer2011 is offline  
Old 12/09/2014, 23:01   #2
 
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,380
Nothing in that example will work.

-You're creating 'new' clients... you cannot do that...
-You're over complicating things


There's no reason to have bools for isTeam in the player.

#1: Create a 'team' enum.
#2: Create an 'event' class. Assign starting/ending events to sort players into teams
#3: Create a 'team' class. Have it store team score and members


When starting an event you take a collection of all signed up players (players on waiting map or add them in via npc/command/etc) and sort them into teams. You can sort them by level/battlepower to try to balance teams if needed or simply randomize the collection.

Something like

var teamCounter = 0;//Starting team index
var teamCounts = 3;//4 possible teams
foreach(var player in awaitingPlayers)
{
teamCounter++;
if(teamCounter > teamCounts)
teamCounter = 0;
Teams[teamCounter].AddMember(player);
}


Again, there's lots of ways to simplify and make your events system easier to build on.



This way you can check in your combat handler if you are part of an event with something like

if(character.Event != null)

You can modify their team's score and perform any needed actions (freezing, changing teams, etc)
character.Team.ScorePoint(target)



Just boils down to coding the base event systems in a way that you can have them support any event you can imagine. I know in albetros I wrote a BASIC system (it's messy but it could give you a basic idea of how to code an event system)
pro4never is offline  
Old 12/09/2014, 23:17   #3
 
elite*gold: 0
Join Date: Sep 2011
Posts: 105
Received Thanks: 17
well that's true that I am always complicating thing up.
all of that is just good.
but my question was on how to sort the teams, how can I do that
and on your answer here you just explained every thing beside
sorting the teams, I know you said "You can sort them by level/battlepower to try to balance teams if needed or simply randomize the collection. "
but what I want is to random every one into a team of the 4 but all the teams should have equal players or a nearly equal players.
thanks for your answer and time
XDestroyer2011 is offline  
Old 12/09/2014, 23:29   #4
 
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,380
Code:
but what I want is to random every one into a team of the 4 but all the teams should have equal players or a nearly equal players.
yes, that's the example I gave you. You need to get a collection of ALL players signed up. Query the map of the event or a 'waiting room' for the event or build it as people sign up. Either way you have a collection of all players.

Sort that collection based on criteria (level for example)

var awaitingPlayers = registeredPlayers.OrderBy(I=>I.Level);

Then loop through all elements and cycle them into teams evendly (first element = team 1, second element = team 2, etc)

var teamCounter = 0;//Starting team index
var teamCounts = 3;//4 possible teams
foreach(var player in awaitingPlayers)
{
teamCounter++;
if(teamCounter > teamCounts)
teamCounter = 0;
Teams[teamCounter].AddMember(player);
}
pro4never is offline  
Old 12/09/2014, 23:38   #5
 
elite*gold: 0
Join Date: Sep 2011
Posts: 105
Received Thanks: 17
but this will work for one team ?
or I can use this method in as many teams as I want
XDestroyer2011 is offline  
Old 12/09/2014, 23:48   #6
 
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,380
You can use it for as many teams as you want.

The idea is you create an array of teams of any length and then you assign players to each team.

want 10 teams? Change 0 lines of code and it'll work the same as 2 teams.
pro4never is offline  
Old 12/09/2014, 23:56   #7
 
elite*gold: 0
Join Date: Sep 2011
Posts: 105
Received Thanks: 17
thats what I did


and I got this error



Sorry man, I am just a noob
XDestroyer2011 is offline  
Old 12/10/2014, 00:33   #8
 
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,380
Enums is just making text out of a number. You need a collection (list, array, dictionary, etcetc) containing the teams themselves (a separate class)

It's not handled all that well but I really do suggest looking through the albetros source as it will at least demonstrate an idea of how you could write an event system.
pro4never is offline  
Old 12/10/2014, 01:03   #9
 
elite*gold: 0
Join Date: Sep 2011
Posts: 105
Received Thanks: 17
Wow just downloaded albetros source and looked in the TDM wow ! it is amazing !
XDestroyer2011 is offline  
Old 12/10/2014, 01:06   #10
 
turk55's Avatar
 
elite*gold: 130
Join Date: Oct 2007
Posts: 1,655
Received Thanks: 706
Updated your code a bit (can be done better, but you will atleast get the idea):

turk55 is offline  
Thanks
2 Users
Old 12/10/2014, 01:27   #11
 
elite*gold: 0
Join Date: Sep 2011
Posts: 105
Received Thanks: 17
Quote:
Originally Posted by turk55 View Post
Updated your code a bit (can be done better, but you will atleast get the idea):

ahhahahah that's not a bit
thanks
XDestroyer2011 is offline  
Reply


Similar Threads Similar Threads
[TUT] anthrax28 bypass method(working method)edited by:akomsimojm [TUT]
04/09/2010 - Soldier Front Hacks, Bots, Cheats & Exploits - 36 Replies
SUCROSE anthrax28 bypass method(working method)edited by:akomsimojm *closed made another thread that is surely working



All times are GMT +1. The time now is 23:05.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.