Posts: 124
Threads: 6
Joined: Dec 2011
Reputation:
14
Yes.
However, it is somewhat outdated. If you want, I'll post the new version.
Posts: 76
Threads: 12
Joined: Feb 2012
Reputation:
0
yes that would be great
and how work? just read map rotation in order or need edit weight?
Posts: 124
Threads: 6
Joined: Dec 2011
Reputation:
14
02-25-2012, 19:49
(This post was last modified: 02-25-2012, 19:57 by Yurio.)
Code: const int MAPS = 16;
string[] mapdev = { "mp_alpha", "mp_bootleg", "mp_bravo", "mp_carbon", "mp_dome", "mp_exchange", "mp_hardhat", "mp_interchange", "mp_lambeth", "mp_mogadishu", "mp_paris", "mp_plaza2", "mp_radar", "mp_seatown", "mp_underground", "mp_village" };
string[] mapuser = { "lockdown", "bootleg", "mission", "carbon", "dome", "downturn", "hardhat", "interchange", "fallen", "bakaara", "resistance", "arkaden", "outpost", "seatown", "underground", "village" };
int[] maprange = new int[MAPS];
int range;
int nextmap = -1;
string dspl, dsr;
Random rnd = new Random(unchecked((int)DateTime.Now.Ticks));
void GetRotation()
{
dspl = GetServerCFG("Yu", "dspl", "default") + ".dspl";
dsr = GetServerCFG("Yu", "dsr", "FFA_default");
string[] weights = GetServerCFG("Yu", "weights", "3, 2, 5, 3, 5, 2, 5, 3, 2, 5, 5, 3, 2, 3, 2, 5").Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);
for (int i = 0; i < MAPS; i++)
{
range += int.Parse(weights[i]);
maprange[i] = range;
}
}
int FindMap(int r)
{
for (int i = 0; i < MAPS; i++)
if (r <= maprange[i])
return i;
return -1;
}
void SetMap(string map)
{
File.WriteAllText(@"admin\" + dspl, map + "," + dsr + ",1");
}
int GetMapByName(string map, bool dev = false)
{
string[] m = dev ? mapdev : mapuser;
for (int i = 0; i < MAPS; i++)
if (m[i].StartsWith(map, StringComparison.InvariantCultureIgnoreCase))
return i;
return -1;
}
public override void OnServerLoad()
{
// ...
GetRotation();
// ...
}
public override void OnMapChange()
{
// ...
int prevmap = GetMapByName(GetDvar("mapname"), true);
//LogWrite("----------------------------------------------\nNEW MAP: " + mapuser[prevmap].ToUpperInvariant() + "\n----------------------------------------------");
repeat:
nextmap = FindMap(1 + rnd.Next(range));
if (prevmap == nextmap) { goto repeat; }
SetMap(mapdev[nextmap]);
// ...
}
In sv_config.ini:
Code: [Yu]
dspl=default // your dspl-file
dsr=FFA_default // your dsr-file
weights= 3, 2, 5, 3, 5, 2, 5, 3, 2, 5, 5, 3, 2, 3, 2, 5 // your map weights
The higher the weight, the more likely choice a map as the next map.
Posts: 56
Threads: 3
Joined: Feb 2012
Reputation:
0
Any chance you could compile it and upload the dll? I don't have the tools to do it myself. Thanks either way for the work you've shared
Posts: 76
Threads: 12
Joined: Feb 2012
Reputation:
0
02-26-2012, 02:08
(This post was last modified: 02-26-2012, 02:12 by Dumas.)
Quote:
In sv_config.ini:
Code: [Yu]
dspl=default // your dspl-file
dsr=FFA_default // your dsr-file
weights= 3, 2, 5, 3, 5, 2, 5, 3, 2, 5, 5, 3, 2, 3, 2, 5 // your map weights
The higher the weight, the more likely choice a map as the next map.
I can use simple 1,2,3,4....14,15,16 weights??
Thank you
Posts: 124
Threads: 6
Joined: Dec 2011
Reputation:
14
@ Dumas
Any non-negative integers.
Release here. Enjoy
|