Author Topic: [Request] Change mapslist according to players number  (Read 661 times)

0 Members and 1 Guest are viewing this topic.

Offline Leo

  • Soldat Beta Team
  • Veteran
  • ******
  • Posts: 1011
[Request] Change mapslist according to players number
« on: January 17, 2008, 09:03:43 am »
Someone can make a script where the mapslist changes according to the number of players in server ? So that if number of players is equal or less than a number that can be changed at the script the mapslist.txt will be used, if the number of players is larger than this number then mapslist2.txt will be used. You get the point :)

Offline xmRipper

  • Soldat Beta Team
  • Flagrunner
  • ******
  • Posts: 742
    • Personal
Re: [Request] Change mapslist according to players number
« Reply #1 on: January 17, 2008, 09:49:18 am »
Code: [Select]
var
  CurrentMapsList: String;
 
const
  MAPSLIST1 = 'mapslist';    // mapslist.txt
  MAPSLIST2 = 'mapslist2';  // mapslist2.txt
  PLAYERLIMIT = 10;           // Player limit for change mapslist.
 
procedure AppOnIdle(Ticks: integer);
begin
  CurrentMapsList := MAPSLIST1;
end;

procedure OnJoinGame(ID, Team: byte);
begin
  if (NumPlayers > PLAYERLIMIT) and (CurrentMapsList = MAPSLIST1) then Begin
        Command('/loadlist '+MAPSLIST2);
CurrentMapsList := MAPSLIST2;
WriteLn(MAPSLIST2+' Loaded');
  end;
end;

procedure OnLeaveGame(ID, Team: byte; Kicked: boolean);
begin
  if (NumPlayers < PLAYERLIMIT) and (CurrentMapsList = MAPSLIST2) then begin
        Command('/loadlist '+MAPSLIST1);
CurrentMapsList := MAPSLIST1;
WriteLn(MAPSLIST1+' Loaded');
  end;
end;

I dont test it. But should be work.
« Last Edit: January 17, 2008, 09:56:10 am by xmRipper »
Co-Founder / CTO @ Macellan
Founder Turkish Soldat Community

Offline rhide

  • Major
  • *
  • Posts: 60
  • Coffee-addict
    • Vrastar-Hai soldat clan
Re: [Request] Change mapslist according to players number
« Reply #2 on: January 17, 2008, 01:49:52 pm »
I thought it would be neater if you could add any number of maps instead of just 2. I just hacked this together, so it's not testet througly, but at least it works.

In soldat.ini: add a new tag in the end of the file saying [MAPS]. There, just add the number of maplists you would want, and for each of them, the number of players for wich they should activate. Use this template:

[MAPS]
Maplist1_Players = 2
Maplist1_Filename = maplist_2players.txt
Maplist2_Players = 6
Maplist2_Filename = maplist_6players.txt
Maplist3_Players = 12
Maplist3_Filename = maplist_12players.txt

Now, when the server has 2-5 players it uses maplist_2players.txt, then when there are 6-11 players it uses maplist_6players.txt and if there are 12 or more it uses maplist_12players.txt.

I'd be happy to hear of any bugs! Thanks :)

EDIT 1:
Code: [Select]
const
   MAX_MAPLISTS = 128;
If you create more maplists than MAX_MAPLISTS without changing this variable, they will simply be ignored. The maplist designed for MOST players have highest prioity, and then falling.


EDIT 2:
I forgot to mention, if there is 0-1 players online, the script uses default maplist.
« Last Edit: January 17, 2008, 01:57:17 pm by rhide »
Warning! Division by zero seriously injures yourself and the people in your surroundings.

Proud member of Vrastar-Hai:
http://www.guldheden.com/~erga050/vrastar-hai

Offline Leo

  • Soldat Beta Team
  • Veteran
  • ******
  • Posts: 1011
Re: [Request] Change mapslist according to players number
« Reply #3 on: January 18, 2008, 05:30:08 am »
Thanks guys :D

Date Posted: January 17, 2008, 11:51:39 am
Hmm... I am using xmRipper's script but it seems there is a problem. Map doesn't change to next when timelimit hits  ???

Offline xmRipper

  • Soldat Beta Team
  • Flagrunner
  • ******
  • Posts: 742
    • Personal
Re: [Request] Change mapslist according to players number
« Reply #4 on: January 18, 2008, 06:15:34 am »
Tested.
Its working on me perfectly. There is not any problem.
Co-Founder / CTO @ Macellan
Founder Turkish Soldat Community