Advertisement
Bendarr

Bendarr

Aug 17th, 2009
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 37.79 KB | None | 0 0
  1. const
  2. FlagballMap = 'htf_FB_Classic3';
  3. ReturnOnScore = false; // moves the flag onto it's spawn point when a team scores
  4. AutoStart = false;
  5. AutoEnd = false;
  6. AdminCommands = true; // admin / commands
  7. PublicCommandsSlash = false; // public / commands
  8. PublicCommandsExcla = false; // ! commands
  9. BotName = 'Boogie Man';
  10. AppOnIdleInterval = 10; // 6 times per second (60 ticks/sec) / (10)
  11. FoulColor = $FF00FF00;
  12. AccidentalScoring = false;
  13. ReturnMessage = false; // after score; "Head back to the 40 yard mark, <team name>"
  14. FlagReadyMessage = false; // once players are allowed past the 40 yard mark (flag exits goalie area)
  15.  
  16. WelcomeColor = $FFFBDA22;
  17. SayColor = $FF9C9F9F;
  18.  
  19. SuccessColor = $FF0FA0C6;
  20. YieldColor = $FF7FBFBF;
  21. ErrorColor = $FFBF7F7F;
  22.  
  23. PublicPassword = true;
  24. UnpauseCounterInitial = 3;
  25. SayName = true;
  26. BigConsole = true;
  27.  
  28. type
  29. TPlayer = record
  30. JoinGame: boolean;
  31. end;
  32.  
  33.  
  34. var
  35. ActivateVariables, Passworded, KillAfter, CheckKillAfter, Ignore, StopNext, EndGame, SayMap, AlphaAlive, BravoAlive, MapsOnOff, Scored, StartOnIdle, DoubleCaps: boolean;
  36. HighestID, Gamemode, UnpauseCounter, LastTouch, teami, LastKill, LastDeath, AlphaNumber, BravoNumber: byte;
  37. DisablePlayerScore: array[1..32] of boolean;
  38. Players: array[1..32] of TPlayer;
  39. TextWidth : array[32..127] of single;
  40. Captures: array[1..32] of byte;
  41. Kills, Deaths: array[1..32] of word;
  42. pmvar: integer;
  43.  
  44.  
  45.  
  46. procedure Greet(const Id: byte);
  47. begin
  48.    WriteConsole(Id, 'Welcome to ' + ServerName + '!', WelcomeColor);
  49.    WriteConsole(Id, 'forums.soldatrs.com - Home of Realistic / Survival', WelcomeColor);
  50.    WriteConsole(Id, '              - Current Admin List -', WelcomeColor);
  51.    WriteConsole(Id, ' Bendarr, Merox, DorkeyDear, Chikka, DutchFlame, Scream', WelcomeColor);
  52.    WriteConsole(Id, ' Ant, JRedcorn, T-Boner, Lourenzo, CharlieCypher, Richmeister24', WelcomeColor);
  53. end;
  54.  
  55.  
  56. Procedure SetHighestID();
  57. var
  58.    i: byte;
  59. begin
  60. HighestID := 1
  61.    for i := 1 to 32 do
  62.    if i > HighestID then
  63.    HighestID := i
  64. end;
  65.  
  66. // by J-Factor, modified by Curt (DorkeyDear)
  67. procedure DrawTextCenter(const Id: byte; Text: string; const Delay: integer; const Color: longint; const Scale: single; const XCoord, YCoord: integer);
  68. var
  69.    i, c : byte;
  70.    TotalWidth, Width, Height : single;
  71. begin
  72.    TotalWidth := 0;
  73.    Width := 0;
  74.    Height := 202;
  75.    for i := 1 to length(Text) do begin
  76.    c := ord(Text[i]);
  77.    if ((c > 31) and (c < 128)) then begin
  78.      Width := Width + TextWidth[c];
  79.    if (Width > TotalWidth) then
  80.      TotalWidth := Width;
  81. end else if (c = 13) then begin
  82.   Height := Height + 202;
  83. Width := 0;
  84. end;
  85. end;
  86. DrawText(ID, Copy(Text, 1, 58) + iif(Length(Text) <= 3, '  ', ''), Delay, Color, Scale, XCoord - Round(TotalWidth * Scale / 2), YCoord - Round(Height * Scale / 2));
  87. end;
  88.  
  89.  
  90. procedure Big(const Id: byte; const Text: string; const Color: longint);
  91. var
  92.    Size: single;
  93. begin
  94.    Size := 3.5 / Length(Text);
  95.    if (Size > 0.33) then
  96.      Size := 0.33;
  97.    DrawTextCenter(Id, Text, 9 * Length(Text) + 85, Color, Size, 320, 360);
  98. end;
  99.  
  100.  
  101. function StrrPos(const Substr, S: string): integer;
  102. begin
  103.    for Result := Length(S) - Length(Substr) + 1 downto 1 do
  104.    if (Copy(S, Result, Length(Substr)) = Substr) then
  105.      exit;
  106.    Result := 0;
  107. end;
  108.  
  109.  
  110. procedure Say(const Id: byte; const Text: string; const Color: longint);
  111. var
  112.    Pos: integer;
  113. begin
  114.    if (Length(Text) <= 72) then
  115.      WriteConsole(Id, Text, Color)
  116.    else begin
  117.    Pos := StrrPos(' ', Copy(Text, 1, 72));
  118.    if (Pos = 0) then begin
  119.      Pos := 72;
  120.    WriteConsole(Id, Copy(Text, 1, 72), Color);
  121. end else
  122. WriteConsole(Id, Copy(Text, 1, Pos - 1), Color);
  123. Say(Id, Copy(Text, Pos + 1, Length(Text)), Color);
  124. end;
  125. end;
  126.  
  127.  
  128. procedure Move(Name: string; Team: byte);
  129. var
  130.    i: byte;
  131. begin
  132.    Name := LowerCase(Name);
  133.    for i := 1 to HighestID do
  134.    if (GetPlayerStat(i, 'Active') = true) then
  135.      if (((Name = '') or (ContainsString(LowerCase(GetPlayerStat(i, 'Name')), Name))) and (GetPlayerStat(i, 'Team') <> Team)) then
  136.      Command('/setteam' + InttoStr(Team) + ' ' + InttoStr(i));
  137. end;
  138.  
  139. procedure SwapTeams;
  140. var
  141.    i: byte;
  142. begin
  143.    for i := 1 to HighestID do
  144.    if GetPlayerStat(i, 'Active') then
  145.      if GetPlayerStat(i, 'Team') = 1 then
  146.      Command('/setteam2 ' + inttostr(i))
  147.    else
  148.      if GetPlayerStat(i, 'Team') = 2 then
  149.      Command('/setteam1 ' + inttostr(i));
  150. end;
  151.  
  152. procedure SpectateAll;
  153. var
  154.    i: byte;
  155. begin
  156.    for i := 1 to HighestID do
  157.    if GetPlayerStat(i, 'Active') then
  158.      if GetPlayerStat(i, 'Team') <> 5 then
  159.      if (GetPlayerStat(i, 'Human') = true) then
  160.      Command('/setteam5 ' + inttostr(i))
  161. end;
  162.  
  163.  
  164. function GetBall(): byte;
  165. var
  166.    i: byte;
  167. begin
  168.    Result := 255;
  169.    for i := 0 to 128 do
  170.    if (GetObjectStat(i, 'Active') = true) then
  171.      if (GetObjectStat(i, 'Style') = 3) then begin
  172.      Result := i;
  173.    exit;
  174. end;
  175. end;
  176.  
  177. procedure ReturnFlag();
  178. var
  179.    i: byte;
  180. begin
  181.    i := GetBall();
  182.    if (i <> 255) then
  183.      KillObject(i);
  184. end;
  185.  
  186.  
  187. function GamemodeName(const Gamemode: byte): string;
  188. begin
  189.    case (Gamemode) of
  190.    0:
  191.    Result := 'Deathmatch';
  192.    1:
  193.    Result := 'Pointmatch';
  194.    2:
  195.    Result := 'Team Deathmatch';
  196.    3:
  197.    Result := 'Capture the Flag';
  198.    4:
  199.    Result := 'Rambo Match';
  200.    5:
  201.    Result := 'Infiltration';
  202.    6:
  203.    Result := 'Hold the Flag';
  204. end;
  205. end;
  206.  
  207. function TeamName(const Team: byte): string;
  208. begin
  209.    case (Team) of
  210.    0:
  211.    Result := 'Deathmatch';
  212.    1:
  213.    Result := 'Alpha';
  214.    2:
  215.    Result := 'Bravo';
  216.    3:
  217.    Result := 'Charlie';
  218.    4:
  219.    Result := 'Delta';
  220.    5:
  221.    Result := 'Spectator';
  222. end;
  223. end;
  224.  
  225. procedure WriteConsole2(const Id: byte; const Text: string; Color: longint);
  226. begin
  227. if (Id = 0) then begin
  228. WriteConsole(0, Text, Color);
  229. WriteLn(Text);
  230. end else if (Id = 255) then
  231.   WriteLn(Text)
  232. else if ((Id >= 1) and (Id <= 32)) then
  233.   if (GetPlayerStat(Id, 'Active') = true) then
  234.   WriteConsole(Id, Text, Color);
  235. end;
  236.  
  237.  
  238. function ScoreColor(const Team: byte): longint;
  239. begin
  240.    case (Team) of
  241.    1:
  242.    Result := $FFDF3131;
  243.    2:
  244.    Result := $FF3131DF;
  245.    else
  246.    Result := $FFFFFFFF;
  247. end;
  248. end;
  249.  
  250. function TeamScore(const Team: byte): word;
  251. begin
  252.    case (Team) of
  253.    1:
  254.    Result := AlphaScore;
  255.    2:
  256.    Result := BravoScore;
  257.    3:
  258.    Result := CharlieScore;
  259.    4:
  260.    Result := DeltaScore;
  261. end;
  262. end;
  263.  
  264. function Explode(Source: string; const Delimiter: string): array of string;
  265. var
  266.    Position, DelLength, ResLength: integer;
  267. begin
  268.    DelLength := Length(Delimiter);
  269.    Source := Source + Delimiter;
  270.    repeat
  271.    Position := Pos(Delimiter, Source);
  272.    SetArrayLength(Result, ResLength + 1);
  273.    Result[ResLength] := Copy(Source, 1, Position - 1);
  274.    ResLength := ResLength + 1;
  275.    Delete(Source, 1, Position + DelLength - 1);
  276.    until (Position = 0);
  277.    SetArrayLength(Result, ResLength - 1);
  278. end;
  279.  
  280. function MapsListFile(): string;
  281. begin
  282.    if (Gamemode = 6) then
  283.      Result := 'mapslistFB.txt'
  284.    else if (Gamemode = 2) then
  285.      Result := 'mapslistTM.txt'
  286.    else if (Gamemode = 3) then
  287.      Result := 'mapslist.txt';
  288. end;
  289.  
  290. function GetRandomMap(forbidden: string): string;
  291. var
  292.    MapList: array of string;
  293.    n,x: integer;
  294. begin
  295.    MapList:=Explode(ReadFile(MapsListFile()),#13#10);
  296.    n := 0;
  297.    repeat
  298.    if (n = 50) then begin
  299.    WriteLn('GetRandomMap fails');
  300.    exit;
  301. end;
  302. x := Random(0, GetArrayLength(MapList) - 1);
  303. n := n + 1;
  304. until ((MapList[x] <> '') and (MapList[x] <> forbidden));
  305. Result := MapList[x];
  306. {
  307. n:=GetArrayLength(MapList);
  308. If n > 0 then
  309. while true do begin
  310. x:=random(0,n-1);
  311. If MapList[x] <> forbidden then begin
  312.   result:=MapList[x];
  313. exit;
  314. end;
  315. end
  316. else
  317. WriteLn('GetRandomMap fails');
  318. }
  319. end;
  320.  
  321.  
  322.  
  323. procedure FixScore(const Team: byte);
  324. var
  325.    i: byte;
  326. begin
  327.    AlphaAlive := false;
  328.    BravoAlive := false;
  329.    for i := 1 to HighestID do
  330.    if (GetPlayerStat(i, 'Active') = true) then
  331.      if (GetPlayerStat(i, 'Alive') = true) then begin
  332.      if (GetPlayerStat(i, 'Team') = 1) then
  333.      AlphaAlive := true;
  334.    if (GetPlayerStat(i, 'Team') = 2) then
  335.      BravoAlive := true;
  336.    if ((AlphaAlive) and (BravoAlive)) then begin
  337.      StopNext := false;
  338.    exit;
  339. end;
  340. end;
  341. if (AlphaAlive) and (not BravoAlive) and (Team <> 5) then begin
  342.   SetTeamScore(1, AlphaScore - 1)
  343. end else if (BravoAlive) and (not AlphaAlive) and (Team <> 5) then begin
  344.   SetTeamScore(2, BravoScore - 1)
  345. end;
  346. StopNext := false
  347. end;
  348.  
  349. function CountPlayers(): byte;
  350. var
  351.    i: byte;
  352. begin
  353.    for i := 1 to HighestID do
  354.    if (GetPlayerStat(i, 'Active') = true) and (GetPlayerStat(i, 'Team') < 5) then
  355.      Result := Result + 1
  356. end;
  357.  
  358. procedure CountTeams();
  359. var
  360.    i: byte;
  361. begin
  362. AlphaNumber := 0
  363. BravoNumber := 0
  364. for i := 1 to HighestID do begin
  365. if (GetPlayerStat(i, 'Active') = true) then
  366.   if (GetPlayerStat(i, 'Alive') = true) then
  367.   if (GetPlayerStat(i, 'Team') = 1) then
  368.   AlphaNumber := AlphaNumber + 1
  369. else if (GetPlayerStat(i, 'Team') = 2) then
  370.   BravoNumber := BravoNumber + 1
  371. end;
  372. end;
  373.  
  374. procedure KillAlpha();
  375. var
  376.    i: byte;
  377. begin
  378.    for i := 1 to HighestID do
  379.    if (GetPlayerStat(i, 'Active') = true) then
  380.      if (GetPlayerStat(i, 'Alive') = true) then
  381.      if i <> LastKill then
  382.      DoDamage(i, 4000)
  383. end;
  384.  
  385. procedure KillBravo();
  386. var
  387.    i: byte;
  388. begin
  389.    for i := 1 to HighestID do
  390.    if (GetPlayerStat(i, 'Active') = true) then
  391.      if (GetPlayerStat(i, 'Alive') = true) then
  392.      if i <> LastKill then
  393.      DoDamage(i, 4000)
  394. end;
  395.  
  396. procedure AnnounceWinner();
  397. var
  398.    i: byte;
  399. begin
  400. for i := 1 to HighestID do begin
  401. if AlphaScore > BravoScore then
  402.   if (GetPlayerStat(i, 'Active') = true) then
  403.   if (GetPlayerStat(i, 'Team') = 1) then
  404. Big(0, (GetPlayerStat(i, 'Name')) + ' has won!', $FFFF0000)
  405. //E15353 5353E1
  406. if BravoScore > AlphaScore then
  407.   if (GetPlayerStat(i, 'Active') = true) then
  408.   if (GetPlayerStat(i, 'Team') = 2) then
  409. Big(0, (GetPlayerStat(i, 'Name')) + ' has won!', $FF0000FF)
  410. end;
  411. end;
  412.  
  413.  
  414. procedure AnnounceAlpha();
  415. var
  416.    i: byte;
  417. begin
  418.    for i := 1 to HighestID do
  419.    if (GetPlayerStat(i, 'Active') = true) then
  420.      if i <> LastKill then
  421.      if i <> LastDeath then
  422.    Big(i, 'Alpha team wins!', $FFFF0000);
  423. end;
  424.  
  425. procedure AnnounceBravo();
  426. var
  427.    i: byte;
  428. begin
  429.    for i := 1 to HighestID do
  430.    if (GetPlayerStat(i, 'Active') = true) then
  431.      if i <> LastKill then
  432.      if i <> LastDeath then
  433.    Big(i, 'Bravo team wins!', $FF0000FF);
  434. end;
  435.  
  436. function HighestSingles(const Data: array of single): array of integer;
  437. var
  438.    i: integer;
  439. begin
  440. if (GetArrayLength(Data) > 0) then begin
  441.   Result := [0];
  442. if (GetArrayLength(Data) > 1) then
  443. for i := 1 to GetArrayLength(Data) - 1 do begin
  444. if (Data[i] > Data[Result[0]]) then
  445.   Result := [i]
  446. else if (Data[i] = Data[Result[0]]) then begin
  447. SetArrayLength(Result, GetArrayLength(Result) + 1);
  448. Result[GetArrayLength(Result) - 1] := i;
  449. end;
  450. end;
  451. end;
  452. end;
  453.  
  454. procedure FindMVP();
  455. var
  456.    i, j: byte;
  457.    Scores: array of single;
  458.    PlayersScores: array of byte;
  459.    MVPs: array of integer;
  460. begin
  461.    for i := 1 to HighestID do
  462.    if (GetPlayerStat(i, 'Active') = true) then begin
  463.      Kills[i] := GetPlayerStat(i, 'Kills');
  464.    if (Kills[i] > 0) then begin
  465.    Deaths[i] := GetPlayerStat(i, 'Deaths');
  466.    Captures[i] := GetPlayerStat(i, 'Flags');
  467.    SetArrayLength(Scores, j + 1);
  468.    SetArrayLength(PlayersScores, j + 1);
  469.    Scores[j] := (Captures[i] + 1.0) * (Kills[i] + 1.0) / (Deaths[i] + 1.0);
  470.    PlayersScores[j] := i;
  471.    j := j + 1;
  472. end;
  473. end;
  474. MVPs := HighestSingles(Scores);
  475. if (GetArrayLength(MVPs) = 0) then
  476. WriteConsole(0, 'No MVPs...', YieldColor)
  477. else begin
  478.   if (GetArrayLength(MVPs) > 1) then
  479. WriteConsole(0, 'Tie for MVP!', YieldColor);
  480. for i := 0 to GetArrayLength(MVPs) - 1 do
  481. WriteConsole(0, 'MVP: ' + GetPlayerStat(PlayersScores[MVPs[i]], 'Name'), YieldColor);
  482. end;
  483. end;
  484.  
  485.  
  486.  
  487. procedure Stop();
  488. begin
  489. if (not Ignore) then begin
  490. WriteConsole(0, 'Game stopped...', $FFFFFFFF);
  491. WriteConsole(0, 'Rejoin to play CTF.', $FFFFFFFF);
  492. end;
  493. Command('/loadlist mapslist');
  494. Command('/loadcon soldat.ini');
  495. Command('/password');
  496. if (not Ignore) then begin
  497.   GameStyle := 3
  498. Password := ''
  499. ActivateVariables := true;
  500. end;
  501. end;
  502.  
  503.  
  504. procedure Start();
  505. begin
  506.    WriteConsole(0, 'Flagball starting, please rejoin...', $FFFFFFFF);
  507.    Ignore := true;
  508.    Stop();
  509.    Ignore := false;
  510.    Command('/loadlist mapslistFB');
  511.    Command('/loadcon flagball.ini');
  512.    Command('/password');
  513.    ActivateVariables := true;
  514. end;
  515.  
  516. procedure StartTM();
  517. begin
  518.    WriteConsole(0, 'Teammatch starting, please rejoin...', $FFFFFFFF);
  519.    Ignore := true;
  520.    Stop();
  521.    Ignore := false;
  522.    Command('/loadlist mapslistTM');
  523.    Command('/loadcon teammatch.ini');
  524.    Command('/password');
  525.    ActivateVariables := true;
  526. end;
  527.  
  528. function CheckPlayerLocation(const Id: byte): boolean;
  529. begin
  530.    if (GetPlayerStat(Id, 'Alive') = false) then
  531.      exit;
  532.    case (GetPlayerStat(Id, 'Team')) of
  533.    1:
  534.    Result := GetPlayerStat(Id, 'X') < -712;
  535.    2:
  536.    Result := GetPlayerStat(Id, 'X') > 712;
  537. end;
  538. if (Result) then begin
  539. DisablePlayerScore[Id] := true;
  540. DoDamage(Id, 2009);
  541. WriteConsole(0, 'Foul! ' + GetPlayerStat(Id, 'Name') + ' inside goalie zone! Penalty: killed', FoulColor);
  542. end;
  543. end;
  544.  
  545. function CheckFlagLocation(): byte;
  546. var
  547.    Ball: byte;
  548.    X, Y: single;
  549. begin
  550.    Ball := GetBall();
  551.    if (Ball = 255) then
  552.      exit;
  553.    X := GetObjectStat(Ball, 'X');
  554.    Y := GetObjectStat(Ball, 'Y');
  555.    if ((X >= 912) and (X <= 1072) and (Y >= 624)) then
  556.      Result := 2
  557.    else if ((X >= -1072) and (X <= -912) and (Y >= 624)) then
  558.      Result := 1;
  559.    if ((Result > 0) and (not Scored)) then begin
  560.      if (DisablePlayerScore[LastTouch]) then
  561.    WriteConsole(0, 'Foul! ' + GetPlayerStat(LastTouch, 'Name') + ' scored while inside the goalie zone. Score does not count.', FoulColor)
  562.    else if ((AccidentalScoring) or (GetPlayerStat(LastTouch, 'Team') = Result)) then begin
  563.      SetTeamScore(Result, TeamScore(Result) + 1);
  564.    WriteConsole(0, GetPlayerStat(LastTouch, 'Name') + iif(GetPlayerStat(LastTouch, 'Team') = Result, '', ' accidentally') + ' scored for ' + TeamName(Result) + ' team!', ScoreColor(Result));
  565.    if (TeamScore(Result) >= ScoreLimit) then begin
  566.    WriteConsole(0, TeamName(Result) + ' won the match!', ScoreColor(Result));
  567.    DrawTextCenter(0, TeamName(Result) + ' won the match', 300, ScoreColor(Result), 0.1875, 320, 400);
  568.    Command('/restart');
  569. end else begin
  570. DrawTextCenter(0, 'Score for ' + TeamName(Result) + ' team!', 250, ScoreColor(Result), 0.171875, 320, 400);
  571. if (ReturnMessage) then
  572. WriteConsole(0, 'Head back to the 40 yard mark, ' + TeamName(3 - Result), FoulColor);
  573. if (ReturnOnScore) then
  574.   ReturnFlag();
  575. end;
  576. end;
  577. end;
  578. if (Scored) then begin
  579. Scored := (X < -710) or (X > 710);
  580. if ((not Scored) and (FlagReadyMessage)) then
  581.   WriteConsole(0, 'Flag is on the field!', FoulColor);
  582. end else
  583. Scored := Result > 0;
  584. end;
  585.  
  586.  
  587.  
  588.  
  589.  
  590. function OnPlayerCommand(Id: byte; Text: string): boolean;
  591. begin
  592.    Result := false;
  593.    if (PublicCommandsSlash) then
  594.      if ((LowerCase(Text) = '/start') or (LowerCase(Text) = '/start flagball')) then
  595.      Start()
  596.    else if (LowerCase(Text) = '/stop') then
  597.      Stop()
  598.    else if (LowerCase(Text) = '/reset') then
  599.      Command('/map ' + FlagballMap);
  600.    
  601.    if (LowerCase(Copy(Text, 1, 2)) = '/ ') then begin
  602.      for teami := 1 to HighestID do
  603.    if GetPlayerStat(teami, 'Active') then
  604.      if GetPlayerStat(teami, 'Team') = GetPlayerStat(Id, 'Team') then
  605.    Say(teami, '(' + TeamName(GetPlayerStat(teami, 'Team')) + ') ' + '[' + GetPlayerStat(Id, 'Name') + '] ' + Copy(Text, 3, Length(Text)), SuccessColor)
  606.    WriteLn('(TEAM) ' + '[' + GetPlayerStat(Id, 'Name') + '] ' + Copy(Text, 3, Length(Text)));
  607. end;
  608.  
  609. if (LowerCase(Copy(Text, 1, 4)) = '/pm ') then begin
  610.   Result := true;
  611. pmvar := strtoint(Copy(Text, 5, 1));
  612. if GetPlayerStat(pmvar, 'Active') then begin
  613.   if pmvar <> 255 then begin
  614. WriteConsole2(Id, 'To: ' + '[' + IDToName(pmvar) + '] ' + Copy(Text, 7, Length(Text)), SuccessColor);
  615. Say(pmvar, 'From: ' + '[' + GetPlayerStat(Id, 'Name') + '] ' + Copy(Text, 7, Length(Text)), SayColor);
  616. WriteLn('PM To: ' + '[' + IDToName(pmvar) + ']' + ' From: ' + '[' + GetPlayerStat(Id, 'Name') + ']' + ': ' + Copy(Text, 7, Length(Text)));
  617. end;
  618. end else if pmvar = 255 then begin
  619. WriteLn('Error: player #' + (Copy(Text, 5, 1)) + ' does not exist.');
  620. end else if pmvar <> 255 then begin
  621. WriteConsole2(Id, 'Error: player #' + (Copy(Text, 5, 1)) + ' does not exist.', ErrorColor);
  622. end;
  623. end;
  624.  
  625.  
  626. if (LowerCase(Text) = '/info') then begin
  627.   Result := true;
  628. WriteConsole2(Id, ServerName + ' (' + ServerIP + ':' + InttoStr(ServerPort) + iif(PublicPassword, '/' + Password, '') + ')', SuccessColor);
  629. WriteConsole2(Id, 'Server v' + ServerVersion + ' for Soldat v' + Version, SuccessColor);
  630. WriteConsole2(Id, 'Gamemode: ' + GamemodeName(GameStyle), SuccessColor);
  631. WriteConsole2(Id, 'Current Map: ' + CurrentMap + '; Next Map: ' + NextMap, SuccessColor);
  632. WriteConsole2(Id, 'Type /server for server info', SuccessColor);
  633. end;
  634.  
  635. if (LowerCase(Text) = '/server') then
  636.   Greet(Id);
  637.  
  638. end;
  639.  
  640.  
  641. function OnCommand(Id: byte; Text: string): boolean;
  642. var
  643.    Team, i: byte;
  644.    Color: longint;
  645. begin
  646.    Result := false;
  647.    
  648.    if (AdminCommands) then
  649.      if ((LowerCase(Text) = '/start') or (LowerCase(Text) = '/flagball')) then
  650.      Start()
  651.    else if (LowerCase(Text) = '/stop') then
  652.      Stop()
  653.    if ((LowerCase(Text) = '/starttm') or (LowerCase(Text) = '/teammatch') or (LowerCase(Text) = '/team')) then
  654.      StartTM()
  655.    else if (LowerCase(Text) = '/ctf') then
  656.      Stop()
  657.    else if (LowerCase(Text) = '/random') then
  658.      Command('/map ' + (GetRandomMap(CurrentMap)));
  659.    
  660.    
  661.    if (LowerCase(Text) = '/mapson') then begin
  662.      MapsOnOff := true
  663.    WriteConsole(0, '!map functions have been turned ON by ' + iif(Id = 255, 'ARSSE Admin', GetPlayerStat(Id, 'Name')), ErrorColor)
  664. end else if (LowerCase(Text) = '/killon') then begin
  665.   KillAfter := true
  666.   DoubleCaps := false
  667. WriteConsole(0, 'After-round time has been turned OFF by ' + iif(Id = 255, 'ARSSE Admin', GetPlayerStat(Id, 'Name')), ErrorColor)
  668. WriteConsole(0, 'Players will be killed after-round', ErrorColor)
  669. WriteConsole(0, 'Double Caps are allowed', ErrorColor)
  670. end else if (LowerCase(Text) = '/mapsoff') then begin
  671.   MapsOnOff := false
  672. WriteConsole(0, '!map functions have been turned OFF by ' + iif(Id = 255, 'ARSSE Admin', GetPlayerStat(Id, 'Name')), ErrorColor)
  673. end else if (LowerCase(Text) = '/killoff') then begin
  674.   KillAfter := false
  675.   DoubleCaps := true
  676. WriteConsole(0, 'After-round time has been turned ON by ' + iif(Id = 255, 'ARSSE Admin', GetPlayerStat(Id, 'Name')), ErrorColor)
  677. WriteConsole(0, 'Players will not be killed after-round', ErrorColor)
  678. WriteConsole(0, 'Double Caps should not be allowed', ErrorColor)
  679. end else if (LowerCase(Text) = '/doubleson') then begin
  680.  DoubleCaps := false
  681. WriteConsole(0, 'Double Caps have been turned ON by ' + iif(Id = 255, 'ARSSE Admin', GetPlayerStat(Id, 'Name')), ErrorColor)
  682. end else if (LowerCase(Text) = '/doublesoff') then
  683. if (not KillAfter) then begin
  684.  DoubleCaps := true
  685. WriteConsole(0, 'Double Caps have been turned OFF by ' + iif(Id = 255, 'ARSSE Admin', GetPlayerStat(Id, 'Name')), ErrorColor)
  686. end else
  687. WriteConsole(Id, 'Type /killoff if you want to disallow double captures ', ErrorColor)
  688.  
  689. if (LowerCase(Copy(Text, 1, 7)) = '/limit ') then begin
  690.   if (Gamemode = 3) then begin
  691.   Result := true
  692. Command('/limit ' + inttostr((strtoint(Copy(Text, 8, Length(Text))) + 1)))
  693. WriteConsole(0, 'Capture limit changed to ' + Copy(Text, 8, Length(Text)) + ' by ' + iif(Id = 255, 'ARSSE Admin', GetPlayerStat(Id, 'Name')), SuccessColor)
  694. WriteConsole(Id, 'Note to Admins: Ignore the yellow server message', ErrorColor)
  695. end;
  696. if (Gamemode <> 3) then
  697. WriteConsole(0, 'Capture limit changed to ' + Copy(Text, 8, Length(Text)) + ' by ' + iif(Id = 255, 'ARSSE Admin', GetPlayerStat(Id, 'Name')), SuccessColor)
  698. end else if (LowerCase(Copy(Text, 1, 9)) = '/setscore')  then begin
  699.   if Copy(Text, 10, 1) = ' ' then
  700.   if (StrToInt(Copy(Text, 13, Length(Text)))) < (ScoreLimit - 1) then
  701. SetTeamScore(StrToInt(Copy(Text, 11, 1)), StrToInt(Copy(Text, 13, Length(Text))))
  702. else
  703. WriteConsole(ID, 'Please enter a value less than the capture limit', ErrorColor)
  704. else
  705.   if (StrToInt(Copy(Text, 12, Length(Text)))) < (ScoreLimit - 1) then
  706. SetTeamScore(StrToInt(Copy(Text, 10, 1)), StrToInt(Copy(Text, 12, Length(Text))))
  707. else
  708. WriteConsole(ID, 'Please enter a value less than the capture limit', ErrorColor)
  709. end else if (LowerCase(Copy(Text, 1, 9)) = '/password') then begin
  710.   Result := true;
  711. Command(Text);
  712. if (LowerCase(Text) = '/password') then begin
  713. WriteConsole2(iif(PublicPassword, 0, Id), 'Password cleared', SuccessColor)
  714. Passworded := false;
  715. end if (LowerCase(Text) <> '/password') then begin
  716. WriteConsole2(iif(PublicPassword, 0, Id), 'Password ' + iif(Password = '', 'set', 'changed from ' + Password) + ' to ' + Copy(Text, 11, Length(Text)), SuccessColor)
  717. Passworded := true;
  718. end;
  719. end;
  720.  
  721. if (LowerCase(Text) = '/loadwep') then begin
  722. Say(0, iif(Id = 255, '', 'Admin ') + iif(SayName, iif(Id = 255, 'ARSSE Admin', GetPlayerStat(Id, 'Name')), '') + ' has reloaded the weapons', ErrorColor);
  723. end;
  724.  
  725. if ((LowerCase(Copy(Text, 1, 6)) = '/pause') and (not Paused)) then begin
  726.   if (UnpauseCounter = 0) then begin
  727. WriteConsole2(0, 'Game paused.', SuccessColor)
  728. end else begin
  729. UnpauseCounter := 0;
  730. WriteConsole2(0, 'Game unpause countdown canceled.', SuccessColor)
  731. end;
  732. end else if ((LowerCase(Copy(Text, 1, 8)) = '/unpause') and (Paused)) then
  733.   WriteConsole2(0, 'Game unpaused.', $FFE739B1)
  734. else if (LowerCase(Copy(Text, 1, 5)) = '/move') then begin
  735.   try
  736. if (ContainsString(Text, ' ')) then
  737.   Team := StrPos(' ', Text) - 6
  738. else
  739. Team := Length(Text);
  740. case (LowerCase(Copy(Text, 6, Team))) of
  741. '0', 'dm', 'deathmatch':
  742. Team := 0;
  743. '1', 'a', 'alpha', 'red', 'r':
  744. Team := 1;
  745. '2', 'b', 'bravo', 'blue':
  746. Team := 2;
  747. '3', 'c', 'charlie', 'yellow', 'y':
  748. Team := 3;
  749. '4', 'd', 'delta', 'green', 'g':
  750. Team := 4;
  751. '5', 's', 'spectator', 'spectater', 'spect', 'spec':
  752. Team := 5;
  753. else
  754. StrtoInt(' ');
  755. end;
  756. except
  757. WriteConsole2(Id, 'Syntax: /move<team> [text]', ErrorColor);
  758. exit;
  759. end;
  760. if (ContainsString(Text, ' ')) then begin
  761. Text := Copy(Text, StrPos(' ', Text) + 1, Length(Text))
  762. Move(Text, Team);
  763. WriteConsole2(0, 'Moved players with "' + Text + '" to ' + TeamName(Team) + ' team.', SuccessColor);
  764. end else begin
  765. Move('', Team);
  766. WriteConsole2(0, 'Everybody set to ' + TeamName(Team) + ' team.', SuccessColor);
  767. end;
  768.  
  769.  
  770. end else if (LowerCase(Copy(Text, 1, 4)) = '/pm ') or (LowerCase(Copy(Text, 1, 4)) = '/am ') then begin
  771.   Result := true;
  772. pmvar := strtoint(Copy(Text, 5, 1));
  773. if GetPlayerStat(pmvar, 'Active') then begin
  774. WriteConsole2(Id, 'To: ' + '[' + IDToName(pmvar) + '] ' + Copy(Text, 7, Length(Text)), SuccessColor);
  775. Say(pmvar, iif(Id = 255, '', 'Admin PM: ') + '[' + iif(SayName, iif(Id = 255, 'ARSSE PM', GetPlayerStat(Id, 'Name')), '') + '] ' + Copy(Text, 7, Length(Text)), SayColor);
  776. WriteLn('PM To: ' + '[' + IDToName(pmvar) + ']' + ' From: ' + '[' + iif(Id = 255, 'ARSSE', GetPlayerStat(Id, 'Name')) + ']' + ': ' + Copy(Text, 7, Length(Text)));
  777. end else if pmvar = 255 then begin
  778. WriteLn('Error: player #' + (Copy(Text, 5, 1)) + ' does not exist.');
  779. end else if pmvar <> 255 then begin
  780. WriteConsole2(Id, 'Error: player #' + (Copy(Text, 5, 1)) + ' does not exist.', ErrorColor);
  781. end;
  782.  
  783. end else if (LowerCase(Copy(Text, 1, 5)) = '/say ') then begin
  784.   Result := true;
  785. Say(0, iif(Id = 255, '', 'Admin: ') + '[' + iif(SayName, iif(Id = 255, 'ARSSE', GetPlayerStat(Id, 'Name')), '') + '] ' + Copy(Text, 6, Length(Text)), SayColor);
  786. end else if (LowerCase(Copy(Text, 1, 4)) = '/big') then begin
  787.   Team := StrPos(' ', Text);
  788. if (Team = 0) then
  789. WriteConsole(Id, 'Syntax: /big[color] <message>', ErrorColor)
  790. else begin
  791. case (LowerCase(Copy(Text, 5, Team - 5))) of
  792. '', 'p', 'pink', 'm', 'magenta', 'battleye', 'battleeye', 'be':
  793. Color := $FFE739B1;
  794. '0', 'black':
  795. Color := $FF000000;
  796. 'white':
  797. Color := $FFFFFFFF;
  798. '1s':
  799. Color := $FFFEE8E8;
  800. '2s':
  801. Color := $FFE3E8FE;
  802. '3s':
  803. Color := $FFFEFEE8;
  804. '4s':
  805. Color := $FFE8FEE8;
  806. '5s':
  807. Color := $FFDF7AB0;
  808. 'ts':
  809. Color := $FFFEDA7C;
  810. '1', '1j', 'red', 'r', 'alpha', 'a':
  811. Color := $FFE15353;
  812. '2', '2j', 'blue', 'b', 'bravo':
  813. Color := $FF5353E1;
  814. '3', '3j', 'yellow', 'y', 'charlie', 'c':
  815. Color := $FFDFDF53;
  816. '4', '4j', 'green', 'g', 'delta', 'd':
  817. Color := $FF53DF53;
  818. '5', '5j', 'spectator', 'spectater', 'spect', 'spec', 's':
  819. Color := $FF52DD52;
  820. 'weaponmod', 'wm':
  821. Color := $FFFBDA22;
  822. 'mode':
  823. Color := $FF81DA41;
  824. 'connectionproblem', 'cp', 'problem', 'prob':
  825. Color := $FFE36952;
  826. 'join', 'kick', 'kicked':
  827. Color := $FFFCD822;
  828. 'nextmap', 'next', 'map', 'timeleft', 'time', 'left', 'playersleft', 'players':
  829. Color := $FF71F981;
  830. 'welcome', 'wel', 'w':
  831. Color := WelcomeColor;
  832. 'say':
  833. Color := SayColor;
  834. 'success', 'suc':
  835. Color := SuccessColor;
  836. 'yield':
  837. Color := YieldColor;
  838. 'error':
  839. Color := ErrorColor;
  840. else begin
  841. Color := $FFE739B1;
  842. WriteConsole(Id, 'Invalid color, default being used. Try a team color or black or white for example.', ErrorColor);
  843. end;
  844. end;
  845. if (BigConsole) then
  846. WriteConsole2(0, iif(SayName, iif(Id = 255, '', 'Admin: ') + '[' + iif(Id = 255, 'ARSSE', GetPlayerStat(Id, 'Name')) + '] ', '') + Copy(Text, Team + 1, Length(Text)), Color);
  847. Big(0, Copy(Text, Team + 1, Length(Text)), Color);
  848. end;
  849.  
  850. end else if (LowerCase(Copy(Text, 1, 8)) = '/killmsg') then begin
  851.   Big(0, Copy(Text, 10, Length(Text)), $FFEF3431);
  852.  
  853. end else if (LowerCase(Text) = '/swap') or (LowerCase(Text) = '/swapteams') then begin
  854.   SwapTeams;
  855. WriteConsole2(0, 'Teams Swapped.', SuccessColor)
  856. end else if LowerCase(Text) = '/specall' then begin
  857.   SpectateAll;
  858. WriteConsole2(0, 'All players set as Spectators.', SuccessColor)
  859. end;
  860. end;
  861.  
  862.  
  863. procedure OnPlayerSpeak(Id: byte; Text: string);
  864. begin
  865.    if (PublicCommandsExcla) then
  866.      if ((LowerCase(Text) = '!start') or (LowerCase(Text) = '!start flagball')) then
  867.      Start()
  868.    else if (LowerCase(Text) = '!stop') then
  869.      Stop()
  870.    else if (LowerCase(Text) = '!reset') then
  871.      Command('/map ' + FlagballMap);
  872.    
  873.    
  874.    
  875.    if (MapsOnOff) then begin
  876.      if (LowerCase(Text) = '!maps') or (LowerCase(Text) = '!mapslist') or (LowerCase(Text) = '!maplist') then begin
  877.      Say(0, 'All gamestyle maps are able to be chosen in ' + ServerName, SuccessColor)
  878.    Say(0, 'Type !mapsDM, !mapsINF, !mapsHTF, or !mapsCTF to see a complete list', SuccessColor)
  879. end;
  880.  
  881. if (LowerCase(Text) = '!mapsdm') then
  882. Say(0, 'Airpirates Arena Arena2 Arena3 Bigfalls Blox Bridge Bunker Cambodia Daybreak DesertWind Factory Flashback HH Island2k5 Jungle Krab Lagrange Leaf MrSnowman RatCave Rok Shau Tropiccave Veoto', SuccessColor)
  883. else if (LowerCase(Text) = '!mapshtf') then
  884. Say(0, 'htf_Arch htf_Baire htf_Boxed htf_Desert htf_Dusk htf_Erbium htf_Muygen htf_Nuclear htf_Prison htf_Rubik htf_Void htf_Zajacz', SuccessColor)
  885. else if (LowerCase(Text) = '!mapsctf') then
  886. Say(0, 'ctf_Amazonia ctf_Ash ctf_AshZ ctf_B2b ctf_B2bZ ctf_Blade ctf_Cobra ctf_Conquest ctf_Crashed ctf_Crashed2 ctf_Death2 ctf_DeathZ ctf_Division ctf_Dropdown2 ctf_Equinnauxe ctf_Equinox ctf_Guardian ctf_Hormone ctf_IceBeam ctf_Kampf ctf_Lanubya ctf_Lanubya2 ctf_Lanubya3 ctf_Laos ctf_LaosZ ctf_MFM2 ctf_Maya ctf_Maya2 ctf_Maya3 ctf_Nuubia ctf_Nuubia2 ctf_Paradigm ctf_Raspberry ctf_Razer ctf_Rotten ctf_Ruins ctf_RuinsZ ctf_Run ctf_Snakebite ctf_SnakebiteZ ctf_Steel ctf_Viet ctf_VietZ ctf_Voland ctf_VolandZ ctf_X', SuccessColor)
  887. else if (LowerCase(Text) = '!mapsinf') then
  888. Say(0, 'inf_Abel inf_Argy inf_Fortress inf_Industrial inf_Messner inf_Moonshine inf_Outpost inf_Warehouse', SuccessColor)
  889. if (LowerCase(Text) = '!mvp') then
  890.   FindMVP();
  891.  
  892. if Passworded = true then begin
  893.   if (LowerCase(Text) = '!nextmap') or (LowerCase(Text) = '!next') then
  894.   Command('/nextmap')
  895. else if (LowerCase(Text) = '!res') or (LowerCase(Text) = '!restart') or (LowerCase(Text) = '!r') or (LowerCase(Text) = '!re') then
  896.   Command('/restart')
  897. else if (LowerCase(Text) = '!p') or (LowerCase(Text) = '!pause') then
  898.   Command('/pause')
  899. else if (LowerCase(Text) = '!up') or (LowerCase(Text) = '!unpause') then begin
  900.   //  Command('/unpause')
  901. if (UnpauseCounterInitial = 0) then
  902. WriteConsole2(0, 'Game unpaused.', $FFE739B1)
  903. else
  904. UnpauseCounter := UnpauseCounterInitial + 1;
  905. //end;
  906. end else if (Copy(LowerCase(Text), 1, 5) = '!map ') then
  907.   Command('/' + Copy(Text, 2, Length(Text)))
  908. else if (LowerCase(Text) = '!random') or (LowerCase(Text) = '!rand') then
  909.   Command('/map ' + (GetRandomMap(CurrentMap)))
  910. else if (LowerCase(Text) = '!swap') then begin
  911.   SwapTeams();
  912. WriteConsole2(0, 'Teams Swapped.', SuccessColor)
  913. end;
  914. end;
  915. if (LowerCase(Text) = '!1') or (LowerCase(Text) = '!alpha') or (LowerCase(Text) = '!a') then
  916.   Command('/setteam1 ' + IntToStr(Id))
  917. else if (LowerCase(Text) = '!2') or (LowerCase(Text) = '!bravo') or (LowerCase(Text) = '!b') then
  918.   Command('/setteam2 ' + IntToStr(Id))
  919. else if (LowerCase(Text) = '!5') or (LowerCase(Text) = '!spec') or (LowerCase(Text) = '!spectate') or (LowerCase(Text) = '!spectator') or (LowerCase(Text) = '!s') then
  920.   Command('/setteam5 ' + IntToStr(Id));
  921.  
  922. if (Gamemode = 2) then begin
  923.   if (LowerCase(Text) = '!3') or (LowerCase(Text) = '!charlie') then
  924.   Command('/setteam3 ' + IntToStr(Id))
  925. else if (LowerCase(Text) = '!4') or (LowerCase(Text) = '!delta') then
  926.   Command('/setteam4 ' + IntToStr(Id));
  927. end;
  928. end;
  929. end;
  930.  
  931. procedure OnFlagScore(ID, TeamFlag: byte);
  932. begin
  933.    LastKill := 0;
  934.    LastDeath := 0;
  935.  
  936. if (DoubleCaps) or (not KillAfter) then begin
  937. CountTeams();
  938. if (AlphaNumber > 0) then
  939. if (BravoNumber = 0) then begin
  940.       SetTeamScore(1, AlphaScore - 1)
  941.       //if CountPlayers <> AlphaNumber then begin
  942.       if (CountPlayers > 1) then begin
  943.       if (CountPlayers <> AlphaNumber) then
  944.         WriteConsole(0, 'Double Captures have been disabled and have no effect', $FFFF0000)
  945.       else
  946.         WriteConsole(0, 'There is no enemy team', $FFFF0000)
  947.       end else
  948.         WriteConsole(ID, 'Stop playing with yourself loser', $FFFF0000)
  949. end;
  950. if (BravoNumber > 0) then
  951. if (AlphaNumber = 0) then begin
  952.       SetTeamScore(2, BravoScore - 1)
  953.       if CountPlayers > 1 then begin
  954.       if CountPlayers <> BravoNumber then
  955.         WriteConsole(0, 'Double Captures have been disabled and have no effect', $FF0000FF)
  956.       else
  957.         WriteConsole(0, 'There is no enemy team', $FF0000FF)
  958.       end else
  959.         WriteConsole(ID, 'Stop playing with yourself loser', $FF0000FF)
  960. end;
  961. end;
  962. end;
  963.  
  964. procedure OnPlayerKill(Killer, Victim: byte; Weapon: string);
  965. begin
  966. If (GetPlayerStat(Killer, 'Team')) <> (GetPlayerStat(Victim, 'Team')) then begin
  967.   LastKill := Killer
  968. LastDeath := Victim
  969. if (KillAfter) and (not CheckKillAfter) then
  970.   CheckKillAfter := true;
  971. end;
  972. end;
  973.  
  974. procedure AppOnIdle(Ticks: cardinal);
  975. var
  976.    i: byte;
  977. begin
  978.    
  979.    if (ActivateVariables) then begin
  980.      Gamemode := GameStyle
  981.    Passworded := Password <> '';
  982.    if (Gamemode = 3) then
  983.      if Passworded = false then
  984.      KillAfter := true
  985.    if (Gamemode <> 6) then
  986.      MapsOnOff := true
  987.    else begin
  988.    MapsOnOff := false
  989.    Command('/limit 6')
  990. end;
  991. ActivateVariables := false;
  992. end;
  993.  
  994. if (CheckKillAfter) and (Gamemode = 3) then begin
  995.   if (AlphaScore < (ScoreLimit - 1)) and (BravoScore < (ScoreLimit - 1)) then
  996.   if NumPlayers > 1 then begin
  997.   CountTeams();
  998.     if AlphaNumber > 0 then
  999.     if BravoNumber = 0 then
  1000.       KillAlpha();
  1001.     if AlphaNumber = 0 then
  1002.     if BravoNumber > 0 then
  1003.       KillBravo();
  1004. end;
  1005. CheckKillAfter := false
  1006. end;
  1007.  
  1008.  
  1009.  
  1010. if (UnpauseCounter > 0) then begin
  1011. UnpauseCounter := UnpauseCounter - 1;
  1012. if (UnpauseCounter = 0) then begin
  1013.   Command('/unpause');
  1014. WriteConsole2(0, 'Game unpaused.', $FFE739B1);
  1015. end else
  1016. WriteConsole2(0, 'Game unpaused in ' + InttoStr(UnpauseCounter) + '...', YieldColor);
  1017. end;
  1018.  
  1019.  
  1020. if (SayMap) then begin
  1021. WriteConsole(0, 'Next Map: ' + NextMap , $FF71F981);
  1022. SayMap := false;
  1023. end;
  1024.  
  1025.  
  1026. if (Gamemode = 3) then begin
  1027.   if (EndGame) then
  1028.   if (AlphaScore = 0) and (BravoScore = 0) then
  1029.   EndGame := false
  1030.  
  1031. if EndGame = false then
  1032.   if (not StopNext) then begin
  1033.   if AlphaScore >= (ScoreLimit - 1) then begin
  1034.   if CountPlayers > 2 then
  1035.   AnnounceAlpha()
  1036. else
  1037. AnnounceWinner();
  1038. EndGame := true;
  1039. Command('/nextmap');
  1040. end;
  1041. if BravoScore >= (ScoreLimit - 1) then begin
  1042.   if CountPlayers > 2 then
  1043.   AnnounceBravo()
  1044. else
  1045. AnnounceWinner();
  1046. EndGame := true
  1047. Command('/nextmap')
  1048. end;
  1049. end;
  1050. end;
  1051.  
  1052.  
  1053. if (Gamemode = 6) then begin
  1054.   for i := 1 to HighestID do
  1055. if (GetPlayerStat(i, 'Active') = true) then
  1056.   if ((GetPlayerStat(i, 'Human') = true) and (GetPlayerStat(i, 'Name') <> BotName) and ((GetPlayerStat(i, 'Team') = 1) or (GetPlayerStat(i, 'Team') = 2))) then
  1057.   CheckPlayerLocation(i);
  1058. CheckFlagLocation();
  1059. if ((AutoEnd) and (NumPlayers = 0)) then
  1060.   Stop();
  1061. if (BotName <> '') then begin
  1062.   for i := 1 to HighestID do
  1063. if (GetPlayerStat(i, 'Active') = true) then
  1064.   if ((GetPlayerStat(i, 'Human') = false) and (GetPlayerStat(i, 'Team') = 3) and (GetPlayerStat(i, 'Name') = BotName)) then
  1065.   exit;
  1066. Command('/addbot3 ' + BotName);
  1067. end;
  1068. end else begin
  1069.   if (StartOnIdle) then
  1070.   Start()
  1071. else for i := 1 to HighestID do
  1072.   if (GetPlayerStat(i, 'Active') = true) then
  1073.   if ((GetPlayerStat(i, 'Human') = false) and (GetPlayerStat(i, 'Team') = 3) and (GetPlayerStat(i, 'Name') = BotName)) then
  1074.   KickPlayer(i);
  1075. end;
  1076. end;
  1077.  
  1078. function OnPlayerDamage(Victim, Shooter: byte; Damage: integer): integer;
  1079. var
  1080.    Ticks: cardinal;
  1081. begin
  1082. if (BotName <> '') then begin
  1083.   if ((GetPlayerStat(Victim, 'Human') = false) and (GetPlayerStat(Victim, 'Team') = 3) and (GetPlayerStat(Victim, 'Name') = BotName)) then begin
  1084.   Result := 0;
  1085. Ticks := GetTickCount();
  1086. if (Ticks mod AppOnIdleInterval = 0) then
  1087.   if (Ticks mod 60 <> 0) then
  1088.   AppOnIdle(Ticks);
  1089. end else
  1090. Result := Damage;
  1091. end else
  1092. Result := Damage;
  1093. end;
  1094.  
  1095. procedure OnMapChange(NewMap: string);
  1096. begin
  1097.    SayMap := true;
  1098.    
  1099.    if (Gamemode = 6) then
  1100.      if (NewMap <> FlagballMap) then
  1101.      Command('/map ' + FlagballMap);
  1102. end;
  1103.  
  1104. procedure OnFlagGrab(Id, Team: byte; Base: boolean);
  1105. begin
  1106.    LastTouch := Id;
  1107. end;
  1108.  
  1109. procedure OnPlayerRespawn(Id: byte);
  1110. begin
  1111.    DisablePlayerScore[Id] := false;
  1112. end;
  1113.  
  1114.  
  1115. procedure OnJoinGame(Id, Team: byte);
  1116. begin
  1117. SetHighestID();
  1118.  
  1119.    Players[Id].JoinGame := true;
  1120.    if (Gamemode = 3) then
  1121.      StopNext := true;
  1122.    
  1123.    if (Gamemode = 6) then begin
  1124.    WriteConsole(Id, 'Welcome to |D) Flagball', $FFFFFFFF);
  1125.    WriteConsole(Id, 'If you are new, read the rules located above the arena', $FFFFFFFF);
  1126. end;
  1127. if (Gamemode = 2) then begin
  1128. WriteConsole(Id, 'Welcome to |D) TeamMatch R/S', $FFFFFFFF);
  1129. WriteConsole(Id, 'Choose any map: DM, HTF, CTF, etc', $FFFFFFFF);
  1130. WriteConsole(Id, 'Kill limit is 25', $FFFFFFFF);
  1131. end;
  1132. end;
  1133.  
  1134. procedure AfterJoinGame(Id, Team: byte);
  1135. begin
  1136.    Greet(Id);
  1137. end;
  1138.  
  1139. procedure OnJoinTeam(Id, Team: byte);
  1140. begin
  1141.    if (Gamemode = 3) then
  1142.      FixScore(Team);
  1143.    
  1144.    if (Players[Id].JoinGame) then begin
  1145.      Players[Id].JoinGame := false;
  1146.    AfterJoinGame(Id, Team);
  1147. end;
  1148.  
  1149. end;
  1150.  
  1151. procedure OnLeaveGame(Id, Team: byte; Kicked: boolean);
  1152. begin
  1153. if Id = HighestID then
  1154. SetHighestID();
  1155.  
  1156.    Players[Id].JoinGame := false;
  1157. end;
  1158.  
  1159.  
  1160.  
  1161.  
  1162. procedure ActivateServer();
  1163. begin
  1164.    ActivateVariables := true;
  1165.    
  1166.    TextWidth[32] := 103.20;
  1167.    TextWidth[33] := 114.67;
  1168.    TextWidth[34] := 74.53;
  1169.    TextWidth[35] := 5.73;
  1170.    TextWidth[36] := 206.40;
  1171.    TextWidth[37] := 235.07;
  1172.    TextWidth[38] := 212.13;
  1173.    TextWidth[39] := 40.13;
  1174.    TextWidth[40] := 103.20;
  1175.    TextWidth[41] := 103.20;
  1176.    TextWidth[42] := 137.60;
  1177.    TextWidth[43] := 229.33;
  1178.    TextWidth[44] := 103.20;
  1179.    TextWidth[45] := 91.73;
  1180.    TextWidth[46] := 103.20;
  1181.    TextWidth[47] := 97.47;
  1182.    TextWidth[48] := 206.40;
  1183.    TextWidth[49] := 206.40;
  1184.    TextWidth[50] := 206.40;
  1185.    TextWidth[51] := 206.40;
  1186.    TextWidth[52] := 206.40;
  1187.    TextWidth[53] := 206.40;
  1188.    TextWidth[54] := 206.40;
  1189.    TextWidth[55] := 206.40;
  1190.    TextWidth[56] := 206.40;
  1191.    TextWidth[57] := 206.40;
  1192.    TextWidth[58] := 103.20;
  1193.    TextWidth[59] := 103.20;
  1194.    TextWidth[60] := 229.33;
  1195.    TextWidth[61] := 229.33;
  1196.    TextWidth[62] := 229.33;
  1197.    TextWidth[63] := 177.73;
  1198.    TextWidth[64] := 275.20;
  1199.    TextWidth[65] := 200.67;
  1200.    TextWidth[66] := 212.13;
  1201.    TextWidth[67] := 206.40;
  1202.    TextWidth[68] := 223.60;
  1203.    TextWidth[69] := 194.93;
  1204.    TextWidth[70] := 177.73;
  1205.    TextWidth[71] := 223.60;
  1206.    TextWidth[72] := 235.07;
  1207.    TextWidth[73] := 97.47;
  1208.    TextWidth[74] := 183.47;
  1209.    TextWidth[75] := 200.67;
  1210.    TextWidth[76] := 177.73;
  1211.    TextWidth[77] := 246.53;
  1212.    TextWidth[78] := 229.33;
  1213.    TextWidth[79] := 235.07;
  1214.    TextWidth[80] := 200.67;
  1215.    TextWidth[81] := 235.07;
  1216.    TextWidth[82] := 212.13;
  1217.    TextWidth[83] := 212.13;
  1218.    TextWidth[84] := 160.53;
  1219.    TextWidth[85] := 223.60;
  1220.    TextWidth[86] := 189.20;
  1221.    TextWidth[87] := 235.07;
  1222.    TextWidth[88] := 194.93;
  1223.    TextWidth[89] := 183.47;
  1224.    TextWidth[90] := 189.20;
  1225.    TextWidth[91] := 103.20;
  1226.    TextWidth[92] := 97.47;
  1227.    TextWidth[93] := 103.20;
  1228.    TextWidth[94] := 275.20;
  1229.    TextWidth[95] := 137.60;
  1230.    TextWidth[96] := 137.60;
  1231.    TextWidth[97] := 172;
  1232.    TextWidth[98] := 172;
  1233.    TextWidth[99] := 172;
  1234.    TextWidth[100] := 200.67;
  1235.    TextWidth[101] := 160.53;
  1236.    TextWidth[102] := 149.07;
  1237.    TextWidth[103] := 183.47;
  1238.    TextWidth[104] := 189.20;
  1239.    TextWidth[105] := 74.53;
  1240.    TextWidth[106] := 154.80;
  1241.    TextWidth[107] := 166.27;
  1242.    TextWidth[108] := 149.07;
  1243.    TextWidth[109] := 206.40;
  1244.    TextWidth[110] := 189.20;
  1245.    TextWidth[111] := 189.20;
  1246.    TextWidth[112] := 166.27;
  1247.    TextWidth[113] := 189.20;
  1248.    TextWidth[114] := 166.27;
  1249.    TextWidth[115] := 177.73;
  1250.    TextWidth[116] := 143.33;
  1251.    TextWidth[117] := 183.47;
  1252.    TextWidth[118] := 160.53;
  1253.    TextWidth[119] := 200.67;
  1254.    TextWidth[120] := 160.53;
  1255.    TextWidth[121] := 154.80;
  1256.    TextWidth[122] := 172;
  1257.    TextWidth[123] := 137.60;
  1258.    TextWidth[124] := 137.60;
  1259.    TextWidth[125] := 137.60;
  1260.    TextWidth[126] := 229.33;
  1261.    TextWidth[127] := 166.27;
  1262.    StartOnIdle := AutoStart;
  1263. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement