Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Request Map Rotation
#11
Yes.
However, it is somewhat outdated. If you want, I'll post the new version.
Reply

#12
yes that would be great
and how work? just read map rotation in order or need edit weight?
Reply

#13
CSHARP Code
  1. const int MAPS = 16;
  2. 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" };
  3. string[] mapuser = { "lockdown", "bootleg", "mission", "carbon", "dome", "downturn", "hardhat", "interchange", "fallen", "bakaara", "resistance", "arkaden", "outpost", "seatown", "underground", "village" };
  4. int[] maprange = new int[MAPS];
  5. int range;
  6. int nextmap = -1;
  7. string dspl, dsr;
  8. Random rnd = new Random(unchecked((int)DateTime.Now.Ticks));
  9.  
  10. void GetRotation()
  11. {
  12. dspl = GetServerCFG("Yu", "dspl", "default") + ".dspl";
  13. dsr = GetServerCFG("Yu", "dsr", "FFA_default");
  14. 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);
  15. for (int i = 0; i < MAPS; i++)
  16. {
  17. range += int.Parse(weights[i]);
  18. maprange[i] = range;
  19. }
  20. }
  21.  
  22. int FindMap(int r)
  23. {
  24. for (int i = 0; i < MAPS; i++)
  25. if (r <= maprange[i])
  26. return i;
  27. return -1;
  28. }
  29.  
  30. void SetMap(string map)
  31. {
  32. File.WriteAllText(@"admin\" + dspl, map + "," + dsr + ",1");
  33. }
  34.  
  35. int GetMapByName(string map, bool dev = false)
  36. {
  37. string[] m = dev ? mapdev : mapuser;
  38. for (int i = 0; i < MAPS; i++)
  39. if (m[i].StartsWith(map, StringComparison.InvariantCultureIgnoreCase))
  40. return i;
  41. return -1;
  42. }
  43.  
  44. public override void OnServerLoad()
  45. {
  46. // ...
  47. GetRotation();
  48. // ...
  49. }
  50.  
  51. public override void OnMapChange()
  52. {
  53. // ...
  54. int prevmap = GetMapByName(GetDvar("mapname"), true);
  55. //LogWrite("----------------------------------------------\nNEW MAP: " + mapuser[prevmap].ToUpperInvariant() + "\n----------------------------------------------");
  56. repeat:
  57. nextmap = FindMap(1 + rnd.Next(range));
  58. if (prevmap == nextmap) { goto repeat; }
  59. SetMap(mapdev[nextmap]);
  60. // ...
  61. }




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.
Reply

#14
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 Smile
Reply

#15
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 Big Grin
Reply

#16
@Dumas
Any non-negative integers.

Release here. Enjoy Wink
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
  bypass map rotation limit kerm007 3 2,784 07-22-2012, 15:23
Last Post: surtek
  [Release] How to add new maps to rotation ;) hillbilly 7 5,989 06-22-2012, 15:24
Last Post: hillbilly
  Crash After First Map Rotation worldclass 6 3,678 06-08-2012, 21:50
Last Post: SuperNovaAO
  Crash After First Map Rotation worldclass 6 3,593 06-08-2012, 20:30
Last Post: SuperNovaAO
  map rotation blueberry9 3 1,866 04-11-2012, 00:40
Last Post: blueberry9
  Help Map rotation - maps are random only? choobie 4 2,555 03-16-2012, 02:06
Last Post: Predje
  mw3 map rotation configurator kerm007 2 2,200 03-01-2012, 02:53
Last Post: kerm007
  Rcon & map rotation xcondex 5 3,811 02-25-2012, 16:45
Last Post: xcondex

Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2024 Melroy van den Berg.