ItsMods

Full Version: Map Rotation
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Ello ...

Would it be possible to make a plugin that can set a certain map rotation perfectly with no random map changing at all ??

I have kinda got my rotation almost flawless BUT i do occasionally have the same map pop up every few maps..

Hope someone can make this as it drives me mad...

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[] mapweight = { 3, 2, 5, 3, 5, 2, 5, 3, 2, 5, 5, 3, 2, 3, 2, 5 };
  5. int[] maprange = new int[MAPS];
  6. int range;
  7. int nextmap = -1;
  8. Random rnd = new Random(unchecked((int)DateTime.Now.Ticks));
  9.  
  10. public override void OnServerLoad()
  11. {
  12. for (int i = 0; i < MAPS; i++)
  13. {
  14. range += mapweight[i];
  15. maprange[i] = range;
  16. }
  17. }
  18.  
  19. public override void OnMapChange()
  20. {
  21. int prevmap = nextmap;
  22. repeat:
  23. nextmap = FindMap(1 + rnd.Next(range));
  24. if (prevmap == nextmap) { goto repeat; }
  25. File.WriteAllText(@"admin/default.dspl", mapdev[nextmap] + ",FFA_All,1");
  26. }
  27.  
  28. int FindMap(int r)
  29. {
  30. for (int i = 0; i < MAPS; i++)
  31. if (r <= maprange[i])
  32. return i;
  33. return -1;
  34. }
(02-04-2012, 15:50)fookaa Wrote: [ -> ]Ello ...

Would it be possible to make a plugin that can set a certain map rotation perfectly with no random map changing at all ??

I have kinda got my rotation almost flawless BUT i do occasionally have the same map pop up every few maps..

Hope someone can make this as it drives me mad...

Not sure if this is possible since game is always checking default.dspl after each map.
(02-04-2012, 17:11)Yurio Wrote: [ -> ]
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[] mapweight = { 3, 2, 5, 3, 5, 2, 5, 3, 2, 5, 5, 3, 2, 3, 2, 5 };
  5. int[] maprange = new int[MAPS];
  6. int range;
  7. int nextmap = -1;
  8. Random rnd = new Random(unchecked((int)DateTime.Now.Ticks));
  9.  
  10. public override void OnServerLoad()
  11. {
  12. for (int i = 0; i < MAPS; i++)
  13. {
  14. range += mapweight[i];
  15. maprange[i] = range;
  16. }
  17. }
  18.  
  19. public override void OnMapChange()
  20. {
  21. int prevmap = nextmap;
  22. repeat:
  23. nextmap = FindMap(1 + rnd.Next(range));
  24. if (prevmap == nextmap) { goto repeat; }
  25. File.WriteAllText(@"admin/default.dspl", mapdev[nextmap] + ",FFA_All,1");
  26. }
  27.  
  28. int FindMap(int r)
  29. {
  30. for (int i = 0; i < MAPS; i++)
  31. if (r <= maprange[i])
  32. return i;
  33. return -1;
  34. }

So what do i do with this ?
lol, maybe compile it?
@Yurio if you don't pass a constructor parameter in the random class it will automatically take the current time as a seed.
@Pozzuh
OK. But if we want to create multiple instances with different number series? Wink
(02-04-2012, 22:20)Yurio Wrote: [ -> ]@Pozzuh
OK. But if we want to create multiple instances with different number series? Wink

Just keep using rnd.next() and it will be fine
Any development on this chapz Big Grin
and.. Yurio code work?
Pages: 1 2