![]() |
|
09-08-2012
|
106 | |
|
Registered User
Join Date: Sep 2011
Location: Germany
Posts: 6,122
|
|
|
|
09-08-2012
|
107 |
|
299,792,458 m/s
Join Date: Mar 2012
Location: Lebanon
Posts: 3,581
|
|
|
09-08-2012
|
108 | |
|
Nerd
Join Date: Sep 2011
Location: Berlin
Posts: 3,825
|
PHP Code:
Last edited by Emera; 09-08-2012 at 09:58 PM.
|
|
|
09-08-2012
|
109 |
|
The muffin man
Join Date: Sep 2011
Location: Burger Refuge
Posts: 2,262
|
|
|
09-08-2012
|
110 | |
|
299,792,458 m/s
Join Date: Mar 2012
Location: Lebanon
Posts: 3,581
|
temp.team = temp.teams[temp.count % temp.teams.size()]; temp.count++; Thanks! |
|
|
09-08-2012
|
111 |
|
Nerd
Join Date: Sep 2011
Location: Berlin
Posts: 3,825
|
|
|
09-08-2012
|
112 |
|
299,792,458 m/s
Join Date: Mar 2012
Location: Lebanon
Posts: 3,581
|
What's temp.count and what does % do xD
|
|
09-08-2012
|
113 |
|
The muffin man
Join Date: Sep 2011
Location: Burger Refuge
Posts: 2,262
|
% is the symbol for modular division. It basically works but...urghh I suck at explaining it, have a wiki:http://en.wikipedia.org/wiki/Modulo_operation But basically it's allowing the variable to pick between to the 2 teams swapping back and fourth. temp.count=0:0%2 = element 0 = team 1 temp.count = 1:1%2 = element 1 = team 2 temp.count = 2:2%2=0 = element 0 = team 1 temp.count = 3:3%2 = 1 = element 1 = team 2 and so on. It's a really nice solution btw emera. |
|
09-08-2012
|
114 | |
|
Nerd
Join Date: Sep 2011
Location: Berlin
Posts: 3,825
|
And thanks for the nice explanation. Mine would've sucked.
|
|
|
09-09-2012
|
115 | |
|
Registered User
Join Date: Sep 2011
Location: Germany
Posts: 6,122
|
the only thing i dont like about it: whenever you want to randomnize it with the same players, wouldnt it keep them in the same team? at least i think so, since the players array is sorted by the account, right? |
|
|
09-09-2012
|
116 | |
|
The muffin man
Join Date: Sep 2011
Location: Burger Refuge
Posts: 2,262
|
A way to ensure randomness would be to do something like: PHP Code:
|
|
|
09-09-2012
|
117 |
|
Delteria GM
Join Date: Apr 2012
Location: New York
Posts: 686
|
Wish I knew what this stuff meant.
|
|
09-09-2012
|
118 | |
|
Banned
Join Date: Apr 2012
Location: Sweden
Posts: 287
|
PHP Code:
Last edited by xXziroXx; 09-10-2012 at 03:37 AM.
|
|
|
09-09-2012
|
119 | |
|
The muffin man
Join Date: Sep 2011
Location: Burger Refuge
Posts: 2,262
|
You don't got **** me on me ;o |
|
|
09-09-2012
|
120 | |
|
Banned
Join Date: Apr 2012
Location: Sweden
Posts: 287
|
|
|