function Split(const Source: string; const Delimiter: string): tstringarray;
var
i,x,d: integer;
s: string;
begin
d := Length(Delimiter);
x := 0;
i := 1;
SetArrayLength(Result,1);
while i <= Length(source) do begin
s := Copy(Source,i,d);
if s = Delimiter then begin
Inc(i,d);
Inc(x,1);
SetArrayLength(result,x + 1);
end else begin
Result[x] := Result[x] + Copy(s,1,1);
Inc(i,1);
end;
end;
end;
procedure OnMapChange(NewMap: string);
var
Bots: byte;
i: integer;
BotArray: tstringarray;
begin
Bots := 24;
BotArray := Split(ReadFile('NumBots.txt'),Chr(13) + Chr(10));
for i := 0 to ArrayHigh(BotArray) - 1 do if LowerCase(BotArray[i]) = LowerCase(NewMap) then begin
Bots := StrtoInt(BotArray[i + 1]);
Break;
end;
i := 32
while (i >= 1) and (Bots < NumBots) do begin
if (GetPlayerStat(i,'Active') = true) and (GetPlayerStat(i,'Human') = false) and (GetPlayerStat(i,'Name') = 'a zombie') then Command('/kick ' + InttoStr(i));
i := i - 1;
end;
while Bots > NumBots do Command('/addbot2 zombie');
end;