Author Topic: [beta] multiMode  (Read 6962 times)

0 Members and 1 Guest are viewing this topic.

Offline cooz

  • Soldier
  • **
  • Posts: 187
  • BANNED
[beta] multiMode
« 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

Code: [Select]
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
« Last Edit: December 06, 2006, 10:24:20 am by cooz »
Dead man! Dead man walking! We got a dead man walking here! Banned man crawling more like

Offline Avarax

  • Veteran
  • *****
  • Posts: 1529
    • Official Hexer & MMod site
Re: [beta] multiMode
« Reply #1 on: November 30, 2006, 09:09:37 am »
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
I like to have one Martini
Two at the very most
Three I'm under the table
Four I'm under the host

Offline xmRipper

  • Soldat Beta Team
  • Flagrunner
  • ******
  • Posts: 742
    • Personal
Re: [beta] multiMode
« Reply #2 on: December 02, 2006, 05:28:56 am »

??? ??? ??? ??? ???

CORE.PAS :
Code: [Select]
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;
Co-Founder / CTO @ Macellan
Founder Turkish Soldat Community

Offline cooz

  • Soldier
  • **
  • Posts: 187
  • BANNED
Re: [beta] multiMode
« Reply #3 on: December 02, 2006, 05:52:26 am »
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:
Code: [Select]
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
Dead man! Dead man walking! We got a dead man walking here! Banned man crawling more like

Offline Avarax

  • Veteran
  • *****
  • Posts: 1529
    • Official Hexer & MMod site
Re: [beta] multiMode
« Reply #4 on: December 02, 2006, 09:25:12 am »
does this work if the admin violently changes map with /map, will the maplist still be in correct order?
I like to have one Martini
Two at the very most
Three I'm under the table
Four I'm under the host

Offline cooz

  • Soldier
  • **
  • Posts: 187
  • BANNED
Re: [beta] multiMode
« Reply #5 on: December 02, 2006, 11:02:45 am »
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
Dead man! Dead man walking! We got a dead man walking here! Banned man crawling more like

Offline xmRipper

  • Soldat Beta Team
  • Flagrunner
  • ******
  • Posts: 742
    • Personal
Re: [beta] multiMode
« Reply #6 on: December 02, 2006, 11:37:46 am »
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
« Last Edit: December 02, 2006, 11:41:34 am by xmRipper »
Co-Founder / CTO @ Macellan
Founder Turkish Soldat Community

Offline cooz

  • Soldier
  • **
  • Posts: 187
  • BANNED
Re: [beta] multiMode
« Reply #7 on: December 02, 2006, 02:49:01 pm »
hehe, i'm not sure how it could look,

but yeah maybe i should make second post line description of script more precise
Dead man! Dead man walking! We got a dead man walking here! Banned man crawling more like