Advertisement
Guest User

MapListReader

a guest
Jan 4th, 2017
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 20.74 KB | None | 0 0
  1. //Savage's MapListReader
  2. //Core Version: 2.8.1
  3. {Description: Tool for reading list of maps, also for searching. Result is divided into pages and displayed in BigText.
  4. Hold "Crouch"(forward) or "Jump"(back) key to change page, You can also use "/page <number>", type "/page 0" to close.}
  5.  
  6. const
  7.     const_MapList = 0; //Do not change it
  8.     const_SortedMapList = 1; //Do not change it
  9.     const_SearchResult = 2; //Do not change it
  10.    
  11.     const_CheckMapsExistence = False; //Works on compilation/When Sorted MapList is creating. Check if maps from mapslist.txt exists in maps directory
  12.     const_RemoveNotExistingMaps = False; //Works on compilation/When Sorted MapList is creating. Removes not existing maps from mapslist.txt
  13.    
  14.     const_CheckForDuplicates = False; //Works on compilation/When Sorted MapList is creating. Check if there are duplicates in mapslist.txt
  15.     const_RemoveDuplicates = False; //Works on compilation/When Sorted MapList is creating. Removes duplicates from mapslist.txt
  16.    
  17.     const_MapsPerPage = 25; //How many maps will be displayed on each page
  18.    
  19.     //BigText settings
  20.     const_GeneratedPageLayer = 255;
  21.     const_GeneratedPageColour = $FFFFFF;
  22.     const_GeneratedPageScale = 0.05;
  23.     const_GeneratedPagePosX = 320;
  24.     const_GeneratedPagePosY = 70;
  25.    
  26. var
  27.     GV_SortedMapList: TStringList;
  28.     GV_SearchResult: array[1..32] of TStringList;
  29.     GV_SearchPattern: array[1..32] of String;
  30.     GV_CurrentPlayerPage: array[1..32] of array [const_MapList..const_SearchResult] of Integer;
  31.     GV_MapListPages, GV_SortedMapListPages: Integer;
  32.     GV_SearchResultPages: array[1..32] of Integer;
  33.     GV_ShowMapID: array[1..32] of Boolean;
  34.     GV_SortedMapListCreationDate: String;
  35.    
  36. procedure CreateSortedMapList(LoopMemory: Integer);
  37. var
  38.     i: Integer;
  39. begin
  40.     if LoopMemory = 0 then begin
  41.         GV_SortedMapList := File.CreateStringList;
  42.         GV_SortedMapListCreationDate := FormatDateTime('c', Now);
  43.         GV_SortedMapList.Sorted := True;
  44.         if (const_CheckForDuplicates = True) or (const_RemoveDuplicates = True) then
  45.         GV_SortedMapList.Duplicates := DupError;
  46.     end;
  47.    
  48.     try
  49.         for i := LoopMemory to Game.MapsList.MapsCount-1 do begin
  50.             if const_RemoveNotExistingMaps then begin
  51.                 if not File.Exists('maps/'+Game.MapsList[i]+'.pms') then begin
  52.                     WriteLn('MapListReader: Map not found: "'+Game.MapsList[i]+'" ID: "'+inttostr(i+1)+'"');
  53.                     Game.MapsList.RemoveMap(Game.MapsList[i]);
  54.                     CreateSortedMapList(i);
  55.                     exit;
  56.                 end;
  57.             end else
  58.             if (const_CheckMapsExistence = True) and (not File.Exists('maps/'+Game.MapsList[i]+'.pms')) then
  59.             WriteLn('MapListReader: Map not found: "'+Game.MapsList[i]+'" ID: "'+inttostr(i+1)+'"');
  60.             GV_SortedMapList.Add(Game.MapsList[i]);
  61.         end;
  62.         GV_SortedMapListPages := iif(GV_SortedMapList.Count mod const_MapsPerPage = 0, GV_SortedMapList.Count div const_MapsPerPage, GV_SortedMapList.Count div const_MapsPerPage + 1);
  63.         WriteLn('MapListReader: Sorted MapList: Counted '+inttostr(GV_SortedMapListPages)+' '+iif(GV_SortedMapListPages = 1, 'page', 'pages')+' for '+inttostr(GV_SortedMapList.Count)+iif(GV_SortedMapList.Count = 1, ' map', ' maps'));
  64.     except
  65.         if const_RemoveDuplicates then begin
  66.             WriteLn('MapListReader: Duplicate map detected: "'+Game.MapsList[i]+'" ID: "'+inttostr(i+1)+'"');
  67.             Game.MapsList.RemoveMap(Game.MapsList[i]);
  68.             if i <> Game.MapsList.MapsCount then
  69.             CreateSortedMapList(i)
  70.             else begin
  71.                 GV_SortedMapListPages := iif(GV_SortedMapList.Count mod const_MapsPerPage = 0, GV_SortedMapList.Count div const_MapsPerPage, GV_SortedMapList.Count div const_MapsPerPage + 1);
  72.                 WriteLn('MapListReader: Sorted MapList: Counted '+inttostr(GV_SortedMapListPages)+' '+iif(GV_SortedMapListPages = 1, 'page', 'pages')+' for '+inttostr(GV_SortedMapList.Count)+iif(GV_SortedMapList.Count = 1, ' map', ' maps'));
  73.             end;
  74.         end else
  75.         begin
  76.             WriteLn('MapListReader: Duplicate map detected: "'+Game.MapsList[i]+'" ID: "'+inttostr(i+1)+'"');
  77.             if i <> Game.MapsList.MapsCount-1 then
  78.             CreateSortedMapList(i+1)
  79.             else begin
  80.                 GV_SortedMapListPages := iif(GV_SortedMapList.Count mod const_MapsPerPage = 0, GV_SortedMapList.Count div const_MapsPerPage, GV_SortedMapList.Count div const_MapsPerPage + 1);
  81.                 WriteLn('MapListReader: Sorted MapList: Counted '+inttostr(GV_SortedMapListPages)+' '+iif(GV_SortedMapListPages = 1, 'page', 'pages')+' for '+inttostr(GV_SortedMapList.Count)+iif(GV_SortedMapList.Count = 1, ' map', ' maps'));
  82.             end;
  83.         end;
  84.     end;
  85. end;
  86.  
  87. function OnAdminCommand(Player: TActivePlayer; Command: string): boolean;
  88. begin
  89.     Command := LowerCase(Command);
  90.    
  91.     //Built-in /addmap and /delmap
  92.    
  93.     if Command = '/createsortedmaplist' then
  94.     CreateSortedMapList(0);
  95.    
  96. Result := False;
  97. end;
  98.  
  99. procedure OnPlayerSpeak(Player: TActivePlayer; Text: String);
  100. var
  101.     i, StrToIntConv: Integer;
  102. begin
  103.     Text := LowerCase(Text);
  104.    
  105.     if Text = '!maplist' then begin
  106.         GV_CurrentPlayerPage[Player.ID][const_SortedMapList] := 0;
  107.         GV_CurrentPlayerPage[Player.ID][const_SearchResult] := 0;
  108.         GV_SearchResult[Player.ID].Clear;
  109.        
  110.         GV_CurrentPlayerPage[Player.ID][const_MapList] := 1;
  111.         Player.WriteConsole('MapListReader: Hold "Crouch"(forward) or "Jump"(back) key to change page', const_GeneratedPageColour);
  112.         Player.WriteConsole('You can also use "!page <number>", type "!page 0" to close', const_GeneratedPageColour);
  113.     end;
  114.    
  115.     if Text = '!smaplist' then begin
  116.         GV_CurrentPlayerPage[Player.ID][const_MapList] := 0;
  117.         GV_CurrentPlayerPage[Player.ID][const_SearchResult] := 0;
  118.         GV_SearchResult[Player.ID].Clear;
  119.        
  120.         GV_CurrentPlayerPage[Player.ID][const_SortedMapList] := 1;
  121.         Player.WriteConsole('MapListReader: Hold "Crouch"(forward) or "Jump"(back) key to change page', const_GeneratedPageColour);
  122.         Player.WriteConsole('You can also use "!page <number>", type "!page 0" to close', const_GeneratedPageColour);
  123.     end;
  124.    
  125.     if (Copy(Text, 1, 11) = '!searchmap ') and (Length(Text)>11) then begin
  126.         Delete(Text, 1, 11);
  127.         GV_CurrentPlayerPage[Player.ID][const_SearchResult] := 0;
  128.         GV_SearchResult[Player.ID].Clear;
  129.         for i := 0 to Game.MapsList.MapsCount-1 do
  130.         if Pos(Text, LowerCase(Game.MapsList[i])) <> 0 then
  131.         GV_SearchResult[Player.ID].Append(iif(GV_ShowMapID[Player.ID], inttostr(i+1)+': '+Game.MapsList[i], Game.MapsList[i]));
  132.         if GV_SearchResult[Player.ID].Count = 0 then
  133.         Player.WriteConsole('MapListReader: Lack of maps containing "'+Text+'"', $FF0000)
  134.         else begin
  135.             GV_SearchPattern[Player.ID] := Text;
  136.            
  137.             GV_SearchResultPages[Player.ID] := iif(GV_SearchResult[Player.ID].Count mod const_MapsPerPage = 0, GV_SearchResult[Player.ID].Count div const_MapsPerPage, GV_SearchResult[Player.ID].Count div const_MapsPerPage + 1);
  138.            
  139.             GV_CurrentPlayerPage[Player.ID][const_MapList] := 0;
  140.             GV_CurrentPlayerPage[Player.ID][const_SortedMapList] := 0;
  141.             GV_CurrentPlayerPage[Player.ID][const_SearchResult] := 1;
  142.             Player.WriteConsole('MapListReader: Hold "Crouch"(forward) or "Jump"(back) key to change page', const_GeneratedPageColour);
  143.             Player.WriteConsole('You can also use "!page <number>", type "!page 0" to close', const_GeneratedPageColour);
  144.         end;
  145.     end;
  146.    
  147.     if Text = '!showmapid' then
  148.     if GV_ShowMapID[Player.ID] then begin
  149.         GV_ShowMapID[Player.ID] := False
  150.         Player.WriteConsole('MapListReader: ShowMapID OFF', $FF0000);
  151.     end else
  152.     begin
  153.         GV_ShowMapID[Player.ID] := True;
  154.         Player.WriteConsole('MapListReader: ShowMapID ON - You can see now map index from MapList in SearchResult, do it before searching', $00FF00);
  155.         Player.WriteConsole('It doesn''t work for SortedMapList, index is 1 based, type "!showmapid" again to turn off', $0000FF);
  156.     end;
  157.    
  158.     if (Copy(Text, 1, 6) = '!page ') and (Length(Text)>6) then
  159.     if (GV_CurrentPlayerPage[Player.ID][const_MapList] <> 0) or (GV_CurrentPlayerPage[Player.ID][const_SortedMapList] <> 0) or (GV_CurrentPlayerPage[Player.ID][const_SearchResult] <> 0) then begin
  160.         Delete(Text, 1, 6);
  161.         try
  162.             StrToIntConv := StrToInt(Text);
  163.         except
  164.             Player.WriteConsole('MapListReader: Invalid integer', $FF0000);
  165.             exit;
  166.         end;
  167.        
  168.         if GV_CurrentPlayerPage[Player.ID][const_MapList] <> 0 then
  169.         if (StrToIntConv >= 0) and (StrToIntConv <= GV_MapListPages) then
  170.         GV_CurrentPlayerPage[Player.ID][const_MapList] := StrToIntConv
  171.         else
  172.         Player.WriteConsole('MapListReader: MapList page has to be between 0 and '+inttostr(GV_MapListPages), $FF0000);
  173.        
  174.         if GV_CurrentPlayerPage[Player.ID][const_SortedMapList] <> 0 then
  175.         if (StrToIntConv >= 0) and (StrToIntConv <= GV_SortedMapListPages) then
  176.         GV_CurrentPlayerPage[Player.ID][const_SortedMapList] := StrToIntConv
  177.         else
  178.         Player.WriteConsole('MapListReader: SortedMapList page has to be between 0 and '+inttostr(GV_SortedMapListPages), $FF0000);
  179.        
  180.         if GV_CurrentPlayerPage[Player.ID][const_SearchResult] <> 0 then
  181.         if (StrToIntConv >= 0) and (StrToIntConv <= GV_SearchResultPages[Player.ID]) then begin
  182.             if StrToIntConv = 0 then begin
  183.                 GV_CurrentPlayerPage[Player.ID][const_SearchResult] := 0;
  184.                 GV_SearchResult[Player.ID].Clear;
  185.             end else
  186.             GV_CurrentPlayerPage[Player.ID][const_SearchResult] := StrToIntConv;
  187.         end else
  188.         Player.WriteConsole('MapListReader: SearchResult page has to be between 0 and '+inttostr(GV_SearchResultPages[Player.ID]), $FF0000);
  189.     end else
  190.     Player.WriteConsole('MapListReader: Open MapList, SortedMapList or SearchResult first', $FF0000);
  191. end;
  192.  
  193. function OnPlayerCommand(Player: TActivePlayer; Command: String): Boolean;
  194. var
  195.     i, StrToIntConv: Integer;
  196. begin
  197.     Command := LowerCase(Command);
  198.    
  199.     if Command = '/maplist' then begin
  200.         GV_CurrentPlayerPage[Player.ID][const_SortedMapList] := 0;
  201.         GV_CurrentPlayerPage[Player.ID][const_SearchResult] := 0;
  202.         GV_SearchResult[Player.ID].Clear;
  203.        
  204.         GV_CurrentPlayerPage[Player.ID][const_MapList] := 1;
  205.         Player.WriteConsole('MapListReader: Hold "Crouch"(forward) or "Jump"(back) key to change page', const_GeneratedPageColour);
  206.         Player.WriteConsole('You can also use "/page <number>", type "/page 0" to close', const_GeneratedPageColour);
  207.     end;
  208.    
  209.     if Command = '/smaplist' then begin
  210.         GV_CurrentPlayerPage[Player.ID][const_MapList] := 0;
  211.         GV_CurrentPlayerPage[Player.ID][const_SearchResult] := 0;
  212.         GV_SearchResult[Player.ID].Clear;
  213.        
  214.         GV_CurrentPlayerPage[Player.ID][const_SortedMapList] := 1;
  215.         Player.WriteConsole('MapListReader: Hold "Crouch"(forward) or "Jump"(back) key to change page', const_GeneratedPageColour);
  216.         Player.WriteConsole('You can also use "/page <number>", type "/page 0" to close', const_GeneratedPageColour);
  217.     end;
  218.    
  219.     if (Copy(Command, 1, 11) = '/searchmap ') and (Length(Command)>11) then begin
  220.         Delete(Command, 1, 11);
  221.         GV_CurrentPlayerPage[Player.ID][const_SearchResult] := 0;
  222.         GV_SearchResult[Player.ID].Clear;
  223.         for i := 0 to Game.MapsList.MapsCount-1 do
  224.         if Pos(Command, LowerCase(Game.MapsList[i])) <> 0 then
  225.         GV_SearchResult[Player.ID].Append(iif(GV_ShowMapID[Player.ID], inttostr(i+1)+': '+Game.MapsList[i], Game.MapsList[i]));
  226.         if GV_SearchResult[Player.ID].Count = 0 then
  227.         Player.WriteConsole('MapListReader: Lack of maps containing "'+Command+'"', $FF0000)
  228.         else begin
  229.             GV_SearchPattern[Player.ID] := Command;
  230.            
  231.             GV_SearchResultPages[Player.ID] := iif(GV_SearchResult[Player.ID].Count mod const_MapsPerPage = 0, GV_SearchResult[Player.ID].Count div const_MapsPerPage, GV_SearchResult[Player.ID].Count div const_MapsPerPage + 1);
  232.            
  233.             GV_CurrentPlayerPage[Player.ID][const_MapList] := 0;
  234.             GV_CurrentPlayerPage[Player.ID][const_SortedMapList] := 0;
  235.             GV_CurrentPlayerPage[Player.ID][const_SearchResult] := 1;
  236.             Player.WriteConsole('MapListReader: Hold "Crouch"(forward) or "Jump"(back) key to change page', const_GeneratedPageColour);
  237.             Player.WriteConsole('You can also use "/page <number>", type "/page 0" to close', const_GeneratedPageColour);
  238.         end;
  239.     end;
  240.    
  241.     if Command = '/showmapid' then
  242.     if GV_ShowMapID[Player.ID] then begin
  243.         GV_ShowMapID[Player.ID] := False
  244.         Player.WriteConsole('MapListReader: ShowMapID OFF', $FF0000);
  245.     end else
  246.     begin
  247.         GV_ShowMapID[Player.ID] := True;
  248.         Player.WriteConsole('MapListReader: ShowMapID ON - You can see now map index from MapList in SearchResult, do it before searching', $00FF00);
  249.         Player.WriteConsole('It doesn''t work for SortedMapList, index is 1 based, type "/showmapid" again to turn off', $0000FF);
  250.     end;
  251.    
  252.     if (Copy(Command, 1, 6) = '/page ') and (Length(Command)>6) then
  253.     if (GV_CurrentPlayerPage[Player.ID][const_MapList] <> 0) or (GV_CurrentPlayerPage[Player.ID][const_SortedMapList] <> 0) or (GV_CurrentPlayerPage[Player.ID][const_SearchResult] <> 0) then begin
  254.         Delete(Command, 1, 6);
  255.         try
  256.             StrToIntConv := StrToInt(Command);
  257.         except
  258.             Player.WriteConsole('MapListReader: Invalid integer', $FF0000);
  259.             exit;
  260.         end;
  261.        
  262.         if GV_CurrentPlayerPage[Player.ID][const_MapList] <> 0 then
  263.         if (StrToIntConv >= 0) and (StrToIntConv <= GV_MapListPages) then
  264.         GV_CurrentPlayerPage[Player.ID][const_MapList] := StrToIntConv
  265.         else
  266.         Player.WriteConsole('MapListReader: MapList page has to be between 0 and '+inttostr(GV_MapListPages), $FF0000);
  267.        
  268.         if GV_CurrentPlayerPage[Player.ID][const_SortedMapList] <> 0 then
  269.         if (StrToIntConv >= 0) and (StrToIntConv <= GV_SortedMapListPages) then
  270.         GV_CurrentPlayerPage[Player.ID][const_SortedMapList] := StrToIntConv
  271.         else
  272.         Player.WriteConsole('MapListReader: SortedMapList page has to be between 0 and '+inttostr(GV_SortedMapListPages), $FF0000);
  273.        
  274.         if GV_CurrentPlayerPage[Player.ID][const_SearchResult] <> 0 then
  275.         if (StrToIntConv >= 0) and (StrToIntConv <= GV_SearchResultPages[Player.ID]) then begin
  276.             if StrToIntConv = 0 then begin
  277.                 GV_CurrentPlayerPage[Player.ID][const_SearchResult] := 0;
  278.                 GV_SearchResult[Player.ID].Clear;
  279.             end else
  280.             GV_CurrentPlayerPage[Player.ID][const_SearchResult] := StrToIntConv;
  281.         end else
  282.         Player.WriteConsole('MapListReader: SearchResult page has to be between 0 and '+inttostr(GV_SearchResultPages[Player.ID]), $FF0000);
  283.     end else
  284.     Player.WriteConsole('MapListReader: Open MapList, SortedMapList or SearchResult first', $FF0000);
  285.    
  286. Result := False;
  287. end;
  288.  
  289. procedure OnLeave(Player: TActivePlayer; Kicked: Boolean);
  290. begin
  291.     GV_CurrentPlayerPage[Player.ID][const_MapList] := 0;
  292.     GV_CurrentPlayerPage[Player.ID][const_SortedMapList] := 0;
  293.     GV_CurrentPlayerPage[Player.ID][const_SearchResult] := 0;
  294.     GV_SearchResult[Player.ID].Clear;
  295.     GV_ShowMapID[Player.ID] := False;
  296. end;
  297.  
  298. procedure OnClockTick(Ticks: Integer);
  299. var
  300.     i: Byte;
  301.     j: Integer;
  302.     GeneratedPage: String;
  303. begin
  304.     GV_MapListPages := iif(Game.MapsList.MapsCount mod const_MapsPerPage = 0, Game.MapsList.MapsCount div const_MapsPerPage, Game.MapsList.MapsCount div const_MapsPerPage + 1);
  305.    
  306.     for i := 1 to 32 do begin
  307.    
  308.         if GV_CurrentPlayerPage[i][const_MapList] <> 0 then
  309.         if GV_MapListPages <> 0 then begin
  310.            
  311.             if GV_CurrentPlayerPage[i][const_MapList] > GV_MapListPages then
  312.             GV_CurrentPlayerPage[i][const_MapList] := GV_MapListPages;
  313.            
  314.             if (Players[i].KeyUp) and (GV_CurrentPlayerPage[i][const_MapList] > 1) then
  315.             Dec(GV_CurrentPlayerPage[i][const_MapList], 1);
  316.            
  317.             if (Players[i].KeyCrouch) and (GV_CurrentPlayerPage[i][const_MapList] < GV_MapListPages) then
  318.             Inc(GV_CurrentPlayerPage[i][const_MapList], 1);
  319.            
  320.             GeneratedPage := ' MapList: '+inttostr(Game.MapsList.MapsCount)+iif(Game.MapsList.MapsCount = 1, ' Map', ' Maps')+#10+' Page: '+inttostr(GV_CurrentPlayerPage[i][const_MapList])+' / '+inttostr(GV_MapListPages)+' Length: '+inttostr(iif(GV_CurrentPlayerPage[i][const_MapList]=GV_MapListPages, Game.MapsList.MapsCount-(GV_MapListPages-1)*const_MapsPerPage, const_MapsPerPage))+' / '+inttostr(const_MapsPerPage)+#10+' Current Map: '+Game.CurrentMap+#10+' ID: '+inttostr(Game.MapsList.CurrentMapId+1)+' Page: '+inttostr(iif((Game.MapsList.CurrentMapId+1) mod const_MapsPerPage = 0, (Game.MapsList.CurrentMapId+1) div const_MapsPerPage, (Game.MapsList.CurrentMapId+1) div const_MapsPerPage + 1))+#10#10;
  321.             for j := (GV_CurrentPlayerPage[i][const_MapList]-1)*const_MapsPerPage to GV_CurrentPlayerPage[i][const_MapList]*const_MapsPerPage-1 do begin
  322.                 if Game.CurrentMap=Game.MapsList[j] then begin
  323.                     if GV_ShowMapID[i] then
  324.                     GeneratedPage := GeneratedPage+chr(149)+inttostr(j+1)+': '+Game.MapsList[j]+#10
  325.                     else
  326.                     GeneratedPage := GeneratedPage+chr(149)+Game.MapsList[j]+#10;
  327.                 end else
  328.                 begin
  329.                     if GV_ShowMapID[i] then
  330.                     GeneratedPage := GeneratedPage+' '+inttostr(j+1)+': '+Game.MapsList[j]+#10
  331.                     else
  332.                     GeneratedPage := GeneratedPage+' '+Game.MapsList[j]+#10;
  333.                 end;
  334.                 if j = Game.MapsList.MapsCount-1 then
  335.                 break;
  336.             end;
  337.             Players[i].BigText(const_GeneratedPageLayer, GeneratedPage, 120, const_GeneratedPageColour, const_GeneratedPageScale, const_GeneratedPagePosX, const_GeneratedPagePosY);
  338.            
  339.         end else Players[i].BigText(const_GeneratedPageLayer, 'Empty MapList', 120, const_GeneratedPageColour, const_GeneratedPageScale, const_GeneratedPagePosX, const_GeneratedPagePosY);
  340.        
  341.         if GV_CurrentPlayerPage[i][const_SortedMapList] <> 0 then
  342.         if GV_SortedMapListPages <> 0 then begin
  343.            
  344.             if GV_CurrentPlayerPage[i][const_SortedMapList] > GV_SortedMapListPages then
  345.             GV_CurrentPlayerPage[i][const_SortedMapList] := GV_SortedMapListPages;
  346.            
  347.             if (Players[i].KeyUp) and (GV_CurrentPlayerPage[i][const_SortedMapList] > 1) then
  348.             Dec(GV_CurrentPlayerPage[i][const_SortedMapList], 1);
  349.            
  350.             if (Players[i].KeyCrouch) and (GV_CurrentPlayerPage[i][const_SortedMapList] < GV_SortedMapListPages) then
  351.             Inc(GV_CurrentPlayerPage[i][const_SortedMapList], 1);
  352.            
  353.             GeneratedPage := ' SortedMapList: '+inttostr(GV_SortedMapList.Count)+iif(GV_SortedMapList.Count = 1, ' Map', ' Maps')+#10+' Page: '+inttostr(GV_CurrentPlayerPage[i][const_SortedMapList])+' / '+inttostr(GV_SortedMapListPages)+' Length: '+inttostr(iif(GV_CurrentPlayerPage[i][const_SortedMapList]=GV_SortedMapListPages, GV_SortedMapList.Count-(GV_SortedMapListPages-1)*const_MapsPerPage, const_MapsPerPage))+' / '+inttostr(const_MapsPerPage)+#10+' Created: '+GV_SortedMapListCreationDate+#10#10;
  354.             for j := (GV_CurrentPlayerPage[i][const_SortedMapList]-1)*const_MapsPerPage to GV_CurrentPlayerPage[i][const_SortedMapList]*const_MapsPerPage-1 do begin
  355.                 if Game.CurrentMap=GV_SortedMapList[j] then
  356.                 GeneratedPage := GeneratedPage+chr(149)+GV_SortedMapList[j]+#10
  357.                 else
  358.                 GeneratedPage := GeneratedPage+' '+GV_SortedMapList[j]+#10;
  359.                 if j = GV_SortedMapList.Count-1 then
  360.                 break;
  361.             end;
  362.             Players[i].BigText(const_GeneratedPageLayer, GeneratedPage, 120, const_GeneratedPageColour, const_GeneratedPageScale, const_GeneratedPagePosX, const_GeneratedPagePosY);
  363.            
  364.         end else Players[i].BigText(const_GeneratedPageLayer, 'Empty SortedMapList', 120, const_GeneratedPageColour, const_GeneratedPageScale, const_GeneratedPagePosX, const_GeneratedPagePosY);
  365.        
  366.         if GV_CurrentPlayerPage[i][const_SearchResult] <> 0 then begin
  367.        
  368.             if (Players[i].KeyUp) and (GV_CurrentPlayerPage[i][const_SearchResult] > 1) then
  369.             Dec(GV_CurrentPlayerPage[i][const_SearchResult], 1);
  370.            
  371.             if (Players[i].KeyCrouch) and (GV_CurrentPlayerPage[i][const_SearchResult] < GV_SearchResultPages[i]) then
  372.             Inc(GV_CurrentPlayerPage[i][const_SearchResult], 1);
  373.            
  374.             GeneratedPage := ' SearchResult: '+inttostr(GV_SearchResult[i].Count)+iif(GV_SearchResult[i].Count = 1, ' Map', ' Maps')+#10+' Page: '+inttostr(GV_CurrentPlayerPage[i][const_SearchResult])+' / '+inttostr(GV_SearchResultPages[i])+' Length: '+inttostr(iif(GV_CurrentPlayerPage[i][const_SearchResult]=GV_SearchResultPages[i], GV_SearchResult[i].Count-(GV_SearchResultPages[i]-1)*const_MapsPerPage, const_MapsPerPage))+' / '+inttostr(const_MapsPerPage)+#10+' Search Pattern: '+GV_SearchPattern[i]+#10#10;
  375.             for j := (GV_CurrentPlayerPage[i][const_SearchResult]-1)*const_MapsPerPage to GV_CurrentPlayerPage[i][const_SearchResult]*const_MapsPerPage-1 do begin
  376.                 if Game.CurrentMap=GV_SearchResult[i][j] then
  377.                 GeneratedPage := GeneratedPage+chr(149)+GV_SearchResult[i][j]+#10
  378.                 else
  379.                 GeneratedPage := GeneratedPage+' '+GV_SearchResult[i][j]+#10;
  380.                 if j = GV_SearchResult[i].Count-1 then
  381.                 break;
  382.             end;
  383.             Players[i].BigText(const_GeneratedPageLayer, GeneratedPage, 120, const_GeneratedPageColour, const_GeneratedPageScale, const_GeneratedPagePosX, const_GeneratedPagePosY);
  384.            
  385.         end;
  386.        
  387.     end;
  388.    
  389. end;
  390.  
  391. procedure Init;
  392. var
  393.     i: Byte;
  394. begin
  395.     CreateSortedMapList(0);
  396.    
  397.     GV_MapListPages := iif(Game.MapsList.MapsCount mod const_MapsPerPage = 0, Game.MapsList.MapsCount div const_MapsPerPage, Game.MapsList.MapsCount div const_MapsPerPage + 1);
  398.     WriteLn('MapListReader: MapList: Counted '+inttostr(GV_MapListPages)+' '+iif(GV_MapListPages = 1, 'page', 'pages')+' for '+inttostr(Game.MapsList.MapsCount)+iif(Game.MapsList.MapsCount = 1, ' map', ' maps'));
  399.    
  400.     for i := 1 to 32 do begin
  401.         GV_SearchResult[i] := File.CreateStringList;
  402.         Players[i].OnSpeak := @OnPlayerSpeak;
  403.         Players[i].OnCommand := @OnPlayerCommand;
  404.     end;
  405.    
  406.     Game.OnLeave := @OnLeave;
  407.     Game.OnAdminCommand := @OnAdminCommand;
  408.     Game.TickThreshold := 5;
  409.     Game.OnClockTick := @OnClockTick;
  410. end;
  411.  
  412. begin
  413.     Init;
  414. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement