Official Soldat Forums
Server Talk => Scripting Releases => Topic started by: cooz on November 30, 2006, 08:19:15 am
-
Script Name: multiMode
Script Description: script allowing server to run multiple game modes, one after another
Original Author: cooz
Core Version: 2.5.2
const
//Teams
ALPHA = 1;
BRAVO = 2;
CHARLIE = 3;
DELTA = 4;
SPECTATOR = 5;
//Game Modes
DEATHMATCH = 0;
POINTMATCH = 1;
TEAMMATCH = 2;
CTF = 3;
RAMBO = 4;
INF = 5;
HTF = 6;
SERVER = 255;
MODE_COUNT = 7; //change to number of elements in km[] array (number of modes choosed to run)
Â
var
 mlist: string;
 i,izm,modenr: integer;
 km: array of integer;
function modeName(mint: integer): string;
begin
 case mint of
  0: result:= 'dm';
  1: result:= 'pm';
  2: result:= 'tm';
  3: result:= 'ctf';
  4: result:= 'rambo';
  5: result:= 'inf';
  6: result:= 'htf';
 end;
end;
procedure ActivateServer();
begin
 km:=[CTF, RAMBO, TEAMMATCH, POINTMATCH, DEATHMATCH, INF, HTF]; //edit this line, to choose modes which will run on server and to set order of them
 izm:=0;
 mlist:= readfile('maps_'+modeName(km[0])+'.txt');
 for i:=1 to length(mlist) do begin
  if mlist[i]=chr(13) then izm:=izm+1;
 end;
 writefile('mapslist.txt',mlist);
 command('/loadlist mapslist');
end;
procedure onMapChange();
label jump;
begin
 izm:=izm-1;
 if(izm=0) then begin
  command('/say this is last map,');
  command('/say after it game mode will change');
 end;
Â
 if(izm<0) then begin
  izm:=0;
  jump:
  modenr:=(modenr+1) mod MODE_COUNT;
  mlist:= readfile('maps_'+modeName(km[modenr])+'.txt');
  for i:=1 to length(mlist) do if mlist[i]=chr(13) then izm:=izm+1;
  if length(mlist)<1 then goto jump;
  writefile('mapslist.txt',mlist);
  command('/loadlist mapslist');
  command('/gamemode '+inttostr(km[modenr]));
 end;
end;
procedure AppOnIdle(Ticks: integer);
begin
 if((TimeLeft+1=TimeLimit*60)) then onMapChange();
 if((TimeLeft=10)and(izm=0)) then command('/say Server wil restart in 10 seconds');
 if((TimeLeft=1)and(izm=0)) then command('/say Server is restarting, Please rejoin');
end;
procedure OnCommand(ID: integer;Text: string);
begin
 if copy(Text,1,5)='/map ' then begin
  izm:=izm+1;
 end;
end;
notes:
first of all, it's not final version but i've tested it and it work quite good,
script has to be pasted into core.pas as it use gamemodes conts from it,
you have to create separate files for each gamemode:
maps_ctf.txt - for capture the flag maps
maps_dm.txt - for deathmatch maps
maps_htf.txt - for hold the flag maps
maps_inf.txt - for infiltration maps
maps_pm.txt - for pointmatch maps
maps_rambo.txt - for rambomatch maps
maps_tm.txt - for teammatch maps
to those files write normal list of maps as you would do with mapslist.txt
eg in maps_ctf.txt can be:
ctf_Kampf
ctf_Voland
ctf_Ash
and maps_inf.txt:
inf_Abel
inf_Fortress
by editing line:Â km:=[CTF, RAMBO...]; you can choose which modes will be played on your server and in what order
script made for Avarax request - yeah, you had to wait 'few days' ;)
any suggestions, bugs...? post them here ::)
02.12.2006:
- one code typo corrected
06.12.2006:
- modified a little count down method, should look better now
- put comments to single lines, yeah :P
-
k... with the first MotW non-CTF map i'll test it on the Selfkill MotW Public. :)
big thanks for spending such time on that :D
-
(http://img354.imageshack.us/img354/7194/serverzy0.th.png) (http://img354.imageshack.us/img354/7194/serverzy0.png)
??? ??? ??? ??? ???
CORE.PAS :
const
//Teams
ALPHA = 1;
BRAVO = 2;
CHARLIE = 3;
DELTA = 4;
SPECTATOR = 5;
//Game Modes
DEATHMATCH = 0;
POINTMATCH = 1;
TEAMMATCH = 2;
CTF = 3;
RAMBO = 4;
INF = 5;
HTF = 6;
SERVER = 255;
MODE_COUNT = 2; //change to number of elements in km[] array
//(number of modes choosed to run)
var
mlist: string;
i,izm,modenr: integer;
km: array of integer;
function modeName(mint: integer): string;
begin
case mint of
0: result:= 'dm';
1: result:= 'pm';
2: result:= 'tm';
3: result:= 'ctf';
4: result:= 'rambo';
5: result:= 'inf';
6: result:= 'htf';
end;
end;
procedure ActivateServer();
begin
//edit this line, to choose modes
km:=[CTF, RAMBO]; //which will run on server
//and to set order of them
izm:=0;
mlist:= readfile('maps_'+modeName(km[0])+'.txt');
for i:=1 to length(mlist) do begin
if mlist[i]=chr(13) then izm:=izm+1;
end;
writefile('mapslist.txt',mlist);
command('/loadlist mapslist');
end;
procedure onMapChange();
label jump;
begin
izm:=izm-1;
if(izm=0) then begin
command('/say this is last map,');
command('/say after it game mode will change');
end;
if(izm<0) then begin
izm:=0;
jump:
modenr:=(modenr+1) mod MODE_COUNT;
mlist:= readfile('maps_'+modeName(km[modenr])+'.txt');
for i:=1 to length(mlist) do if mlist[i]=chr(13) then izm:=izm+1;
if length(mlist)<1 then goto jump;
writefile('mapslist.txt',mlist);
command('/loadlist mapslist');
command('/gamemode '+inttostr(km[modenr]));
end;
end;
procedure AppOnIdle(Ticks: integer);
begin
if((TimeLeft+1=TimeLimit*60)) then onMapChange();
if((TimeLeft=5)and(izm=0)) then command('/say Server wil restart in 5 seconds');
if((TimeLeft=4)and(izm=0)) then command('/say Server wil restart in 4 seconds');
if((TimeLeft=3)and(izm=0)) then command('/say Server wil restart in 3 seconds');
if((TimeLeft=2)and(izm=0)) then command('/say Server wil restart in 2 seconds');
if((TimeLeft=1)and(izm=0)) then command('/say Server wil restart in 1 seconds');
if((TimeLeft=1)and(izm=0)) then command('/say Server is restarting, Please rejoin');
end;
end;
procedure OnCommand(ID: integer;Text: string);
begin
if copy(Text,1,5)='/map ' then begin
izm:=izm+1;
end;
end;
-
i have no idea how did it do it, but i did it again :(
...
there shouldn't be one 'end;' in AppOnIdle()
replace it with:
procedure AppOnIdle(Ticks: integer);
begin
if((TimeLeft+1=TimeLimit*60)) then onMapChange();
if((TimeLeft=5)and(izm=0)) then command('/say Server wil restart in 5 seconds');
if((TimeLeft=4)and(izm=0)) then command('/say Server wil restart in 4 seconds');
if((TimeLeft=3)and(izm=0)) then command('/say Server wil restart in 3 seconds');
if((TimeLeft=2)and(izm=0)) then command('/say Server wil restart in 2 seconds');
if((TimeLeft=1)and(izm=0)) then command('/say Server wil restart in 1 seconds');
if((TimeLeft=1)and(izm=0)) then command('/say Server is restarting, Please rejoin');
end;
and it should ok
-
does this work if the admin violently changes map with /map, will the maplist still be in correct order?
-
if map changed with /map command is in same gamemode it will work ok,
it will be added in middle of maplist...
voted maps will overwrite current map but it should work correct too
-
it's ok now. correctly running. it's a really good script. but i thougt i could run much mods at the same time. (ctf+rambo) ;D ;D ;D
-
hehe, i'm not sure how it could look,
but yeah maybe i should make second post line description of script more precise